appstream-python 0.7__py3-none-any.whl → 0.8__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.
@@ -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.developer_name: TranslateableTag = TranslateableTag()
207
- "The developer name"
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.developer_name.clear()
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
- self.developer_name.load_tags(tag.findall("developer_name"))
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.developer_name.write_tags(tag, "developer_name")
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
@@ -1 +1 @@
1
- 0.7
1
+ 0.8
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: appstream-python
3
- Version: 0.7
3
+ Version: 0.8
4
4
  Summary: A library for dealing with Freedesktop Appstream data
5
5
  Author-email: JakobDev <jakobdev@gmx.de>
6
6
  License: BSD-2-Clause
@@ -1,13 +1,13 @@
1
1
  appstream_python/Collection.py,sha256=D5Sx8M4YovOZ2OKkubgY0rxRA2IwhdXJqcFuAhhoIUE,2777
2
- appstream_python/Component.py,sha256=hKmlhPlYQ1K0eBQmYe8nXmU_Iwk_MtLW_BR487_yWgk,23038
2
+ appstream_python/Component.py,sha256=BgFWQUv0XBsUZYp4WTuONXAmf80XE64Q7QG0x2PcD1U,24219
3
3
  appstream_python/Release.py,sha256=sLQbv0T7FLYZYcfGivveVOKFD6rptoCAK0lbYCFYeiE,5409
4
4
  appstream_python/Shared.py,sha256=zHeUDicNbuP_jXx3VTSNGuq7XFGUryZg0zMVCgGdXgo,13959
5
5
  appstream_python/StandardConstants.py,sha256=-SzBKeXWFgY_6wc3SgptDlj88gOE_ztXBeBM3Xx3ko4,2376
6
6
  appstream_python/__init__.py,sha256=eB0PvIoWrH0ZkNq2yY2h9xujdNqJMKmyM01KDpm6Yis,212
7
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,,
8
+ appstream_python/version.txt,sha256=_fJ28Bg8cXQoI7Bh9zQtWB5W3grxBkgzm1JSSeJu6U8,4
9
+ appstream_python-0.8.dist-info/LICENSE,sha256=KHWQLS2VDTyyF0CMgSrCU2j758vzhIUXA4viB-DWlTI,1318
10
+ appstream_python-0.8.dist-info/METADATA,sha256=6GzziBTwnxogHEFdDf_uxfUhsxG5EgiN-15nUJ7qOw4,1328
11
+ appstream_python-0.8.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
12
+ appstream_python-0.8.dist-info/top_level.txt,sha256=TEnvfaZcEAhAofLtB0lquKH1fwr9C-9dxpGN405dZiQ,17
13
+ appstream_python-0.8.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.3)
2
+ Generator: bdist_wheel (0.43.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5