GedcomElement

class src.pygedcom.elements.element.GedcomElement(level: int, tag: str, sub_elements: list, value: str | None = None)

Bases: object

Class for representing a Gedcom element.

Parameters:
  • level (int) – The level of the Gedcom element.

  • tag (str) – The tag of the Gedcom element.

  • sub_elements (list) – The sub elements of the Gedcom element.

  • value (str, optional) – The value of the Gedcom element. Defaults to None.

Returns:

The Gedcom element.

Return type:

GedcomElement

add_sub_element(level, tag, sub_elements, value=None)

Add a sub element to the Gedcom element.

Parameters:
  • level (int) – The level of the sub element.

  • tag (str) – The tag of the sub element.

  • sub_elements (list) – The sub elements of the sub element.

  • value (str, optional) – The value of the sub element. Defaults to None.

export() dict

Export the Gedcom element.

Returns:

The exported Gedcom element.

Return type:

dict

extract_gedcom() str

Extract the Gedcom element.

Returns:

The extracted Gedcom element.

Return type:

str

find_sub_element(tag: str) list

Find a sub element by tag.

Parameters:

tag (str) – The tag of the sub element to find.

Returns:

The sub element found.

Return type:

list

get_gedcom()

Get the Gedcom representation of the Gedcom element.

Returns:

The Gedcom representation of the Gedcom element.

Return type:

str

get_level() int

Get the level of the Gedcom element.

Returns:

The level of the Gedcom element.

Return type:

int

get_sub_elements()

Get the sub elements of the Gedcom element.

Returns:

The sub elements of the Gedcom element.

Return type:

list

get_tag() str

Get the tag of the Gedcom element.

Returns:

The tag of the Gedcom element.

Return type:

str

get_value() str

Get the value of the Gedcom element.

Returns:

The value of the Gedcom element.

Return type:

str

remove_sub_element(element)

Remove a sub element from the Gedcom element.

Parameters:

element (GedcomElement) – The sub element to remove.

set_value(value: str)

Set the value of the Gedcom element.

Parameters:

value (str) – The value to set.