gedcom-x 0.5.7__py3-none-any.whl → 0.5.9__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.
- {gedcom_x-0.5.7.dist-info → gedcom_x-0.5.9.dist-info}/METADATA +1 -1
- gedcom_x-0.5.9.dist-info/RECORD +56 -0
- gedcomx/Extensions/rs10/rsLink.py +110 -60
- gedcomx/TopLevelTypeCollection.py +1 -1
- gedcomx/__init__.py +43 -42
- gedcomx/address.py +217 -0
- gedcomx/{Agent.py → agent.py} +107 -34
- gedcomx/attribution.py +115 -0
- gedcomx/{Conclusion.py → conclusion.py} +120 -51
- gedcomx/{Converter.py → converter.py} +261 -116
- gedcomx/coverage.py +64 -0
- gedcomx/{Date.py → date.py} +43 -9
- gedcomx/{Document.py → document.py} +60 -12
- gedcomx/{Event.py → event.py} +88 -31
- gedcomx/evidence_reference.py +20 -0
- gedcomx/{Fact.py → fact.py} +81 -74
- gedcomx/{Gedcom.py → gedcom.py} +10 -0
- gedcomx/{Gedcom5x.py → gedcom5x.py} +31 -21
- gedcomx/gedcom7/Exceptions.py +9 -0
- gedcomx/gedcom7/GedcomStructure.py +94 -0
- gedcomx/gedcom7/Specification.py +347 -0
- gedcomx/gedcom7/__init__.py +26 -0
- gedcomx/gedcom7/g7interop.py +205 -0
- gedcomx/gedcom7/gedcom7.py +160 -0
- gedcomx/gedcom7/logger.py +19 -0
- gedcomx/{GedcomX.py → gedcomx.py} +109 -106
- gedcomx/gender.py +91 -0
- gedcomx/group.py +72 -0
- gedcomx/{Identifier.py → identifier.py} +48 -21
- gedcomx/{LoggingHub.py → logging_hub.py} +19 -0
- gedcomx/{Mutations.py → mutations.py} +59 -30
- gedcomx/{Name.py → name.py} +88 -47
- gedcomx/note.py +105 -0
- gedcomx/online_account.py +19 -0
- gedcomx/{Person.py → person.py} +61 -41
- gedcomx/{PlaceDescription.py → place_description.py} +71 -23
- gedcomx/{PlaceReference.py → place_reference.py} +32 -10
- gedcomx/{Qualifier.py → qualifier.py} +20 -4
- gedcomx/relationship.py +156 -0
- gedcomx/resource.py +112 -0
- gedcomx/serialization.py +794 -0
- gedcomx/source_citation.py +37 -0
- gedcomx/source_description.py +401 -0
- gedcomx/{SourceReference.py → source_reference.py} +56 -21
- gedcomx/subject.py +122 -0
- gedcomx/textvalue.py +89 -0
- gedcomx/{Translation.py → translation.py} +4 -4
- gedcomx/uri.py +273 -0
- gedcom_x-0.5.7.dist-info/RECORD +0 -49
- gedcomx/Address.py +0 -131
- gedcomx/Attribution.py +0 -91
- gedcomx/Coverage.py +0 -37
- gedcomx/EvidenceReference.py +0 -11
- gedcomx/Gender.py +0 -65
- gedcomx/Group.py +0 -37
- gedcomx/Note.py +0 -73
- gedcomx/OnlineAccount.py +0 -10
- gedcomx/Relationship.py +0 -97
- gedcomx/Resource.py +0 -85
- gedcomx/Serialization.py +0 -816
- gedcomx/SourceCitation.py +0 -25
- gedcomx/SourceDescription.py +0 -314
- gedcomx/Subject.py +0 -59
- gedcomx/TextValue.py +0 -35
- gedcomx/URI.py +0 -105
- {gedcom_x-0.5.7.dist-info → gedcom_x-0.5.9.dist-info}/WHEEL +0 -0
- {gedcom_x-0.5.7.dist-info → gedcom_x-0.5.9.dist-info}/top_level.txt +0 -0
- /gedcomx/{Exceptions.py → exceptions.py} +0 -0
- /gedcomx/{ExtensibleEnum.py → extensible_enum.py} +0 -0
gedcomx/Coverage.py
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
from typing import Optional
|
2
|
-
|
3
|
-
from .Date import Date
|
4
|
-
from .PlaceReference import PlaceReference
|
5
|
-
|
6
|
-
|
7
|
-
class Coverage:
|
8
|
-
identifier = 'http://gedcomx.org/v1/Coverage'
|
9
|
-
version = 'http://gedcomx.org/conceptual-model/v1'
|
10
|
-
|
11
|
-
def __init__(self,spatial: Optional[PlaceReference], temporal: Optional[Date]) -> None:
|
12
|
-
self.spatial = spatial
|
13
|
-
self.temporal = temporal
|
14
|
-
|
15
|
-
# ...existing code...
|
16
|
-
|
17
|
-
@property
|
18
|
-
def _as_dict_(self):
|
19
|
-
from .Serialization import Serialization
|
20
|
-
type_as_dict = {}
|
21
|
-
if self.spatial:
|
22
|
-
type_as_dict['spatial'] = getattr(self.spatial, '_as_dict_', self.spatial)
|
23
|
-
if self.temporal: # (fixed: no space after the dot)
|
24
|
-
type_as_dict['temporal'] = getattr(self.temporal, '_as_dict_', self.temporal)
|
25
|
-
return Serialization.serialize_dict(type_as_dict)
|
26
|
-
|
27
|
-
@classmethod
|
28
|
-
def _from_json_(cls, data: dict):
|
29
|
-
"""
|
30
|
-
Create a Coverage instance from a JSON-dict (already parsed).
|
31
|
-
"""
|
32
|
-
from .PlaceReference import PlaceReference
|
33
|
-
from .Date import Date
|
34
|
-
|
35
|
-
spatial = PlaceReference._from_json_(data.get('spatial')) if data.get('spatial') else None
|
36
|
-
temporal = Date._from_json_(data.get('temporal')) if data.get('temporal') else None
|
37
|
-
return cls(spatial=spatial, temporal=temporal)
|
gedcomx/EvidenceReference.py
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
from typing import Optional
|
2
|
-
|
3
|
-
from .Attribution import Attribution
|
4
|
-
from .Resource import Resource
|
5
|
-
|
6
|
-
class EvidenceReference:
|
7
|
-
identifier = 'http://gedcomx.org/v1/EvidenceReference'
|
8
|
-
version = 'http://gedcomx.org/conceptual-model/v1'
|
9
|
-
|
10
|
-
def __init__(self, resource: Resource, attribution: Optional[Attribution]) -> None:
|
11
|
-
pass
|
gedcomx/Gender.py
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
from enum import Enum
|
2
|
-
from typing import List, Optional
|
3
|
-
|
4
|
-
from gedcomx.Attribution import Attribution
|
5
|
-
from gedcomx.Conclusion import ConfidenceLevel
|
6
|
-
from gedcomx.Note import Note
|
7
|
-
from gedcomx.SourceReference import SourceReference
|
8
|
-
from gedcomx.Resource import Resource
|
9
|
-
|
10
|
-
from .Conclusion import Conclusion
|
11
|
-
from .Qualifier import Qualifier
|
12
|
-
|
13
|
-
|
14
|
-
from collections.abc import Sized
|
15
|
-
|
16
|
-
class GenderType(Enum):
|
17
|
-
Male = "http://gedcomx.org/Male"
|
18
|
-
Female = "http://gedcomx.org/Female"
|
19
|
-
Unknown = "http://gedcomx.org/Unknown"
|
20
|
-
Intersex = "http://gedcomx.org/Intersex"
|
21
|
-
|
22
|
-
@property
|
23
|
-
def description(self):
|
24
|
-
descriptions = {
|
25
|
-
GenderType.Male: "Male gender.",
|
26
|
-
GenderType.Female: "Female gender.",
|
27
|
-
GenderType.Unknown: "Unknown gender.",
|
28
|
-
GenderType.Intersex: "Intersex (assignment at birth)."
|
29
|
-
}
|
30
|
-
return descriptions.get(self, "No description available.")
|
31
|
-
|
32
|
-
class Gender(Conclusion):
|
33
|
-
identifier = 'http://gedcomx.org/v1/Gender'
|
34
|
-
version = 'http://gedcomx.org/conceptual-model/v1'
|
35
|
-
|
36
|
-
def __init__(self,
|
37
|
-
id: Optional[str] = None,
|
38
|
-
lang: Optional[str] = None,
|
39
|
-
sources: Optional[List[SourceReference]] = None,
|
40
|
-
analysis: Optional[Resource] = None,
|
41
|
-
notes: Optional[List[Note]] = None,
|
42
|
-
confidence: Optional[ConfidenceLevel] = None,
|
43
|
-
attribution: Optional[Attribution] = None,
|
44
|
-
type: Optional[GenderType] = None
|
45
|
-
) -> None:
|
46
|
-
super().__init__(id=id, lang=lang, sources=sources, analysis=analysis, notes=notes, confidence=confidence, attribution=attribution)
|
47
|
-
self.type = type
|
48
|
-
|
49
|
-
@property
|
50
|
-
def _as_dict_(self):
|
51
|
-
from .Serialization import Serialization
|
52
|
-
type_as_dict = super()._as_dict_
|
53
|
-
if self.type:
|
54
|
-
type_as_dict['type'] = self.type.value if self.type else None
|
55
|
-
|
56
|
-
|
57
|
-
return Serialization.serialize_dict(type_as_dict)
|
58
|
-
|
59
|
-
@classmethod
|
60
|
-
def _from_json_(cls,data):
|
61
|
-
from .Serialization import Serialization
|
62
|
-
|
63
|
-
return Serialization.deserialize(data, Gender)
|
64
|
-
|
65
|
-
|
gedcomx/Group.py
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
from enum import Enum
|
2
|
-
from typing import List, Optional
|
3
|
-
|
4
|
-
from .Attribution import Attribution
|
5
|
-
from .Conclusion import ConfidenceLevel
|
6
|
-
from .Date import Date
|
7
|
-
from .EvidenceReference import EvidenceReference
|
8
|
-
from .Identifier import Identifier
|
9
|
-
from .Note import Note
|
10
|
-
from .PlaceReference import PlaceReference
|
11
|
-
from .SourceReference import SourceReference
|
12
|
-
from .Resource import Resource
|
13
|
-
|
14
|
-
from .TextValue import TextValue
|
15
|
-
from .Subject import Subject
|
16
|
-
|
17
|
-
class GroupRoleType(Enum):
|
18
|
-
def __init__(self) -> None:
|
19
|
-
super().__init__()
|
20
|
-
|
21
|
-
class GroupRole:
|
22
|
-
identifier = 'http://gedcomx.org/v1/GroupRole'
|
23
|
-
version = 'http://gedcomx.org/conceptual-model/v1'
|
24
|
-
|
25
|
-
def __init__(self, person: Resource,type: Optional[Enum], date: Optional[Date],details: Optional[str]) -> None:
|
26
|
-
pass
|
27
|
-
|
28
|
-
class Group(Subject):
|
29
|
-
identifier = 'http://gedcomx.org/v1/Group'
|
30
|
-
version = 'http://gedcomx.org/conceptual-model/v1'
|
31
|
-
|
32
|
-
def __init__(self, id: str | None, lang: str | None, sources: SourceReference | None, analysis: Resource | None, notes: Note | None, confidence: ConfidenceLevel | None, attribution: Attribution | None, extracted: bool | None, evidence: List[EvidenceReference] | None, media: List[SourceReference] | None, identifiers: List[Identifier] | None,
|
33
|
-
names: TextValue,
|
34
|
-
date: Optional[Date],
|
35
|
-
place: Optional[PlaceReference],
|
36
|
-
roles: Optional[List[GroupRole]]) -> None:
|
37
|
-
super().__init__(id, lang, sources, analysis, notes, confidence, attribution, extracted, evidence, media, identifiers)
|
gedcomx/Note.py
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
from typing import Optional
|
2
|
-
|
3
|
-
from .Attribution import Attribution
|
4
|
-
|
5
|
-
class Note:
|
6
|
-
identifier = 'http://gedcomx.org/v1/Note'
|
7
|
-
version = 'http://gedcomx.org/conceptual-model/v1'
|
8
|
-
|
9
|
-
def __init__(self,lang: Optional[str] = 'en', subject: Optional[str] = None, text: Optional[str] = None, attribution: Optional[Attribution] = None) -> None:
|
10
|
-
self.lang = lang
|
11
|
-
self.subject = subject
|
12
|
-
self.text = text
|
13
|
-
self.attribution = attribution
|
14
|
-
|
15
|
-
def append(self, text_to_add: str):
|
16
|
-
if text_to_add and isinstance(text_to_add, str):
|
17
|
-
if self.text:
|
18
|
-
self.text = self.text + text_to_add
|
19
|
-
else:
|
20
|
-
self.text = text_to_add
|
21
|
-
else:
|
22
|
-
return #TODO
|
23
|
-
raise ValueError("The text to add must be a non-empty string.")
|
24
|
-
|
25
|
-
@property
|
26
|
-
def _as_dict_(self):
|
27
|
-
from .Serialization import Serialization
|
28
|
-
type_as_dict = {}
|
29
|
-
if self.lang:
|
30
|
-
type_as_dict["lang"] = self.lang
|
31
|
-
if self.subject:
|
32
|
-
type_as_dict["subject"] = self.subject
|
33
|
-
if self.text:
|
34
|
-
type_as_dict["text"] = self.text
|
35
|
-
if self.attribution:
|
36
|
-
# If attribution exposes `_as_dict_` as a property, use it; otherwise include as-is
|
37
|
-
type_as_dict["attribution"] = getattr(self.attribution, "_as_dict_", self.attribution)
|
38
|
-
return Serialization.serialize_dict(type_as_dict)
|
39
|
-
|
40
|
-
def __eq__(self, other):
|
41
|
-
if not isinstance(other, Note):
|
42
|
-
return NotImplemented
|
43
|
-
|
44
|
-
def safe_str(val):
|
45
|
-
return val.strip() if isinstance(val, str) else ''
|
46
|
-
|
47
|
-
return (
|
48
|
-
#safe_str(self.lang) == safe_str(other.lang) and
|
49
|
-
#safe_str(self.subject) == safe_str(other.subject) and
|
50
|
-
safe_str(self.text) == safe_str(other.text) #and
|
51
|
-
# self.attribution == other.attribution # Assumes Attribution defines __eq__
|
52
|
-
)
|
53
|
-
|
54
|
-
@classmethod
|
55
|
-
def _from_json_(cls, data: dict):
|
56
|
-
"""
|
57
|
-
Create a Note instance from a JSON-dict (already parsed).
|
58
|
-
"""
|
59
|
-
# Basic scalar fields
|
60
|
-
lang = data.get('lang', 'en')
|
61
|
-
text = data.get('text')
|
62
|
-
subject = data.get('subject')
|
63
|
-
# Add other fields as needed
|
64
|
-
|
65
|
-
# Build the instance
|
66
|
-
inst = cls(
|
67
|
-
lang = lang,
|
68
|
-
text = text,
|
69
|
-
subject = subject,
|
70
|
-
# Add other fields as needed
|
71
|
-
)
|
72
|
-
|
73
|
-
return inst
|
gedcomx/OnlineAccount.py
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
from typing import Optional
|
2
|
-
|
3
|
-
from .Resource import Resource
|
4
|
-
|
5
|
-
class OnlineAccount:
|
6
|
-
identifier = 'http://gedcomx.org/v1/OnlineAccount'
|
7
|
-
version = 'http://gedcomx.org/conceptual-model/v1'
|
8
|
-
|
9
|
-
def __init__(self, serviceHomepage: Resource, accountName: str) -> None:
|
10
|
-
pass
|
gedcomx/Relationship.py
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
from enum import Enum
|
2
|
-
from typing import List, Optional
|
3
|
-
|
4
|
-
from .Attribution import Attribution
|
5
|
-
from .Conclusion import ConfidenceLevel
|
6
|
-
from .EvidenceReference import EvidenceReference
|
7
|
-
from .Fact import Fact
|
8
|
-
from .Identifier import Identifier
|
9
|
-
from .Note import Note
|
10
|
-
from .Person import Person
|
11
|
-
|
12
|
-
from .SourceReference import SourceReference
|
13
|
-
from .Resource import Resource
|
14
|
-
|
15
|
-
from .Subject import Subject
|
16
|
-
|
17
|
-
class RelationshipType(Enum):
|
18
|
-
Couple = "http://gedcomx.org/Couple"
|
19
|
-
ParentChild = "http://gedcomx.org/ParentChild"
|
20
|
-
|
21
|
-
@property
|
22
|
-
def description(self):
|
23
|
-
descriptions = {
|
24
|
-
RelationshipType.Couple: "A relationship of a pair of persons.",
|
25
|
-
RelationshipType.ParentChild: "A relationship from a parent to a child."
|
26
|
-
}
|
27
|
-
return descriptions.get(self, "No description available.")
|
28
|
-
|
29
|
-
class Relationship(Subject):
|
30
|
-
"""Represents a relationship between two Person(s)
|
31
|
-
|
32
|
-
Args:
|
33
|
-
type (RelationshipType): Type of relationship
|
34
|
-
person1 (Person) = First Person in Relationship
|
35
|
-
person2 (Person): Second Person in Relationship
|
36
|
-
|
37
|
-
Raises:
|
38
|
-
|
39
|
-
"""
|
40
|
-
identifier = 'http://gedcomx.org/v1/Relationship'
|
41
|
-
version = 'http://gedcomx.org/conceptual-model/v1'
|
42
|
-
|
43
|
-
def __init__(self,
|
44
|
-
person1: Optional[Person | Resource] = None,
|
45
|
-
person2: Optional[Person | Resource] = None,
|
46
|
-
facts: Optional[List[Fact]] = None,
|
47
|
-
id: Optional[str] = None,
|
48
|
-
lang: Optional[str] = None,
|
49
|
-
sources: Optional[List[SourceReference]] = None,
|
50
|
-
analysis: Optional[Resource] = None,
|
51
|
-
notes: Optional[List[Note]] = None,
|
52
|
-
confidence: Optional[ConfidenceLevel] = None,
|
53
|
-
attribution: Optional[Attribution] = None,
|
54
|
-
extracted: Optional[bool] = None,
|
55
|
-
evidence: Optional[List[EvidenceReference]] = None,
|
56
|
-
media: Optional[List[SourceReference]] = None,
|
57
|
-
identifiers: Optional[List[Identifier]] = None,
|
58
|
-
type: Optional[RelationshipType] = None,
|
59
|
-
) -> None:
|
60
|
-
|
61
|
-
# Call superclass initializer if required
|
62
|
-
super().__init__(id, lang, sources, analysis, notes, confidence, attribution, extracted, evidence, media, identifiers)
|
63
|
-
|
64
|
-
self.type = type
|
65
|
-
self.person1 = person1
|
66
|
-
self.person2 = person2
|
67
|
-
self.facts = facts if facts else []
|
68
|
-
|
69
|
-
def add_fact(self,fact: Fact):
|
70
|
-
if fact is not None and isinstance(fact,Fact):
|
71
|
-
for existing_fact in self.facts:
|
72
|
-
if fact == existing_fact:
|
73
|
-
return
|
74
|
-
self.facts.append(fact)
|
75
|
-
else:
|
76
|
-
raise TypeError(f"Expected type 'Fact' recieved type {type(fact)}")
|
77
|
-
|
78
|
-
@property
|
79
|
-
def _as_dict_(self):
|
80
|
-
from .Serialization import Serialization
|
81
|
-
type_as_dict = super()._as_dict_
|
82
|
-
type_as_dict.update({
|
83
|
-
"type": self.type.value if isinstance(self.type, RelationshipType) else self.type,
|
84
|
-
"person1": Resource(target=self.person1)._as_dict_ if self.person1 else None,
|
85
|
-
"person2": Resource(target=self.person1)._as_dict_ if self.person2 else None,
|
86
|
-
"facts": [fact for fact in self.facts] if self.facts else None
|
87
|
-
})
|
88
|
-
return Serialization.serialize_dict(type_as_dict)
|
89
|
-
|
90
|
-
@classmethod
|
91
|
-
def _from_json_(cls, data: dict):
|
92
|
-
"""
|
93
|
-
Create a Person instance from a JSON-dict (already parsed).
|
94
|
-
"""
|
95
|
-
from .Serialization import Serialization
|
96
|
-
return Serialization.deserialize(data, Relationship)
|
97
|
-
|
gedcomx/Resource.py
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
from typing import Optional
|
2
|
-
|
3
|
-
"""
|
4
|
-
======================================================================
|
5
|
-
Project: Gedcom-X
|
6
|
-
File: Resource.py
|
7
|
-
Author: David J. Cartwright
|
8
|
-
Purpose: References TopLevel Types for Serialization
|
9
|
-
|
10
|
-
Created: 2025-08-25
|
11
|
-
Updated:
|
12
|
-
- 2025-08-31: working on target=Resource and deserialization issues
|
13
|
-
|
14
|
-
======================================================================
|
15
|
-
"""
|
16
|
-
|
17
|
-
"""
|
18
|
-
======================================================================
|
19
|
-
GEDCOM Module Types
|
20
|
-
======================================================================
|
21
|
-
"""
|
22
|
-
|
23
|
-
from .URI import URI
|
24
|
-
|
25
|
-
class Resource:
|
26
|
-
"""
|
27
|
-
Class used to track and resolve URIs and references between datastores.
|
28
|
-
|
29
|
-
Parameters
|
30
|
-
----------
|
31
|
-
|
32
|
-
Raises
|
33
|
-
------
|
34
|
-
ValueError
|
35
|
-
If `id` is not a valid UUID.
|
36
|
-
"""
|
37
|
-
# TODO, Deal with a resouce being passed, as it may be unresolved.
|
38
|
-
def __init__(self,uri: Optional[URI|str] = None, id:Optional[str] = None,top_lvl_object: Optional[object] = None,target= None) -> None:
|
39
|
-
|
40
|
-
self.resource = URI.from_url(uri.value) if isinstance(uri,URI) else URI.from_url(uri) if isinstance(uri,str) else None
|
41
|
-
self.Id = id
|
42
|
-
|
43
|
-
self.type = None
|
44
|
-
self.resolved = False
|
45
|
-
self.target: object = target
|
46
|
-
self.remote: bool | None = None # is the resource pointed to persitent on a remote datastore?
|
47
|
-
|
48
|
-
if target:
|
49
|
-
if isinstance(target,Resource):
|
50
|
-
self.resource = target.resource
|
51
|
-
self.Id = target.Id
|
52
|
-
self.target = target.target
|
53
|
-
else:
|
54
|
-
self.resource = target.uri
|
55
|
-
self.Id = target.id
|
56
|
-
self.type = type(target)
|
57
|
-
|
58
|
-
@property
|
59
|
-
def uri(self):
|
60
|
-
return self.resource
|
61
|
-
|
62
|
-
@property
|
63
|
-
def _as_dict_(self):
|
64
|
-
from .Serialization import Serialization
|
65
|
-
typ_as_dict = {}
|
66
|
-
if self.resource:
|
67
|
-
typ_as_dict['resource'] = self.resource.value if self.resource else None
|
68
|
-
if self.Id:
|
69
|
-
typ_as_dict['resourceId'] = self.Id
|
70
|
-
return Serialization.serialize_dict(typ_as_dict)
|
71
|
-
|
72
|
-
@classmethod
|
73
|
-
def _from_json_(cls,data):
|
74
|
-
# TODO This is not used but taken care of in Serialization
|
75
|
-
r = Resource(uri=data.get('resource'),id=data.get('resourceId',None))
|
76
|
-
#return r
|
77
|
-
|
78
|
-
def __repr__(self) -> str:
|
79
|
-
return f"Resource(uri={self.resource}, id={self.Id}, target={self.target})"
|
80
|
-
|
81
|
-
def __str__(self) -> str:
|
82
|
-
return f"{self.resource}{f', id={self.Id}' if self.Id else ''}"
|
83
|
-
|
84
|
-
|
85
|
-
|