Esempio n. 1
0
    def parse(self, gedcom_stream, strict=True):
        """Parses a stream, or an array of lines, as GEDCOM 5.5 formatted data
        :type gedcom_stream: a file stream, or str array of lines with new line at the end
        :type strict: bool
        """
        self.invalidate_cache()
        self.__root_element = RootElement()

        line_number = 1
        last_element = self.get_root_element()

        for line in gedcom_stream:
            last_element = self.__parse_line(line_number,
                                             line.decode('utf-8-sig'),
                                             last_element, strict)
            line_number += 1
Esempio n. 2
0
    def parse_file(self, file_path, strict=True):
        """Opens and parses a file, from the given file path, as GEDCOM 5.5 formatted data
        :type file_path: str
        :type strict: bool
        """
        self.invalidate_cache()
        self.__root_element = RootElement()

        gedcom_file = open(file_path, 'rb')
        line_number = 1
        last_element = self.get_root_element()

        for line in gedcom_file:
            last_element = self.__parse_line(line_number,
                                             line.decode('utf-8-sig'),
                                             last_element, strict)
            line_number += 1
Esempio n. 3
0
def test_initialization():
    root_element = RootElement(level=-1, pointer="", tag="ROOT", value="")
    assert isinstance(root_element, Element)
    assert isinstance(root_element, RootElement)
Esempio n. 4
0
 def __init__(self):
     """Initialize a GEDCOM data object."""
     self.__element_list = []
     self.__element_dictionary = {}
     self.__root_element = RootElement()
Esempio n. 5
0
 def __init__(self):
     self.__element_list = []
     self.__element_dictionary = {}
     self.__root_element = RootElement()