File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ def loads(string: str) -> List[GedcomStructure]:
2323 structure = GedcomStructure (
2424 tag = ext .get (data ["tag" ]) or data ["tag" ],
2525 pointer = data ["pointer" ],
26+ xref = data ["xref" ],
2627 text = data ["linestr" ],
2728 )
2829 # handle extension tags
Original file line number Diff line number Diff line change 11"""Classes and data types."""
22
3+ import re
34from typing import Optional , List
45
6+ from . import grammar
7+
58
69class GedcomStructure :
710 """Gedcom structure class."""
@@ -11,13 +14,15 @@ def __init__(
1114 tag : str ,
1215 pointer : str ,
1316 text : str ,
17+ xref : str ,
1418 children : Optional [List ["GedcomStructure" ]] = None ,
1519 ):
1620 """Initialize self."""
1721 self .tag = tag
1822 self .pointer = pointer
1923 self .text = text
2024 self .children = children or []
25+ self .xref = xref
2126 self .parent : Optional ["GedcomStructure" ] = None
2227
2328 def __repr__ (self ):
@@ -30,3 +35,10 @@ def __repr__(self):
3035 f"tag={ self .tag } , pointer={ self .pointer } , text={ self .text } , "
3136 f"children={ repr_children } "
3237 )
38+
39+ def as_list_enum (self ) -> List [str ]:
40+ """Return as list enum data type."""
41+ match = re .fullmatch (grammar .list_enum , self .text )
42+ if not match :
43+ raise ValueError (f"Cannot interpret { self .text } as type list enum" )
44+ return [el .strip () for el in self .text .split ("," )]
You can’t perform that action at this time.
0 commit comments