def __parse(self):
     while self.__get_line():
         if self.tag == 'INDI':
             self.num = int(self.pointer[2:len(self.pointer)-1])
             self.indi[self.num] = Indi(num = self.num)
             self.__get_indi()
         elif self.tag == 'FAM':
             self.num = int(self.pointer[2:len(self.pointer)-1])
             self.fam[self.num] = Fam(num = self.num)
             self.__get_fam()
         else:
             continue
 def __parse(self):
     while self.__get_line():
         if self.tag == 'INDI':
             self.num = int(self.pointer[2:len(self.pointer) - 1])
             self.indi[self.num] = Indi(tree=self.tree, num=self.num)
             self.__get_indi()
         elif self.tag == 'FAM':
             self.num = int(self.pointer[2:len(self.pointer) - 1])
             if self.num not in self.fam:
                 self.fam[self.num] = Fam(tree=self.tree, num=self.num)
             self.__get_fam()
         elif self.tag == 'NOTE':
             self.num = int(self.pointer[2:len(self.pointer) - 1])
             if self.num not in self.note:
                 self.note[self.num] = Note(tree=self.tree, num=self.num)
             self.__get_note()
         elif self.tag == 'SOUR':
             self.num = int(self.pointer[2:len(self.pointer) - 1])
             if self.num not in self.sour:
                 self.sour[self.num] = Source(tree=self.tree, num=self.num)
             self.__get_source()
         else:
             continue
    tree = Tree()

    indi_counter = 0
    fam_counter = 0

    # read the GEDCOM data
    for file in args.i:
        ged = Gedcom(file)

        # add informations about individuals
        for num in ged.indi:
            fid = ged.indi[num].fid
            if fid not in tree.indi:
                indi_counter += 1
                tree.indi[fid] = Indi(num = indi_counter)
                tree.indi[fid].fid = ged.indi[num].fid
            tree.indi[fid].fams_fid |= ged.indi[num].fams_fid
            tree.indi[fid].famc_fid |= ged.indi[num].famc_fid
            tree.indi[fid].given = ged.indi[num].given
            tree.indi[fid].surname = ged.indi[num].surname
            tree.indi[fid].gender = ged.indi[num].gender
            tree.indi[fid].birtdate = ged.indi[num].birtdate
            tree.indi[fid].birtplac = ged.indi[num].birtplac
            tree.indi[fid].chrdate = ged.indi[num].chrdate
            tree.indi[fid].chrplac = ged.indi[num].chrplac
            tree.indi[fid].deatdate = ged.indi[num].deatdate
            tree.indi[fid].deatplac = ged.indi[num].deatplac
            tree.indi[fid].buridate = ged.indi[num].buridate
            tree.indi[fid].buriplac = ged.indi[num].buriplac
Beispiel #4
0
    def save(self):
        if not self.files_to_merge.files:
            messagebox.showinfo(_('Error'),
                                message=_('Please add GEDCOM files'))
            return

        filename = filedialog.asksaveasfilename(title=_('Save as'),
                                                defaultextension='.ged',
                                                filetypes=(('GEDCOM', '.ged'),
                                                           (_('All files'),
                                                            '*.*')))
        tree = Tree()

        indi_counter = 0
        fam_counter = 0

        # read the GEDCOM data
        for file in self.files_to_merge.files.values():
            ged = Gedcom(file, tree)

            # add informations about individuals
            for num in ged.indi:
                fid = ged.indi[num].fid
                if fid not in tree.indi:
                    indi_counter += 1
                    tree.indi[fid] = Indi(tree=tree, num=indi_counter)
                    tree.indi[fid].tree = tree
                    tree.indi[fid].fid = ged.indi[num].fid
                tree.indi[fid].fams_fid |= ged.indi[num].fams_fid
                tree.indi[fid].famc_fid |= ged.indi[num].famc_fid
                tree.indi[fid].name = ged.indi[num].name
                tree.indi[fid].birthnames = ged.indi[num].birthnames
                tree.indi[fid].nicknames = ged.indi[num].nicknames
                tree.indi[fid].aka = ged.indi[num].aka
                tree.indi[fid].married = ged.indi[num].married
                tree.indi[fid].gender = ged.indi[num].gender
                tree.indi[fid].facts = ged.indi[num].facts
                tree.indi[fid].notes = ged.indi[num].notes
                tree.indi[fid].sources = ged.indi[num].sources
                tree.indi[fid].memories = ged.indi[num].memories
                tree.indi[fid].baptism = ged.indi[num].baptism
                tree.indi[fid].confirmation = ged.indi[num].confirmation
                tree.indi[fid].endowment = ged.indi[num].endowment
                if not (tree.indi[fid].sealing_child
                        and tree.indi[fid].sealing_child.famc):
                    tree.indi[fid].sealing_child = ged.indi[num].sealing_child

            # add informations about families
            for num in ged.fam:
                husb, wife = (ged.fam[num].husb_fid, ged.fam[num].wife_fid)
                if (husb, wife) not in tree.fam:
                    fam_counter += 1
                    tree.fam[(husb, wife)] = Fam(husb, wife, tree, fam_counter)
                    tree.fam[(husb, wife)].tree = tree
                tree.fam[(husb, wife)].chil_fid |= ged.fam[num].chil_fid
                tree.fam[(husb, wife)].fid = ged.fam[num].fid
                tree.fam[(husb, wife)].facts = ged.fam[num].facts
                tree.fam[(husb, wife)].notes = ged.fam[num].notes
                tree.fam[(husb, wife)].sources = ged.fam[num].sources
                tree.fam[(husb,
                          wife)].sealing_spouse = ged.fam[num].sealing_spouse

        # merge notes by text
        tree.notes = sorted(tree.notes, key=lambda x: x.text)
        for i, n in enumerate(tree.notes):
            if i == 0:
                n.num = 1
                continue
            if n.text == tree.notes[i - 1].text:
                n.num = tree.notes[i - 1].num
            else:
                n.num = tree.notes[i - 1].num + 1

        # compute number for family relationships and print GEDCOM file
        tree.reset_num()
        with open(filename, 'w', encoding='utf-8') as file:
            tree.print(file)
        messagebox.showinfo(_('Info'), message=_('Files successfully merged'))
    indi_counter = 0
    fam_counter = 0
    note_counter = 0
    temp_note = None

    # read the GEDCOM data
    for file in args.i:
        ged = Gedcom(file, tree)

        # add informations about individuals
        for num in ged.indi:
            fid = ged.indi[num].fid
            if fid not in tree.indi:
                indi_counter += 1
                tree.indi[fid] = Indi(tree=tree, num=indi_counter)
                tree.indi[fid].tree = tree
                tree.indi[fid].fid = ged.indi[num].fid
            tree.indi[fid].living = ged.indi[num].living
            tree.indi[fid].fams_fid |= ged.indi[num].fams_fid
            tree.indi[fid].famc_fid |= ged.indi[num].famc_fid
            tree.indi[fid].name = ged.indi[num].name
            tree.indi[fid].birthnames = ged.indi[num].birthnames
            tree.indi[fid].nicknames = ged.indi[num].nicknames
            tree.indi[fid].aka = ged.indi[num].aka
            tree.indi[fid].married = ged.indi[num].married
            tree.indi[fid].gender = ged.indi[num].gender
            tree.indi[fid].birtdate = ged.indi[num].birtdate
            tree.indi[fid].birtplac = ged.indi[num].birtplac
            tree.indi[fid].chrdate = ged.indi[num].chrdate
            tree.indi[fid].chrplac = ged.indi[num].chrplac