appstream-python 0.7__tar.gz → 0.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {appstream-python-0.7/appstream_python.egg-info → appstream-python-0.8}/PKG-INFO +1 -1
- {appstream-python-0.7 → appstream-python-0.8}/appstream_python/Component.py +52 -5
- appstream-python-0.8/appstream_python/version.txt +1 -0
- {appstream-python-0.7 → appstream-python-0.8/appstream_python.egg-info}/PKG-INFO +1 -1
- {appstream-python-0.7 → appstream-python-0.8}/tests/test_appstream_data.py +18 -0
- appstream-python-0.7/appstream_python/version.txt +0 -1
- {appstream-python-0.7 → appstream-python-0.8}/LICENSE +0 -0
- {appstream-python-0.7 → appstream-python-0.8}/MANIFEST.in +0 -0
- {appstream-python-0.7 → appstream-python-0.8}/README.md +0 -0
- {appstream-python-0.7 → appstream-python-0.8}/appstream_python/Collection.py +0 -0
- {appstream-python-0.7 → appstream-python-0.8}/appstream_python/Release.py +0 -0
- {appstream-python-0.7 → appstream-python-0.8}/appstream_python/Shared.py +0 -0
- {appstream-python-0.7 → appstream-python-0.8}/appstream_python/StandardConstants.py +0 -0
- {appstream-python-0.7 → appstream-python-0.8}/appstream_python/__init__.py +0 -0
- {appstream-python-0.7 → appstream-python-0.8}/appstream_python/_helper.py +0 -0
- {appstream-python-0.7 → appstream-python-0.8}/appstream_python.egg-info/SOURCES.txt +0 -0
- {appstream-python-0.7 → appstream-python-0.8}/appstream_python.egg-info/dependency_links.txt +0 -0
- {appstream-python-0.7 → appstream-python-0.8}/appstream_python.egg-info/requires.txt +0 -0
- {appstream-python-0.7 → appstream-python-0.8}/appstream_python.egg-info/top_level.txt +0 -0
- {appstream-python-0.7 → appstream-python-0.8}/pyproject.toml +0 -0
- {appstream-python-0.7 → appstream-python-0.8}/setup.cfg +0 -0
- {appstream-python-0.7 → appstream-python-0.8}/tests/test_description.py +0 -0
- {appstream-python-0.7 → appstream-python-0.8}/tests/test_display_length.py +0 -0
- {appstream-python-0.7 → appstream-python-0.8}/tests/test_releases.py +0 -0
|
@@ -4,6 +4,7 @@ from .Release import ReleaseList
|
|
|
4
4
|
from ._helper import assert_func
|
|
5
5
|
from .StandardConstants import *
|
|
6
6
|
from lxml import etree
|
|
7
|
+
import dataclasses
|
|
7
8
|
import io
|
|
8
9
|
import os
|
|
9
10
|
|
|
@@ -190,6 +191,44 @@ class DisplayLength:
|
|
|
190
191
|
return False
|
|
191
192
|
|
|
192
193
|
|
|
194
|
+
@dataclasses.dataclass
|
|
195
|
+
class Developer:
|
|
196
|
+
"Represents a <developer> tag"
|
|
197
|
+
|
|
198
|
+
id: Optional[str] = None
|
|
199
|
+
name: TranslateableTag = dataclasses.field(default_factory=lambda: TranslateableTag())
|
|
200
|
+
|
|
201
|
+
def load_tag(self, tag: etree.Element) -> None:
|
|
202
|
+
"Loads the data from a XML tag"
|
|
203
|
+
self.id = tag.get("id")
|
|
204
|
+
|
|
205
|
+
self.name.load_tags(tag.findall("name"))
|
|
206
|
+
|
|
207
|
+
def get_tag(self) -> etree.Element:
|
|
208
|
+
"""
|
|
209
|
+
Returns the XML Tag
|
|
210
|
+
|
|
211
|
+
:return: The Tag
|
|
212
|
+
"""
|
|
213
|
+
tag = etree.Element("developer")
|
|
214
|
+
|
|
215
|
+
if self.id is not None:
|
|
216
|
+
tag.set("id", self.id)
|
|
217
|
+
|
|
218
|
+
self.name.write_tags(tag, "name")
|
|
219
|
+
|
|
220
|
+
return tag
|
|
221
|
+
|
|
222
|
+
def clear(self) -> None:
|
|
223
|
+
"""Resets all data"""
|
|
224
|
+
self.id = None
|
|
225
|
+
self.name.clear()
|
|
226
|
+
|
|
227
|
+
def is_empty(self) -> bool:
|
|
228
|
+
"Checks if the developer tag is empty"
|
|
229
|
+
return self.id is None and self.name.get_default_text() == ""
|
|
230
|
+
|
|
231
|
+
|
|
193
232
|
class AppstreamComponent:
|
|
194
233
|
"Represents AppStream Component"
|
|
195
234
|
|
|
@@ -203,8 +242,8 @@ class AppstreamComponent:
|
|
|
203
242
|
self.name: TranslateableTag = TranslateableTag()
|
|
204
243
|
"The component name"
|
|
205
244
|
|
|
206
|
-
self.
|
|
207
|
-
"The developer
|
|
245
|
+
self.developer: Developer = Developer()
|
|
246
|
+
"The developer"
|
|
208
247
|
|
|
209
248
|
self.summary: TranslateableTag = TranslateableTag()
|
|
210
249
|
"The component summary"
|
|
@@ -284,7 +323,7 @@ class AppstreamComponent:
|
|
|
284
323
|
self.id = ""
|
|
285
324
|
self.type = "desktop"
|
|
286
325
|
self.name.clear()
|
|
287
|
-
self.
|
|
326
|
+
self.developer.clear()
|
|
288
327
|
self.summary.clear()
|
|
289
328
|
self.description.items.clear()
|
|
290
329
|
self.metadata_license = ""
|
|
@@ -357,7 +396,11 @@ class AppstreamComponent:
|
|
|
357
396
|
|
|
358
397
|
self.name.load_tags(tag.findall("name"))
|
|
359
398
|
|
|
360
|
-
|
|
399
|
+
# For backward compatibility
|
|
400
|
+
self.developer.name.load_tags(tag.findall("developer_name"))
|
|
401
|
+
|
|
402
|
+
if (developer_tag := tag.find("developer")) is not None:
|
|
403
|
+
self.developer.load_tag(developer_tag)
|
|
361
404
|
|
|
362
405
|
self.summary.load_tags(tag.findall("summary"))
|
|
363
406
|
|
|
@@ -554,7 +597,8 @@ class AppstreamComponent:
|
|
|
554
597
|
|
|
555
598
|
self.name.write_tags(tag, "name")
|
|
556
599
|
|
|
557
|
-
self.
|
|
600
|
+
if not self.developer.is_empty():
|
|
601
|
+
tag.append(self.developer.get_tag())
|
|
558
602
|
|
|
559
603
|
self.summary.write_tags(tag, "summary")
|
|
560
604
|
|
|
@@ -604,6 +648,9 @@ class AppstreamComponent:
|
|
|
604
648
|
if len(provides_tag.getchildren()) == 0:
|
|
605
649
|
tag.remove(provides_tag)
|
|
606
650
|
|
|
651
|
+
if len(self.releases) != 0:
|
|
652
|
+
tag.append(self.releases.get_tag())
|
|
653
|
+
|
|
607
654
|
if self.project_group:
|
|
608
655
|
project_group_tag = etree.SubElement(tag, "project_group")
|
|
609
656
|
project_group_tag.text = self.project_group
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.8
|
|
@@ -11,6 +11,8 @@ def assert_component_jdtextedit(component: appstream_python.AppstreamComponent)
|
|
|
11
11
|
assert component.id == "com.gitlab.JakobDev.jdTextEdit"
|
|
12
12
|
assert component.name.get_default_text() == "jdTextEdit"
|
|
13
13
|
assert component.summary.get_default_text() == "An advanced text editor"
|
|
14
|
+
assert component.developer.name.get_default_text() == "JakobDev"
|
|
15
|
+
assert component.developer.id is None
|
|
14
16
|
assert component.project_license == "GPL-3.0-only"
|
|
15
17
|
assert component.metadata_license == "CC0-1.0"
|
|
16
18
|
assert component.project_group is None
|
|
@@ -53,3 +55,19 @@ def test_from_string() -> None:
|
|
|
53
55
|
with open(JDTEXTEDIT_METAINFO, "r") as f:
|
|
54
56
|
component = appstream_python.AppstreamComponent.from_string(f.read())
|
|
55
57
|
assert_component_jdtextedit(component)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def test_save_jdtextedit_data(tmp_path: pathlib.Path) -> None:
|
|
61
|
+
old_component = appstream_python.AppstreamComponent.from_file(JDTEXTEDIT_METAINFO)
|
|
62
|
+
old_component.save_file(tmp_path / "jdTextEdit.metainfo.xml")
|
|
63
|
+
|
|
64
|
+
new_component = appstream_python.AppstreamComponent.from_file(tmp_path / "jdTextEdit.metainfo.xml")
|
|
65
|
+
assert_component_jdtextedit(new_component)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def test_data_appstream_cli() -> None:
|
|
69
|
+
component = appstream_python.AppstreamComponent.from_file(DATA_DIR / "org.freedesktop.appstream.cli.metainfo.xml")
|
|
70
|
+
|
|
71
|
+
assert component.project_group == "Freedesktop"
|
|
72
|
+
assert component.developer.id == "org.freedesktop"
|
|
73
|
+
assert component.developer.name.get_default_text() == "Matthias Klumpp"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.7
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{appstream-python-0.7 → appstream-python-0.8}/appstream_python.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|