def test_invalidate_cache(): parser = Parser() parser.parse_file('tests/files/Musterstammbaum.ged') assert len(parser.get_element_list()) == 396 assert len(parser.get_element_dictionary()) == 32 parser.invalidate_cache() assert len(parser.get_element_list()) == 396 assert len(parser.get_element_dictionary()) == 32
# License: MIT import sys from gedcom.parser import Parser from gedcom.element.individual import IndividualElement from gedcom.element.family import FamilyElement try: workpath = sys.argv[1] except IndexError: sys.exit("No gedcom defined!") def term2id(el): return "i" + el.get_pointer().replace('@', '').lower() g = Parser() g.parse_file(workpath) gedcom_dict = g.get_element_dictionary() individuals, marriages = {}, {} for k, v in gedcom_dict.items(): if isinstance(v, IndividualElement): children, siblings = set(), set() idx = term2id(v) title = v.get_name()[0] + " " + v.get_name()[1] title = title.replace('"', '').replace('[', '').replace(']', '').replace('(', '').replace(')', '').strip() own_families = g.get_families(v, 'FAMS') for fam in own_families: children |= set(term2id(i) for i in g.get_family_members(fam, "CHIL")) parent_families = g.get_families(v, 'FAMC')