gedcom.element.element module¶
Base GEDCOM element
- class gedcom.element.element.Element(level, pointer, tag, value, crlf='\n', multi_line=True)¶
Bases:
objectGEDCOM element Each line in a GEDCOM file is an element with the format level [pointer] tag [value] where level and tag are required, and pointer and value are optional. Elements are arranged hierarchically according to their level, and elements with a level of zero are at the top level. Elements with a level greater than zero are children of their parent.
A pointer has the format @pname@, where pname is any sequence of characters and numbers. The pointer identifies the object being pointed to, so that any pointer included as the value of any element points back to the original object. For example, an element may have a FAMS tag whose value is @F1@, meaning that this element points to the family record in which the associated person is a spouse. Likewise, an element with a tag of FAMC has a value that points to a family record in which the associated person is a child.
See a GEDCOM file for examples of tags and their values. Tags available to an element are seen here: gedcom.tags
- add_child_element(element)¶
Adds a child element to this element
- equals(element)¶
Returns true when the specific fields for both elements match. The comparison includes the level, pointer, tag and pointer. If the tag is ‘BIRT’,’BURI’,’DEAT’,’_MILT’, or ‘RESI’, the comparison includes the date and place from the child elements.
- Return type
bool
- get_child_element_value(tag='DATE')¶
Returns the value for a specific child element. Assumes there will only be one child element per tag
- Return type
str
- get_child_elements()¶
Returns the direct child elements of this element
- Return type
list of Element
- get_child_value_by_tag(tag)¶
Returns value of child element by tag including any CONC lines
- Return type
str
- get_individual()¶
Returns this element and all of its sub-elements represented as a GEDCOM string ::deprecated:: As of version 1.0.0 use to_gedcom_string() method instead
- Return type
str
- get_level()¶
Returns the level of this element from within the GEDCOM file
- Return type
int
- get_multi_line_value()¶
Returns the value of this element including concatenations or continuations
- Return type
str
- get_pointer()¶
Returns the pointer of this element from within the GEDCOM file
- Return type
str
- get_tag()¶
Returns the tag of this element from within the GEDCOM file
- Return type
str
- get_value()¶
Return the value of this element from within the GEDCOM file
- Return type
str
- new_child_element(tag, pointer='', value='')¶
Creates and returns a new child element of this element
- Return type
- remove_child_element(pointer)¶
Removes child element based on pointer
- set_multi_line_value(value)¶
Sets the value of this element, adding concatenation and continuation lines when necessary
- set_parent_element(element)¶
Adds a parent element to this element There’s usually no need to call this method manually, add_child_element() calls it automatically.
- set_value(value)¶
Sets the value of this element
- to_gedcom_string(recursive=False)¶
Formats this element and optionally all of its sub-elements into a GEDCOM string
- Return type
str