aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author简律纯 <i@jyunko.cn>2024-03-12 03:38:31 +0800
committer简律纯 <i@jyunko.cn>2024-03-12 03:38:31 +0800
commit20ea54161311077642b75d9d07bfeeb1b80e562e (patch)
treedb6f8f15ff4447d9315e0337bf57004ba6cff417
parent6a480c9b1efb70410e11c8233382c5c90b7e68cb (diff)
downloadipm-dev.tar.gz
ipm-dev.zip
chore(_freeze): add create_xml_file methoddev
-rw-r--r--examples/pyproject.toml13
-rw-r--r--src/ipm/utils/_freeze.py28
2 files changed, 11 insertions, 30 deletions
diff --git a/examples/pyproject.toml b/examples/pyproject.toml
deleted file mode 100644
index f0eeda3..0000000
--- a/examples/pyproject.toml
+++ /dev/null
@@ -1,13 +0,0 @@
-[project]
-name = "examples"
-version = "0.1.0"
-description = "EXAMPLES 规则包"
-authors = [
- {name = "admin",email = "admin@example.com"},
-]
-license = {text = "MIT"}
-webpage = ""
-unzip = 1
-dependencies = ["infini"]
-requires-python = ">=3.8"
-readme = "README.md" \ No newline at end of file
diff --git a/src/ipm/utils/_freeze.py b/src/ipm/utils/_freeze.py
index d054fe9..b4049ec 100644
--- a/src/ipm/utils/_freeze.py
+++ b/src/ipm/utils/_freeze.py
@@ -1,5 +1,6 @@
from curses import meta
from importlib import metadata
+from logging import warn
from pathlib import Path
from struct import pack
import tarfile
@@ -24,21 +25,14 @@ def extract_tar_gz(input_filename: str, output_folder: str) -> None:
def create_xml_file(meta_data: InfiniProject, output_folder: str | Path) -> None:
- package = {}
- package['_id'] = meta_data.name
- package['version'] = meta_data.version
- package['description'] = meta_data.description
- authors = meta_data.authors
- if authors is not None:
- package['author'] = authors.first
- package['_license'] = meta_data.license
- package['webpage'] = meta_data.webpage
- package['unzip'] = meta_data.unzip
-
- with open(path.join(output_folder, package["_id"], ".xml"), mode='w', encoding='utf8') as xml_file:
- xml_file.write(f"""<package id="{_id}"
- name="{_id}: {description}"
+ from collections import defaultdict
+ meta_data_dict = defaultdict(
+ lambda: '', meta_data._data.get('project')) # type: ignore
+
+ with open(path.join(output_folder, f"{meta_data.name}.xml"), mode='w', encoding='utf8') as xml_file:
+ xml_file.write("""<package id="{name}"
+ name="{name}: {description}"
webpage="{webpage}"
- author="{author}"
- license="{_license}"
- unzip="{unzip}"/>""".format(**package))
+ author="{authors[0][name]}"
+ license="{license}"
+ unzip="{unzip}"/>""".format(**meta_data_dict))