fastgedcom.base
Classes and types for the data structure used to represent a gedcom.
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. |
|
|
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. |
Module Contents
- fastgedcom.base.SubmRef: TypeAlias = str[source]
The cross-reference identifier of type ‘@SUB1@’ or ‘@U1@’ for a submitter of the document.
- fastgedcom.base.SubnRef: TypeAlias = str[source]
Deprecated. The cross-reference identifier of type ‘@SUB2@’ for a submission.
- fastgedcom.base.IndiRef: TypeAlias = str[source]
The cross-reference identifier of type ‘@I1@’ for an individual.
- fastgedcom.base.FamRef: TypeAlias = str[source]
The cross-reference identifier of type ‘@F1@’ for a family.
- fastgedcom.base.SNoteRef: TypeAlias = str[source]
The cross-reference identifier of type ‘@N1@’ for a shared note.
- fastgedcom.base.SourRef: TypeAlias = str[source]
The cross-reference identifier of type ‘@S1@’ for a source document.
- fastgedcom.base.RepoRef: TypeAlias = str[source]
The cross-reference identifier of type ‘@R1@’ for a repository (an archive).
- fastgedcom.base.ObjeRef: TypeAlias = str[source]
The cross-reference identifier of type ‘@O1@’ for an object (e.g. an image).
- fastgedcom.base.XRef: TypeAlias = SubmRef | SubnRef | IndiRef | FamRef | SNoteRef | SourRef | RepoRef | ObjeRef[source]
The cross-reference identifier indicates a record to which payloads may point.
- fastgedcom.base.VoidRef: TypeAlias = Literal['@VOID@'][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 = XRef | VoidRef[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.ABCAbstract base class for gedcom lines.
Implementations are
TrueLineandFakeLine, see these classes for more information.- property payload_with_cont: str[source]
- Abstractmethod:
Return the multi-line payload into a single string.
Multi-line payloads are split into several
Lineas written in the original gedcom file. The corresponding sub-lines are with the tags CONC and CONT. There are gathered into a single string by concatenation of the different payload of each line. A newline is added for the concatenation of sub-lines with the CONT tag.
- __iter__() Iterator[TrueLine][source]
Iterate on sub-lines, i.e. the next-level lines that are part of this structure.
- abstract get_sub_lines(tag: str) list[TrueLine][source]
Return all sub-lines having the given
tag. Return 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. Return aFakeLineif 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. Return 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:
LineDummy 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
FakeLinefrom aTrueLinea simple boolean test is enough.- payload_with_cont = ''[source]
Return the multi-line payload into a single string.
Multi-line payloads are split into several
Lineas written in the original gedcom file. The corresponding sub-lines are with the tags CONC and CONT. There are gathered into a single string by concatenation of the different payload of each line. A newline is added for the concatenation of sub-lines with the CONT tag.
- get_sub_lines(tag: str) list[TrueLine][source]
Return all sub-lines having the given
tag. Return 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. Return aFakeLineif 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. Return 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:
LineRepresent a line of a gedcom document.
Contain the
sub-linesof the gedcom structure to form a recursive representation of the gedcom file.This class uses the simplified format, instead of the normalized
Level [Xref] Tag [LineVal]format.The format of a gedcom line:
Level Tag Payload.In the simplified format, the
tagis either the normalized Tag or the optional Xref. Hence, thepayloadis 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.- tag: str | XRef[source]
The cross-reference identifier for level 0 line (also called record identifier), or the tag defining the information and the structure of the data.
- payload: str = ''[source]
The payload of the structure, also called content or value.
Warning: Multi-line payloads are split into several
Lineas written in the original gedcom file. The corresponding sub-lines are with the tags CONC and CONT. Use thepayload_with_contproperty 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. Return 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. Return aFakeLineif 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. Return 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.
- property payload_with_cont: str[source]
Return the multi-line payload into a single string.
Multi-line payloads are split into several
Lineas written in the original gedcom file. The corresponding sub-lines are with the tags CONC and CONT. There are gathered into a single string by concatenation of the different payload of each line. A newline is added for the concatenation of sub-lines with the CONT tag.
- fastgedcom.base.Record: TypeAlias = TrueLine[source]
A level 0 line referenced by an XRef in the document.
- class fastgedcom.base.Document[source]
Store all the information of the gedcom document.
All records (level 0 lines) are directly accessible via the
recordsdictionnary and the other lines 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.
- __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. The type is the payload of level 0 lines: INDI, FAM, etc..
- __rshift__[source]
Alias for
get_records()to shorten the syntax by using the >> operator.
- get_record(identifier: XRef | Literal['HEAD']) Record | FakeLine[source]
Return the record under that
identifier.
- __getitem__[source]
Alias for
get_record()to shorten the syntax by using the [] operator.
- all_lines() Iterator[list[TrueLine]][source]
Return an iterator over all lines of the document. An element of the iterator is the sequence of lines to access the last line of the list.
For example, given the following gedcom document:
0 @I1@ INDI 1 NAME John /Doe/ 2 SURN Doe 0 @I2@ INDI
>>> list(document.all_lines()) [ [<TrueLine 0 @I1@ INDI -> 1>], [<TrueLine 0 @I1@ INDI -> 1>, <TrueLine 1 NAME John /Doe/ -> 1>], [<TrueLine 0 @I1@ INDI -> 1>, <TrueLine 1 NAME John /Doe/ -> 1>, <TrueLine 2 SURN Doe -> 0>], [<TrueLine 0 @I2@ INDI -> 0>], ]