appstream-python 0.7__py3-none-any.whl → 0.8.1__py3-none-any.whl
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/Collection.py +19 -3
- appstream_python/Component.py +55 -8
- appstream_python/version.txt +1 -1
- {appstream_python-0.7.dist-info → appstream_python-0.8.1.dist-info}/METADATA +1 -1
- appstream_python-0.8.1.dist-info/RECORD +13 -0
- {appstream_python-0.7.dist-info → appstream_python-0.8.1.dist-info}/WHEEL +1 -1
- appstream_python-0.7.dist-info/RECORD +0 -13
- {appstream_python-0.7.dist-info → appstream_python-0.8.1.dist-info}/LICENSE +0 -0
- {appstream_python-0.7.dist-info → appstream_python-0.8.1.dist-info}/top_level.txt +0 -0
appstream_python/Collection.py
CHANGED
|
@@ -12,13 +12,24 @@ class AppstreamCollection:
|
|
|
12
12
|
def _add_appstream_tag(self, tag: etree.Element) -> None:
|
|
13
13
|
component_data = AppstreamComponent()
|
|
14
14
|
component_data.parse_component_tag(tag)
|
|
15
|
+
self.add_component(component_data)
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
def add_component(self, component: AppstreamComponent) -> None:
|
|
18
|
+
"Adds a AppstreamComponent to the collection"
|
|
19
|
+
self._components[component.id] = component
|
|
17
20
|
|
|
18
|
-
for i in
|
|
21
|
+
for i in component.categories:
|
|
19
22
|
if i not in self._categories:
|
|
20
23
|
self._categories[i] = []
|
|
21
|
-
self._categories[i].append(
|
|
24
|
+
self._categories[i].append(component.id)
|
|
25
|
+
|
|
26
|
+
def load_uncompressed_appstream_collection(self, path: str) -> None:
|
|
27
|
+
"Loads a uncompressed collection"
|
|
28
|
+
with open(path, "rb") as f:
|
|
29
|
+
root = etree.fromstring(f.read())
|
|
30
|
+
|
|
31
|
+
for i in root.findall("component"):
|
|
32
|
+
self._add_appstream_tag(i)
|
|
22
33
|
|
|
23
34
|
def load_compressed_appstream_collection(self, path: str) -> None:
|
|
24
35
|
"Loads a GZIP compressed collection"
|
|
@@ -72,5 +83,10 @@ class AppstreamCollection:
|
|
|
72
83
|
with open(path, "w", encoding="utf-8") as f:
|
|
73
84
|
f.write(etree.tostring(self.get_collection_tag(), pretty_print=True, xml_declaration=True, encoding="utf-8").decode("utf-8"))
|
|
74
85
|
|
|
86
|
+
def write_compressed_file(self, path: str) -> None:
|
|
87
|
+
"Writes a Uncompressed collection file"
|
|
88
|
+
with gzip.open(path, "wb") as f:
|
|
89
|
+
f.write(etree.tostring(self.get_collection_tag(), pretty_print=True, xml_declaration=True, encoding="utf-8"))
|
|
90
|
+
|
|
75
91
|
def __len__(self) -> int:
|
|
76
92
|
return len(self._components)
|
appstream_python/Component.py
CHANGED
|
@@ -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 = ""
|
|
@@ -318,7 +357,7 @@ class AppstreamComponent:
|
|
|
318
357
|
|
|
319
358
|
def get_available_languages(self) -> list[str]:
|
|
320
359
|
"Returns a list with all available languages of the Component"
|
|
321
|
-
lang_list = self.name.get_available_languages() + self.summary.get_available_languages() + self.
|
|
360
|
+
lang_list = self.name.get_available_languages() + self.summary.get_available_languages() + self.developer.name.get_available_languages()
|
|
322
361
|
return list(set(lang_list))
|
|
323
362
|
|
|
324
363
|
def _parse_relation_tag(self, tag: etree.Element) -> None:
|
|
@@ -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
|
|
|
@@ -366,11 +409,11 @@ class AppstreamComponent:
|
|
|
366
409
|
self.description.load_tags(description_tag)
|
|
367
410
|
|
|
368
411
|
metadata_license_tag = tag.find("metadata_license")
|
|
369
|
-
if metadata_license_tag is not None:
|
|
412
|
+
if metadata_license_tag is not None and metadata_license_tag.text is not None:
|
|
370
413
|
self.metadata_license = metadata_license_tag.text.strip()
|
|
371
414
|
|
|
372
415
|
project_license_tag = tag.find("project_license")
|
|
373
|
-
if project_license_tag is not None:
|
|
416
|
+
if project_license_tag is not None and project_license_tag.text is not None:
|
|
374
417
|
self.project_license = project_license_tag.text.strip()
|
|
375
418
|
|
|
376
419
|
categories_tag = tag.find("categories")
|
|
@@ -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
|
appstream_python/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.8.1
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
appstream_python/Collection.py,sha256=1WG1jyQCUEtaU8jv_iOjMZDibUjSSv9VkWkVUz9TtTA,3472
|
|
2
|
+
appstream_python/Component.py,sha256=8HxrSdkiMv3Ff-pfFLbMxxDC4A20gzIyE4g7QkxiHb0,24302
|
|
3
|
+
appstream_python/Release.py,sha256=sLQbv0T7FLYZYcfGivveVOKFD6rptoCAK0lbYCFYeiE,5409
|
|
4
|
+
appstream_python/Shared.py,sha256=zHeUDicNbuP_jXx3VTSNGuq7XFGUryZg0zMVCgGdXgo,13959
|
|
5
|
+
appstream_python/StandardConstants.py,sha256=-SzBKeXWFgY_6wc3SgptDlj88gOE_ztXBeBM3Xx3ko4,2376
|
|
6
|
+
appstream_python/__init__.py,sha256=eB0PvIoWrH0ZkNq2yY2h9xujdNqJMKmyM01KDpm6Yis,212
|
|
7
|
+
appstream_python/_helper.py,sha256=T1On8-taSPoKgpz9u8briuRO0uurcBL415o8g2Gc678,326
|
|
8
|
+
appstream_python/version.txt,sha256=qvZyHcN8QLQjOsz8CB8ld2_zvR0qS51c6nYNHCz4ZmU,6
|
|
9
|
+
appstream_python-0.8.1.dist-info/LICENSE,sha256=KHWQLS2VDTyyF0CMgSrCU2j758vzhIUXA4viB-DWlTI,1318
|
|
10
|
+
appstream_python-0.8.1.dist-info/METADATA,sha256=2f82WuWQSonypjpDg6zB4_Q25GJJ8IO2U4J1O7debok,1330
|
|
11
|
+
appstream_python-0.8.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
12
|
+
appstream_python-0.8.1.dist-info/top_level.txt,sha256=TEnvfaZcEAhAofLtB0lquKH1fwr9C-9dxpGN405dZiQ,17
|
|
13
|
+
appstream_python-0.8.1.dist-info/RECORD,,
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
appstream_python/Collection.py,sha256=D5Sx8M4YovOZ2OKkubgY0rxRA2IwhdXJqcFuAhhoIUE,2777
|
|
2
|
-
appstream_python/Component.py,sha256=hKmlhPlYQ1K0eBQmYe8nXmU_Iwk_MtLW_BR487_yWgk,23038
|
|
3
|
-
appstream_python/Release.py,sha256=sLQbv0T7FLYZYcfGivveVOKFD6rptoCAK0lbYCFYeiE,5409
|
|
4
|
-
appstream_python/Shared.py,sha256=zHeUDicNbuP_jXx3VTSNGuq7XFGUryZg0zMVCgGdXgo,13959
|
|
5
|
-
appstream_python/StandardConstants.py,sha256=-SzBKeXWFgY_6wc3SgptDlj88gOE_ztXBeBM3Xx3ko4,2376
|
|
6
|
-
appstream_python/__init__.py,sha256=eB0PvIoWrH0ZkNq2yY2h9xujdNqJMKmyM01KDpm6Yis,212
|
|
7
|
-
appstream_python/_helper.py,sha256=T1On8-taSPoKgpz9u8briuRO0uurcBL415o8g2Gc678,326
|
|
8
|
-
appstream_python/version.txt,sha256=OxrdSJ-JYVYLwVYvEMq892K86WFiPMo2LwEoUi_h7Sk,4
|
|
9
|
-
appstream_python-0.7.dist-info/LICENSE,sha256=KHWQLS2VDTyyF0CMgSrCU2j758vzhIUXA4viB-DWlTI,1318
|
|
10
|
-
appstream_python-0.7.dist-info/METADATA,sha256=7CXVR-UkoBh8Vry0buCR69wPSMYrazgqXXDFvfNG40I,1328
|
|
11
|
-
appstream_python-0.7.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
|
|
12
|
-
appstream_python-0.7.dist-info/top_level.txt,sha256=TEnvfaZcEAhAofLtB0lquKH1fwr9C-9dxpGN405dZiQ,17
|
|
13
|
-
appstream_python-0.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|