gedcom-x 0.5.6__py3-none-any.whl → 0.5.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.
Files changed (64) hide show
  1. {gedcom_x-0.5.6.dist-info → gedcom_x-0.5.8.dist-info}/METADATA +1 -1
  2. gedcom_x-0.5.8.dist-info/RECORD +56 -0
  3. gedcomx/Extensions/__init__.py +1 -0
  4. gedcomx/Extensions/rs10/__init__.py +1 -0
  5. gedcomx/Extensions/rs10/rsLink.py +116 -0
  6. gedcomx/TopLevelTypeCollection.py +1 -1
  7. gedcomx/__init__.py +43 -41
  8. gedcomx/{Address.py → address.py} +13 -13
  9. gedcomx/{Agent.py → agent.py} +52 -24
  10. gedcomx/{Attribution.py → attribution.py} +36 -9
  11. gedcomx/{Conclusion.py → conclusion.py} +49 -21
  12. gedcomx/converter.py +1049 -0
  13. gedcomx/coverage.py +55 -0
  14. gedcomx/{Date.py → date.py} +11 -4
  15. gedcomx/{Document.py → document.py} +27 -8
  16. gedcomx/{Event.py → event.py} +102 -27
  17. gedcomx/{EvidenceReference.py → evidence_reference.py} +2 -2
  18. gedcomx/{Fact.py → fact.py} +45 -34
  19. gedcomx/{Gedcom5x.py → gedcom5x.py} +78 -61
  20. gedcomx/gedcom7/Exceptions.py +9 -0
  21. gedcomx/gedcom7/Gedcom7.py +160 -0
  22. gedcomx/gedcom7/GedcomStructure.py +94 -0
  23. gedcomx/gedcom7/Specification.py +347 -0
  24. gedcomx/gedcom7/__init__.py +26 -0
  25. gedcomx/gedcom7/g7interop.py +205 -0
  26. gedcomx/gedcom7/logger.py +19 -0
  27. gedcomx/gedcomx.py +501 -0
  28. gedcomx/{Gender.py → gender.py} +29 -17
  29. gedcomx/group.py +63 -0
  30. gedcomx/{Identifier.py → identifier.py} +13 -16
  31. gedcomx/{LoggingHub.py → logging_hub.py} +21 -0
  32. gedcomx/{Mutations.py → mutations.py} +50 -26
  33. gedcomx/name.py +396 -0
  34. gedcomx/{Note.py → note.py} +17 -10
  35. gedcomx/{OnlineAccount.py → online_account.py} +1 -1
  36. gedcomx/{Person.py → person.py} +52 -29
  37. gedcomx/place_description.py +123 -0
  38. gedcomx/place_reference.py +62 -0
  39. gedcomx/qualifier.py +54 -0
  40. gedcomx/{Relationship.py → relationship.py} +33 -13
  41. gedcomx/resource.py +85 -0
  42. gedcomx/serialization.py +815 -0
  43. gedcomx/{SourceDescription.py → source_description.py} +144 -85
  44. gedcomx/{SourceReference.py → source_reference.py} +15 -14
  45. gedcomx/{Subject.py → subject.py} +30 -28
  46. gedcomx/{GedcomX.py → translation.py} +283 -446
  47. gedcomx/{URI.py → uri.py} +42 -26
  48. gedcom_x-0.5.6.dist-info/RECORD +0 -45
  49. gedcomx/Coverage.py +0 -36
  50. gedcomx/Group.py +0 -37
  51. gedcomx/Name.py +0 -276
  52. gedcomx/PlaceDescription.py +0 -70
  53. gedcomx/PlaceReference.py +0 -30
  54. gedcomx/Qualifier.py +0 -27
  55. gedcomx/Resource.py +0 -75
  56. gedcomx/Serialization.py +0 -401
  57. gedcomx/Translation.py +0 -219
  58. {gedcom_x-0.5.6.dist-info → gedcom_x-0.5.8.dist-info}/WHEEL +0 -0
  59. {gedcom_x-0.5.6.dist-info → gedcom_x-0.5.8.dist-info}/top_level.txt +0 -0
  60. /gedcomx/{Exceptions.py → exceptions.py} +0 -0
  61. /gedcomx/{ExtensibleEnum.py → extensible_enum.py} +0 -0
  62. /gedcomx/{Gedcom.py → gedcom.py} +0 -0
  63. /gedcomx/{SourceCitation.py → source_citation.py} +0 -0
  64. /gedcomx/{TextValue.py → textvalue.py} +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gedcom-x
3
- Version: 0.5.6
3
+ Version: 0.5.8
4
4
  Summary: Python implimentation of gedcom-x standard
5
5
  Author-email: "David J. Cartwright" <davidcartwright@hotmail.com>
6
6
  License: MIT
@@ -0,0 +1,56 @@
1
+ gedcomx/Logging.py,sha256=vBDOjawVXc4tCge1laYjy6_2Ves-fnGzG0m6NnLZejE,624
2
+ gedcomx/TopLevelTypeCollection.py,sha256=p99i-O5LXiXe3GlC6jWuz4nH1TAcKxOLbe0VRxWbSFY,1495
3
+ gedcomx/Zip.py,sha256=lBxcv-Vip45884EHj56wZJJ5I36Q38UuHUidDxQBoS8,14
4
+ gedcomx/__init__.py,sha256=bQs2gL9GfLTFJbDppCIhxn8HTwuJUBo1PUjeEqQuHFE,1723
5
+ gedcomx/address.py,sha256=zwvsA6N6edR3FJ31kraGfv250e70TAsi2AB-grZTkF8,4865
6
+ gedcomx/agent.py,sha256=voUM3pxxr3DTTwZUCZgkqONAux2FsoIIJAErlEofbZ4,9321
7
+ gedcomx/attribution.py,sha256=cGvRyzofLSORzgtv7dFWAh8EKwWfd_I7oxpKeyqNBU0,3381
8
+ gedcomx/conclusion.py,sha256=yU0eul3rj6VBb5lFAPTAY9138x15yYQVjO6dN2gcdKo,9187
9
+ gedcomx/converter.py,sha256=yP3xw1vo0uVaM74_fyE51UQA0lq2eBzfcnasLyo-DfU,51508
10
+ gedcomx/coverage.py,sha256=E6Oa9O3ahbE81zTLgX2QQ-VbnLdzjWvqeRpY_KO2v_s,1837
11
+ gedcomx/date.py,sha256=rkvpVtziwvzsbGip8OkyeJXsi1spc4S6uWpRcNSSxCo,2344
12
+ gedcomx/document.py,sha256=iS3eANznPx8TxBytPa3CtwHS4QuPs80skQNdL-Rwis4,3519
13
+ gedcomx/event.py,sha256=YJhaWp42RCQdELIYzjZVrZKdb5E9qjs-MfUrujZLIbU,13324
14
+ gedcomx/evidence_reference.py,sha256=9Wo2iF8G8BIni5EvuqFj78KKbIBbSs1ZJQJ0pGiUoM4,348
15
+ gedcomx/exceptions.py,sha256=0OdPM3euhBMgX8o61ZwPuKeN8zPuSuuDcSBFflVGFqk,587
16
+ gedcomx/extensible_enum.py,sha256=DftCZLMBNul3C9hwh-rf0GE3SVdvylvyd5mt7bX_l6o,6535
17
+ gedcomx/fact.py,sha256=vYS4yweXGN6gX02sQXZbIiye_SLO3f3mRoCvKmgQ5po,24871
18
+ gedcomx/gedcom.py,sha256=l_BuLBynQacDtpLjhs2Afrabfiqt2Opoo_5_7myI7Z4,1709
19
+ gedcomx/gedcom5x.py,sha256=V4kLW-TJobJbaVRYPJVApMUYI2pPbEBHWetXQ-mwzbM,23138
20
+ gedcomx/gedcomx.py,sha256=dIbPas65wWcj3BeCqqRauE6WK2iGgjSj7olekF5H0pU,19019
21
+ gedcomx/gender.py,sha256=3om8xY-mjAx1lGUs9XZwNR5x-Dmqxvsh9NDcw8vy2K0,2698
22
+ gedcomx/group.py,sha256=8yuQuZb6XE56A3J57pqISPIsZwfY0zWyvQcBn0-3zLs,2531
23
+ gedcomx/identifier.py,sha256=_o821Y1dIkcC9knb4GeSD691o9Nj-A_bS2MHHNft--0,8492
24
+ gedcomx/logging_hub.py,sha256=f4z1r6WL3TdL1kg1eaCfCk7XEn9epCH5zUCXd1OT4mc,7793
25
+ gedcomx/mutations.py,sha256=3TSNZggB6kNsys7XLojgzwiHPNGnmz-XBK2Fnuqg6KA,7224
26
+ gedcomx/name.py,sha256=1DffrckDP0_A05bHDxV9KgMhGlXPIP5SNgtZQEA84Nw,18643
27
+ gedcomx/note.py,sha256=URgLdSmrSCSA9hx4eZzAUPDSWph0pMoUyRQp9qafGss,2547
28
+ gedcomx/online_account.py,sha256=zZliLAmrtQnPJH0z-UgfqBdKDhq8Y3eBbViKsJnRrkg,291
29
+ gedcomx/person.py,sha256=71zig0D708qGQmLhHZct9xAnp9uVdQ4E0sd7WFVwO5Y,8103
30
+ gedcomx/place_description.py,sha256=rXYQnYcyZemJtZnkMxqd8-4AXm8Ez_e09PvBQG_9ucc,5563
31
+ gedcomx/place_reference.py,sha256=sEo_8PIEeuO0VzBCYhORhxvN4opuGk4RweOlPTjTqVY,2112
32
+ gedcomx/qualifier.py,sha256=nM02EW8uEpZXUhejX9YTZk1sD0Why-_27RgUdJrZWkM,1778
33
+ gedcomx/relationship.py,sha256=D2qsgUZ-s3HJWI8IlSahissFVyfa6-YhSb6P0QIReVk,4265
34
+ gedcomx/resource.py,sha256=c1nID0mzDMNyq8vQWZmISLlGm765Ku_m6BJmPA9yanI,2674
35
+ gedcomx/serialization.py,sha256=RvrIQkAJJNmIk6qHomEbikkuudk9ei9Tc_C17xr-GJs,34015
36
+ gedcomx/source_citation.py,sha256=aW-lEb7bT9QU49GiBjJppFMBvtisR6fhVVuXjr5y4vQ,742
37
+ gedcomx/source_description.py,sha256=9rrFVgFXIPF-M2suRQmJy_-e3uOak2kE_Bc3ZAtwTTs,14973
38
+ gedcomx/source_reference.py,sha256=fvAvhi046d82gQ53v64moq9o11VulHQbZ1FPErjHDjw,5190
39
+ gedcomx/subject.py,sha256=AQkC2fZOdEIXjIfoKIh7bI3heqkupeCo5j6pFAdrbms,3084
40
+ gedcomx/textvalue.py,sha256=6B0wMxL0nigFNzhXZDhbTONvFGbnM2t2NcDZiZuu4Zw,1112
41
+ gedcomx/translation.py,sha256=nCs6jAXHBg9qCePcCnY0S2uw-c8GfEn7IJhHHmDVe6s,61398
42
+ gedcomx/uri.py,sha256=0k6NySntsZoyAeEkTthNM-fcd49_3hPDanaKXLaYYzA,4558
43
+ gedcomx/Extensions/__init__.py,sha256=MQzi_whzlxiLiknUNh10hG8OVrNqJE38l6n-AwCssx8,24
44
+ gedcomx/Extensions/rs10/__init__.py,sha256=nSHoZiD8hsCAyE-KyRTuWSLqSJSFh12kSz7hqilAMps,26
45
+ gedcomx/Extensions/rs10/rsLink.py,sha256=yZhd-XIqERhBD4w1-VsIFJ7IeR09W0JYK8fAbkIR0zs,4353
46
+ gedcomx/gedcom7/Exceptions.py,sha256=xeKr4x8b7r8pOqJ9yMpsCVTyxPeOlREDGgKoM5rX4U0,149
47
+ gedcomx/gedcom7/Gedcom7.py,sha256=i_g9W0qsZQYLMoD2sBCA13ibKRYFnSf4uj9-ix_tE4Q,5614
48
+ gedcomx/gedcom7/GedcomStructure.py,sha256=ZKNoEcXc41KdrCLPx-A8ohOU9VYmXAkFc4xuZExsBPw,3435
49
+ gedcomx/gedcom7/Specification.py,sha256=qIBe9wzL1GB0l0NyetS1ncbhz5C44b9nMyjAxHuqMt8,9245
50
+ gedcomx/gedcom7/__init__.py,sha256=8ELFZJ_j8RbRDKG9i6Sqb8s_CSxU9iM3bMN_0779rgI,679
51
+ gedcomx/gedcom7/g7interop.py,sha256=hSzwqeok2n7xziEvN2QiJY7bVCWrOnZIZWXubnkrv7w,9945
52
+ gedcomx/gedcom7/logger.py,sha256=QM1SySyh91UEhs90d2DMhH-s9qGF8XS8I8gr1eOcmfw,617
53
+ gedcom_x-0.5.8.dist-info/METADATA,sha256=E7gYz4fVbIoNVtFf9Mce6i5f4Nxj1mtKrpBNJnDqrps,4332
54
+ gedcom_x-0.5.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
55
+ gedcom_x-0.5.8.dist-info/top_level.txt,sha256=smVBF4nxSU-mzCd6idtRYTbYjPICMMi8pTqewEmqF8Y,8
56
+ gedcom_x-0.5.8.dist-info/RECORD,,
@@ -0,0 +1 @@
1
+ from .rs10 import rsLink
@@ -0,0 +1 @@
1
+ from .rsLink import rsLink
@@ -0,0 +1,116 @@
1
+ '''
2
+ The "Link" Data Type
3
+ The Link data type defines a representation of an available transition from one application state to another.
4
+ The base definition of a link is provided by RFC 5988.
5
+
6
+ Instances of Link can be reasonably expected as extension elements to any GEDCOM X data type,
7
+ except data types that are defined by the GEDCOM X Conceptual Model to explicitly restrict extension properties.
8
+ '''
9
+
10
+ '''
11
+ 8/25/25, 0.5.5, built serialization, type checking in init for href
12
+ '''
13
+
14
+ from typing import List, Optional
15
+ from ...uri import URI
16
+ from ...exceptions import GedcomClassAttributeError
17
+
18
+
19
+ class rsLink():
20
+ """A link description object. RS Extension to GedcomX by FamilySearch.
21
+
22
+ Args:
23
+ rel (str): Link relation identifier. Required.
24
+ href (str, optional): Link target URI. If omitted, provide `template`.
25
+ template (str, optional): URI Template (see RFC 6570). If omitted, provide `href`.
26
+ type (str, optional): Media type(s) of the linked resource (RFC 2616 §3.7).
27
+ accept (str, optional): Acceptable media type(s) for updating the linked resource (RFC 2616 §3.7).
28
+ allow (str, optional): Allowable HTTP methods to transition to the linked resource (RFC 2616 §14.7).
29
+ hreflang (str, optional): Language of the linked resource (e.g., BCP-47 tag).
30
+ title (str, optional): Human-readable label for the link.
31
+
32
+ Raises:
33
+ ValueError: If neither `href` nor `template` is provided.
34
+ """
35
+
36
+ """Attribution Information for a Genealogy, Conclusion, Subject and child classes
37
+
38
+ Args:
39
+ contributor (Agent, optional): Contributor to object being attributed.
40
+ modified (timestamp, optional): timestamp for when this record was modified.
41
+ changeMessage (str, optional): Birth date (YYYY-MM-DD).
42
+ creator (Agent, optional): Creator of object being attributed.
43
+ created (timestamp, optional): timestamp for when this record was created
44
+
45
+ Raises:
46
+
47
+ """
48
+ identifier = "http://gedcomx.org/v1/Link"
49
+
50
+ def __init__(self,rel: Optional[URI] = None,
51
+ href: Optional[URI] = None,
52
+ template: Optional[str] = None,
53
+ type: Optional[str] = None,
54
+ accept: Optional[str] = None,
55
+ allow: Optional[str] = None,
56
+ hreflang: Optional[str] = None,
57
+ title: Optional[str] = None) -> None:
58
+
59
+ self.rel = rel
60
+ self.href = href if isinstance(href,URI) else URI.from_url(href) if isinstance(href,str) else None
61
+ self.template = template
62
+ self.type = type
63
+ self.accept = accept
64
+ self.allow = allow
65
+ self.hreflang = hreflang
66
+ self.title = title
67
+
68
+ if self.href is None and self.template is None:
69
+ raise GedcomClassAttributeError("href or template are required")
70
+
71
+ @property
72
+ def _as_dict_(self):
73
+ from ...serialization import Serialization
74
+ type_as_dict = {
75
+ "rel": self.rel._as_dict_ if self.rel else None,
76
+ "href": self.href._as_dict_ if self.href else None,
77
+ "template": self.template, # RFC 6570 template if used
78
+ "type": self.type, # media type (note: shadows built-in 'type')
79
+ "accept": self.accept,
80
+ "allow": self.allow,
81
+ "hreflang": self.hreflang,
82
+ "title": self.title,
83
+ }
84
+ return Serialization.serialize_dict(type_as_dict)
85
+
86
+ @property
87
+ def json(self):
88
+ import json
89
+ return json.dumps(self._as_dict_)
90
+
91
+ class _rsLinkList():
92
+ def __init__(self) -> None:
93
+ self.links = {}
94
+
95
+ def add(self,link: rsLink):
96
+ if link and isinstance(link,rsLink):
97
+ if link.rel in self.links.keys():
98
+ self.links[link.rel].append(link.href)
99
+ else:
100
+ self.links[link.rel] = [link.href]
101
+
102
+
103
+ @classmethod
104
+ def _from_json_(cls,data: dict):
105
+
106
+ link_list = _rsLinkList()
107
+ for rel in data.keys():
108
+ link_list.add(rsLink(rel,data[rel]))
109
+ return link_list
110
+
111
+ @property
112
+ def _as_dict_(self) -> dict:
113
+ return self.links
114
+
115
+
116
+
@@ -1,4 +1,4 @@
1
- from .TextValue import TextValue
1
+ from .textvalue import TextValue
2
2
 
3
3
  class TopLevelTypeCollection:
4
4
  def __init__(self):
gedcomx/__init__.py CHANGED
@@ -1,48 +1,50 @@
1
- from .Agent import Agent
2
- from .Address import Address
3
- from .Attribution import Attribution
4
- from .Conclusion import Conclusion
5
- from .Coverage import Coverage
6
- from .Date import Date
7
- from .Document import Document
8
- from .Document import DocumentType
9
- from .EvidenceReference import EvidenceReference
10
- from .ExtensibleEnum import ExtensibleEnum
11
- from .Event import Event
12
- from .Event import EventType
13
- from .Event import EventRole
14
- from .Fact import Fact
15
- from .Fact import FactQualifier
16
- from .Fact import FactType
17
- from .Gedcom import Gedcom
18
- from .Gedcom5x import Gedcom5x
19
- from .GedcomX import GedcomX, Translater
20
- from .Gender import Gender, GenderType
21
- from .Group import Group, GroupRole
22
- from .Identifier import Identifier, IdentifierType, IdentifierList
1
+ from .agent import Agent
2
+ from .address import Address
3
+ from .attribution import Attribution
4
+ from .conclusion import Conclusion
5
+ from .converter import GedcomConverter
6
+ from .coverage import Coverage
7
+ from .date import Date
8
+ from .document import Document
9
+ from .document import DocumentType
10
+ from .evidence_reference import EvidenceReference
11
+ from .extensible_enum import ExtensibleEnum
12
+ from .event import Event
13
+ from .event import EventType
14
+ from .event import EventRole
15
+ from .fact import Fact
16
+ from .fact import FactQualifier
17
+ from .fact import FactType
18
+ from .gedcom import Gedcom
19
+ from .gedcom5x import Gedcom5x, Gedcom5xRecord
20
+ from .gedcomx import GedcomX
21
+ from .gender import Gender, GenderType
22
+ from .group import Group, GroupRole
23
+ from .identifier import Identifier, IdentifierType, IdentifierList
23
24
  from .Logging import get_logger
24
- from .Name import Name, NameForm, NamePart, NamePartType, NameType, NamePartQualifier
25
- from .Note import Note
26
- from .OnlineAccount import OnlineAccount
27
- from .Person import Person, QuickPerson
28
- from .PlaceDescription import PlaceDescription
29
- from .PlaceReference import PlaceReference
30
- from .Qualifier import Qualifier
31
- from .Relationship import Relationship, RelationshipType
32
- from .Serialization import Serialization
33
- from .SourceCitation import SourceCitation
34
- from .SourceDescription import SourceDescription
35
- from .SourceDescription import ResourceType
36
- from .SourceReference import SourceReference
37
- from .Subject import Subject
38
- from .TextValue import TextValue
39
- from .Resource import Resource
40
- from .URI import URI
25
+ from .name import Name, NameForm, NamePart, NamePartType, NameType, NamePartQualifier
26
+ from .note import Note
27
+ from .online_account import OnlineAccount
28
+ from .person import Person, QuickPerson
29
+ from .place_description import PlaceDescription
30
+ from .place_reference import PlaceReference
31
+ from .qualifier import Qualifier
32
+ from .relationship import Relationship, RelationshipType
33
+ from .serialization import Serialization
34
+ from .source_citation import SourceCitation
35
+ from .source_description import SourceDescription
36
+ from .source_description import ResourceType
37
+ from .source_reference import SourceReference
38
+ from .subject import Subject
39
+ from .textvalue import TextValue
40
+ from .resource import Resource
41
+ from .uri import URI
42
+
41
43
 
42
44
  from .Extensions.rs10.rsLink import rsLink
43
45
 
44
- from .gedcom7 import Gedcom7, GedcomStructure
45
- from .Translation import g7toXtable
46
+ from .gedcom7.Gedcom7 import Gedcom7, GedcomStructure
47
+ from .translation import g7toXtable
46
48
 
47
49
 
48
50
 
@@ -1,7 +1,7 @@
1
1
  from typing import Optional
2
2
  import json
3
3
 
4
- from .Serialization import Serialization
4
+
5
5
 
6
6
  class Address:
7
7
  """A GedcomX Address Data Type
@@ -113,18 +113,18 @@ class Address:
113
113
 
114
114
  @property
115
115
  def _as_dict_(self):
116
- type_as_dict = {
117
- "city": self.city if self.city else None,
118
- "country": self.country if self.country else None,
119
- "postalCode": self.postalCode if self.postalCode else None,
120
- "stateOrProvince": self.stateOrProvince if self.stateOrProvince else None,
121
- "street": self.street if self.street else None,
122
- "street2": self.street2 if self.street2 else None,
123
- "street3": self.street3 if self.street3 else None,
124
- "street4": self.street4 if self.street4 else None,
125
- "street5": self.street5 if self.street5 else None,
126
- "street6": self.street6 if self.street6 else None
127
- }
116
+ from .serialization import Serialization
117
+ type_as_dict = {}
118
+ if self.city: type_as_dict["city"] = self.city
119
+ if self.country: type_as_dict["country"] = self.country
120
+ if self.postalCode: type_as_dict["postalCode"] = self.postalCode
121
+ if self.stateOrProvince: type_as_dict["stateOrProvince"] = self.stateOrProvince
122
+ if self.street: type_as_dict["street"] = self.street
123
+ if self.street2: type_as_dict["street2"] = self.street2
124
+ if self.street3: type_as_dict["street3"] = self.street3
125
+ if self.street4: type_as_dict["street4"] = self.street4
126
+ if self.street5: type_as_dict["street5"] = self.street5
127
+ if self.street6: type_as_dict["street6"] = self.street6
128
128
 
129
129
  return Serialization.serialize_dict(type_as_dict)
130
130
 
@@ -2,16 +2,31 @@ import base64
2
2
  import uuid
3
3
 
4
4
  from typing import List, Optional
5
+ """
6
+ ======================================================================
7
+ Project: Gedcom-X
8
+ File: agent.py
9
+ Author: David J. Cartwright
10
+ Purpose:
5
11
 
6
- from .Address import Address
7
- #from .Attribution import Attribution
8
- from .Identifier import Identifier, IdentifierList
12
+ Created: 2025-08-25
13
+ Updated:
14
+ -
15
+
16
+ ======================================================================
17
+ """
9
18
 
10
- from .OnlineAccount import OnlineAccount
11
- from .TextValue import TextValue
12
- from .Resource import Resource
13
- from .URI import URI
14
- from .Serialization import Serialization
19
+ """
20
+ ======================================================================
21
+ GEDCOM Module Type Imports
22
+ ======================================================================
23
+ """
24
+ from .address import Address
25
+ from .identifier import Identifier, IdentifierList
26
+ from .online_account import OnlineAccount
27
+ from .resource import Resource
28
+ from .textvalue import TextValue
29
+ from .uri import URI
15
30
 
16
31
 
17
32
  class Agent:
@@ -82,9 +97,10 @@ class Agent:
82
97
  self.emails = emails or []
83
98
  self.phones = phones or []
84
99
  self.addresses = addresses if addresses else []
100
+ self.person = person
85
101
  self.xnotes = []
86
102
  self.attribution = attribution or None
87
- self.uri = URI(fragment=self.id)
103
+ self.uri = URI(fragment=self.id) if self.id else None
88
104
 
89
105
  def _append_to_name(self, text_to_append: str):
90
106
  if self.names and self.names[0] and self.names[0].value:
@@ -113,8 +129,8 @@ class Agent:
113
129
  else:
114
130
  raise ValueError(f'name must be of type str or TextValue, recived {type(name_to_add)}')
115
131
 
116
- def add_note(self, note_to_add: 'Note'):
117
- from .Note import Note
132
+ def add_note(self, note_to_add):
133
+ from .note import Note
118
134
  if note_to_add and isinstance(note_to_add,Note):
119
135
  self.xnotes.append(note_to_add)
120
136
  else:
@@ -125,18 +141,29 @@ class Agent:
125
141
 
126
142
  @property
127
143
  def _as_dict_(self):
128
- type_as_dict = {
129
- "id": self.id if self.id else None,
130
- "identifiers": self.identifiers._as_dict_ if self.identifiers else None,
131
- "names": [name._as_dict_ for name in self.names],
132
- "homepage": self.homepage if self.homepage else None,
133
- "openid": self.openid if self.openid else None,
134
- "accounts": self.accounts if self.accounts else None,
135
- "emails": self.emails if self.emails else None,
136
- "phones": self.phones if self.phones else None,
137
- "addresses": [address._as_dict_ for address in self.addresses],
138
- "notes": [note._as_dict_ for note in self.xnotes]
139
- }
144
+ from .serialization import Serialization
145
+ type_as_dict = {}
146
+
147
+ if self.id:
148
+ type_as_dict["id"] = self.id
149
+ if self.identifiers:
150
+ type_as_dict["identifiers"] = self.identifiers._as_dict_
151
+ if self.names:
152
+ type_as_dict["names"] = [name._as_dict_ for name in self.names if name]
153
+ if self.homepage:
154
+ type_as_dict["homepage"] = self.homepage
155
+ if self.openid:
156
+ type_as_dict["openid"] = self.openid
157
+ if self.accounts:
158
+ type_as_dict["accounts"] = self.accounts
159
+ if self.emails:
160
+ type_as_dict["emails"] = self.emails
161
+ if self.phones:
162
+ type_as_dict["phones"] = self.phones
163
+ if self.addresses:
164
+ type_as_dict["addresses"] = [address._as_dict_ for address in self.addresses if address]
165
+ if self.xnotes:
166
+ type_as_dict["notes"] = [note._as_dict_() for note in self.xnotes if note]
140
167
  return Serialization.serialize_dict(type_as_dict)
141
168
 
142
169
  @classmethod
@@ -144,8 +171,9 @@ class Agent:
144
171
  """
145
172
  Create a Person instance from a JSON-dict (already parsed).
146
173
  """
174
+ from .serialization import Serialization
147
175
  type_as_dict = Serialization.get_class_fields('Agent')
148
- return Serialization.deserialize(data, type_as_dict)
176
+ return Serialization.deserialize(type_as_dict,Agent)
149
177
 
150
178
  def __str__(self):
151
179
  """
@@ -2,9 +2,30 @@
2
2
  from datetime import datetime
3
3
  from typing import Optional, Dict, Any
4
4
 
5
- from .Agent import Agent
6
- from .Resource import Resource, get_resource_as_dict
7
- from .Serialization import Serialization
5
+ """
6
+ ======================================================================
7
+ Project: Gedcom-X
8
+ File: Attribution.py
9
+ Author: David J. Cartwright
10
+ Purpose:
11
+
12
+ Created: 2025-08-25
13
+ Updated:
14
+ - 2025-08-31: fixed _as_dict_ to deal with Resources and ignore empty fields
15
+
16
+ ======================================================================
17
+ """
18
+
19
+ """
20
+ ======================================================================
21
+ GEDCOM Module Types
22
+ ======================================================================
23
+ """
24
+
25
+ from .agent import Agent
26
+ from .resource import Resource
27
+ #=====================================================================
28
+
8
29
 
9
30
  class Attribution:
10
31
  """Attribution Information for a Genealogy, Conclusion, Subject and child classes
@@ -39,12 +60,18 @@ class Attribution:
39
60
  """
40
61
  Serialize Attribution to a JSON-ready dict, skipping None values.
41
62
  """
63
+ from Serialization import Serialization
42
64
  type_as_dict: Dict[str, Any] = {}
43
- type_as_dict['contributor'] = get_resource_as_dict(self.contributor)
44
- type_as_dict['modified'] = self.modified if self.modified else None
45
- type_as_dict['changeMessage'] = self.changeMessage if self.changeMessage else None
46
- type_as_dict['creator'] = get_resource_as_dict(self.creator)
47
- type_as_dict['created'] = self.created if self.created else None
65
+ if self.contributor:
66
+ type_as_dict['contributor'] = Resource(target=self.contributor)._as_dict_
67
+ if self.modified:
68
+ type_as_dict['modified'] = self.modified if self.modified else None
69
+ if self.changeMessage:
70
+ type_as_dict['changeMessage'] = self.changeMessage if self.changeMessage else None
71
+ if self.creator:
72
+ type_as_dict['creator'] = Resource(target=self.creator)._as_dict_
73
+ if self.created:
74
+ type_as_dict['created'] = self.created if self.created else None
48
75
 
49
76
  return Serialization.serialize_dict(type_as_dict)
50
77
 
@@ -59,6 +86,6 @@ class Attribution:
59
86
  """
60
87
  Create a Person instance from a JSON-dict (already parsed).
61
88
  """
62
- from .Serialization import Serialization
89
+ from .serialization import Serialization
63
90
 
64
91
  return Serialization.deserialize(data, Attribution)
@@ -3,17 +3,34 @@ import uuid
3
3
  import warnings
4
4
 
5
5
  from typing import List, Optional
6
-
7
- from .Attribution import Attribution
8
- #from .Document import Document
9
- from .Note import Note
10
- from .Qualifier import Qualifier
11
- from .Serialization import Serialization
12
- from .SourceReference import SourceReference
13
- from .Resource import Resource, URI
6
+ """
7
+ ======================================================================
8
+ Project: Gedcom-X
9
+ File: conclusion.py
10
+ Author: David J. Cartwright
11
+ Purpose:
12
+
13
+ Created: 2025-08-25
14
+ Updated:
15
+ -
16
+
17
+ ======================================================================
18
+ """
19
+
20
+ """
21
+ ======================================================================
22
+ GEDCOM Module Type Imports
23
+ ======================================================================
24
+ """
25
+ from .attribution import Attribution
14
26
  from .Extensions.rs10.rsLink import _rsLinkList, rsLink
27
+ from .note import Note
28
+ from .qualifier import Qualifier
29
+ from .resource import Resource, URI
30
+ from .source_reference import SourceReference
31
+
32
+
15
33
 
16
- from collections.abc import Sized
17
34
 
18
35
  class ConfidenceLevel(Qualifier):
19
36
  High = "http://gedcomx.org/High"
@@ -96,7 +113,7 @@ class Conclusion:
96
113
  Args:
97
114
  id (str, optional): A unique identifier for the conclusion. If not provided,
98
115
  a UUID-based identifier will be automatically generated.
99
- lang (str, optional): The language code of the conclusion. Defaults to 'en'.
116
+ lang (str, optional): The language code of the conclusion.
100
117
  sources (list[SourceReference], optional): A list of source references that
101
118
  support the conclusion.
102
119
  analysis (Document | Resource, optional): A reference to an analysis document
@@ -127,7 +144,7 @@ class Conclusion:
127
144
 
128
145
  def __init__(self,
129
146
  id: Optional[str] = None,
130
- lang: Optional[str] = 'en',
147
+ lang: Optional[str] = None,
131
148
  sources: Optional[List[SourceReference]] = None,
132
149
  analysis: Optional[object | Resource] = None,
133
150
  notes: Optional[List[Note]] = None,
@@ -188,16 +205,27 @@ class Conclusion:
188
205
 
189
206
  @property
190
207
  def _as_dict_(self):
191
- type_as_dict = {
192
- 'id':self.id,
193
- 'lang':self.lang,
194
- 'sources': [source._as_dict_ for source in self.sources] if self.sources else None,
195
- 'analysis': self.analysis if self.analysis else None,
196
- 'notes': [note for note in self.notes] if self.notes else None,
197
- 'confidence':self.confidence,
198
- 'attribution':self.attribution,
199
- 'links':self.links._as_dict_ if self.links else None
200
- }
208
+ from .serialization import Serialization
209
+ type_as_dict = {}
210
+
211
+ if self.id:
212
+ type_as_dict['id'] = self.id
213
+ if self.lang:
214
+ type_as_dict['lang'] = self.lang
215
+ if self.sources:
216
+ type_as_dict['sources'] = [s._as_dict_ for s in self.sources if s]
217
+ if self.analysis:
218
+ type_as_dict['analysis'] = getattr(self.analysis, '_as_dict_', self.analysis)
219
+ if self.notes:
220
+ type_as_dict['notes'] = [
221
+ (n._as_dict_ if hasattr(n, '_as_dict_') else n) for n in self.notes if n
222
+ ]
223
+ if self.confidence is not None:
224
+ type_as_dict['confidence'] = self.confidence
225
+ if self.attribution:
226
+ type_as_dict['attribution'] = getattr(self.attribution, '_as_dict_', self.attribution)
227
+ if self.links:
228
+ type_as_dict['links'] = self.links._as_dict_
201
229
 
202
230
  return Serialization.serialize_dict(type_as_dict)
203
231