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.ABCAbstract base class for gedcom lines.
Implementations are
TrueLineandFakeLine, see these classes for more information.- abstract 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.
- 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.- 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.- 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.
- 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.
- 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.
- __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. The type is the payload of level 0 lines: INDI, FAM, etc..