fastgedcom.base
Classes and types for the data structure used to represent a gedcom.
Module Contents
Classes
Abstract base class for gedcom lines. |
|
Dummy line for syntactic sugar. |
|
Represent a line of a gedcom document. |
|
Store all the information of the gedcom document. |
Attributes
The cross-reference identifier of type '@SUB1@' or '@U1@' for a submitter |
|
Deprecated. The cross-reference identifier of type '@SUB2@' for a submission. |
|
The cross-reference identifier of type '@I1@' for an individual. |
|
The cross-reference identifier of type '@F1@' for a family. |
|
The cross-reference identifier of type '@N1@' for a shared note. |
|
The cross-reference identifier of type '@S1@' for a source document. |
|
The cross-reference identifier of type '@R1@' for a repository (an archive). |
|
The cross-reference identifier of type '@O1@' for an object (e.g. an image). |
|
The cross-reference identifier indicates a record to which payloads may point. |
|
A pointer used for unknown value where payload can't be let empty. |
|
Generic pointer that is used in the payload to reference an existing record |
|
A level 0 line referenced by an XRef in the document. |
|
|
- fastgedcom.base.SubmRef: TypeAlias[source]
The cross-reference identifier of type ‘@SUB1@’ or ‘@U1@’ for a submitter of the document.
- fastgedcom.base.SubnRef: TypeAlias[source]
Deprecated. The cross-reference identifier of type ‘@SUB2@’ for a submission.
- fastgedcom.base.IndiRef: TypeAlias[source]
The cross-reference identifier of type ‘@I1@’ for an individual.
- fastgedcom.base.FamRef: TypeAlias[source]
The cross-reference identifier of type ‘@F1@’ for a family.
- fastgedcom.base.SNoteRef: TypeAlias[source]
The cross-reference identifier of type ‘@N1@’ for a shared note.
- fastgedcom.base.SourRef: TypeAlias[source]
The cross-reference identifier of type ‘@S1@’ for a source document.
- fastgedcom.base.RepoRef: TypeAlias[source]
The cross-reference identifier of type ‘@R1@’ for a repository (an archive).
- fastgedcom.base.ObjeRef: TypeAlias[source]
The cross-reference identifier of type ‘@O1@’ for an object (e.g. an image).
- fastgedcom.base.XRef: TypeAlias[source]
The cross-reference identifier indicates a record to which payloads may point.
- fastgedcom.base.VoidRef: TypeAlias[source]
A pointer used for unknown value where payload can’t be let empty.
e.g.: In a family record, the line ‘2 CHIL @VOID@’ indicates that the parents had a child whom we know nothing. The line is used to keep the children birth order.
- fastgedcom.base.Pointer: TypeAlias[source]
Generic pointer that is used in the payload to reference an existing record or a non-existing one.
- class fastgedcom.base.Line[source]
Bases:
abc.ABC
Abstract base class for gedcom lines.
Implementations are
TrueLine
andFakeLine
, see these classes for more information.- abstract property payload_with_cont: str[source]
The content of this gedcom field, namely the payload combined with all CONT and CONC sub-lines.
- abstract get_sub_lines(tag: str) list[TrueLine] [source]
Return all sub-lines having the given
tag
. An empty list if no line matches.
- __rshift__(tag: str) list[TrueLine] [source]
Alias for
get_sub_lines()
to shorten the syntax by using the >> operator.
- abstract get_sub_line(tag: str) TrueLine | FakeLine [source]
Return the first sub-line having the given
tag
. AFakeLine
if no line matches.
- __gt__(tag: str) TrueLine | FakeLine [source]
Alias for
get_sub_line()
to shorten the syntax by using the > operator.
- abstract get_sub_line_payload(tag: str) str [source]
Return the payload of the first sub-line having the given
tag
. An empty string if no line matches.
- __ge__(tag: str) str [source]
Alias for
get_sub_line_payload()
to shorten the syntax by using the >= operator.
- class fastgedcom.base.FakeLine[source]
Bases:
Line
Dummy line for syntactic sugar.
It allows the chaining of method calls. See these examples for the usage of chaining.
The class behave like a
TrueLine
(It has the same methods), but the payload is empty.To differentiate a
FakeLine
from aTrueLine
a simple boolean test is enough.- get_sub_lines(tag: str) list[TrueLine] [source]
Return all sub-lines having the given
tag
. An empty list if no line matches.
- __rshift__(tag: str) list[TrueLine] [source]
Alias for
get_sub_lines()
to shorten the syntax by using the >> operator.
- get_sub_line(tag: str) TrueLine | FakeLine [source]
Return the first sub-line having the given
tag
. AFakeLine
if no line matches.
- __gt__(tag: str) TrueLine | FakeLine [source]
Alias for
get_sub_line()
to shorten the syntax by using the > operator.
- get_sub_line_payload(tag: str) str [source]
Return the payload of the first sub-line having the given
tag
. An empty string if no line matches.
- __ge__(tag: str) str [source]
Alias for
get_sub_line_payload()
to shorten the syntax by using the >= operator.
- class fastgedcom.base.TrueLine[source]
Bases:
Line
Represent a line of a gedcom document.
Contain the
sub-lines
of the gedcom structure.This class uses the simplified
Level Tag Payload
format, instead of the normalizedLevel [Xref] Tag [LineVal]
format. In the simplified format, thetag
is either the normalized Tag or the optional Xref. Hence, thepayload
is the LineVal - when the Xref is not present - or the normalized Tag plus the LineVal (generally an empty string) - when the Xref is present. The Payload can be an empty string. As for thelevel
, it matches the definition of the gedcom standard.- property payload_with_cont: str[source]
The content of this gedcom field, namely the payload combined with all CONT and CONC sub-lines.
- tag: str | XRef[source]
The cross-reference identified if it is a
Record
, or the tag - as defined in the gedcom standard - defining the structure type.
- payload: str[source]
The payload of the structure, also called content or value. Warning: Multi-line payloads are split into several lines according to the gedcom standard. Use the
payload_with_cont
property to get the complete multi-line payloads.
- sub_lines: list[TrueLine][source]
List of the sub-lines, i.e. the next-level lines that are part of this structure.
- get_sub_lines(tag: str) list[TrueLine] [source]
Return all sub-lines having the given
tag
. An empty list if no line matches.
- __rshift__(tag: str) list[TrueLine] [source]
Alias for
get_sub_lines()
to shorten the syntax by using the >> operator.
- get_sub_line(tag: str) TrueLine | FakeLine [source]
Return the first sub-line having the given
tag
. AFakeLine
if no line matches.
- __gt__(tag: str) TrueLine | FakeLine [source]
Alias for
get_sub_line()
to shorten the syntax by using the > operator.
- get_sub_line_payload(tag: str) str [source]
Return the payload of the first sub-line having the given
tag
. An empty string if no line matches.
- __ge__(tag: str) str [source]
Alias for
get_sub_line_payload()
to shorten the syntax by using the >= operator.
- class fastgedcom.base.Document[source]
Store all the information of the gedcom document.
All records (level 0 lines) are directly accessible via the
records
dictionnary and the other lines level are accessible viaTrueLine.sub_lines
.- records: dict[XRef, Record][source]
Dictionnary of records, accessible via
get_records()
or__getitem__()
. Access it directly to raise KeyError instead of getting aFakeLine
. Usefull when you a pretty sure of the Record existing in the document.
- __rshift__[source]
Alias for
get_records()
to shorten the syntax by using the >> operator.
- __getitem__[source]
Alias for
get_record()
to shorten the syntax by using the [] operator.
- __iter__() Iterator[Record] [source]
Iterate on the lines of level 0 (the records, the header, and the TRLR line).
- __contains__(identifier: XRef) bool [source]
Return True if the identifier refers to an existing record.
- get_records(record_type: str) Iterator[Record] [source]
Return an iterator over records of that
record_type
(i.e. thepayload
of level 0 lines).