def __get_name(self): parts = self.data.split('/') name = Name() added = False name.given = parts[0].strip() name.surname = parts[1].strip() if parts[2]: name.suffix = parts[2] if not self.indi[self.num].name: self.indi[self.num].name = name added = True while self.__get_line() and self.level > 1: if self.tag == 'NPFX': name.prefix = self.data elif self.tag == 'TYPE': if self.data == 'aka': self.indi[self.num].aka.add(name) added = True elif self.data == 'married': self.indi[self.num].married.add(name) added = True elif self.tag == 'NICK': nick = Name() nick.given = self.data self.indi[self.num].nicknames.add(nick) elif self.tag == 'NOTE': num = int(self.data[2:len(self.data) - 1]) if num not in self.note: self.note[num] = Note(tree=self.tree, num=num) name.note = self.note[num] if not added: self.indi[self.num].birthnames.add(name) self.flag = True
def __get_source(self): while self.__get_line() and self.level > 0: if self.tag == 'TITL': self.sour[self.num].title = self.data elif self.tag == 'AUTH': self.sour[self.num].citation = self.data elif self.tag == 'PUBL': self.sour[self.num].url = self.data elif self.tag == 'REFN': self.sour[self.num].fid = self.data elif self.tag == 'NOTE': num = int(self.data[2:len(self.data) - 1]) if num not in self.note: self.note[num] = Note(tree=self.tree, num=num) self.sour[self.num].notes.add(self.note[num]) self.flag = True
def __get_fact(self): fact = Fact() fact.value = self.data if self.tag == 'DSCR': self.indi[self.num].physical_descriptions.add(fact) elif self.tag == 'OCCU': self.indi[self.num].occupations.add(fact) elif self.tag == '_MILT': self.indi[self.num].military.add(fact) while self.__get_line() and self.level > 1: if self.tag == 'DATE': fact.date = self.data elif self.tag == 'PLAC': fact.place = self.data elif self.tag == 'NOTE': num = int(self.data[2:len(self.data) - 1]) if num not in self.note: self.note[num] = Note(tree=self.tree, num=num) fact.note = self.note[num] self.flag = True
def __get_marr(self): fact = Fact() if self.tag == 'MARR': fact.type = 'http://gedcomx.org/Marriage' elif self.tag == 'DIV': fact.type = 'http://gedcomx.org/Divorce' elif self.tag == 'ANUL': fact.type = 'http://gedcomx.org/Annulment' elif self.tag == '_COML': fact.type = 'http://gedcomx.org/CommonLawMarriage' while self.__get_line() and self.level > 1: if self.tag == 'DATE': fact.date = self.data elif self.tag == 'PLAC': fact.place = self.data elif self.tag == 'NOTE': num = int(self.data[2:len(self.data) - 1]) if num not in self.note: self.note[num] = Note(tree=self.tree, num=num) fact.note = self.note[num] self.flag = True return fact
def __get_fam(self): while self.__get_line() and self.level > 0: if self.tag == 'HUSB': self.fam[self.num].husb_num = int(self.data[2:len(self.data) - 1]) elif self.tag == 'WIFE': self.fam[self.num].wife_num = int(self.data[2:len(self.data) - 1]) elif self.tag == 'CHIL': self.fam[self.num].chil_num.add(int(self.data[2:len(self.data) - 1])) elif self.tag in ('MARR', 'DIV', 'ANUL', '_COML'): self.fam[self.num].marriage_facts.add(self.__get_marr()) elif self.tag == 'SLGS': self.fam[self.num].sealing_spouse = self.__get_ordinance() elif self.tag == '_FSFTID': self.fam[self.num].fid = self.data elif self.tag == 'NOTE': num = int(self.data[2:len(self.data) - 1]) if num not in self.note: self.note[num] = Note(tree=self.tree, num=num) self.fam[self.num].notes.add(self.note[num]) elif self.tag == 'SOUR': self.fam[self.num].sources.add(self.__get_link_source()) self.flag = True
def __get_indi(self): while self.f and self.__get_line() and self.level > 0: if self.tag == 'NAME': self.__get_name() elif self.tag == 'SEX': self.indi[self.num].gender = self.data elif self.tag == 'BIRT': self.__get_birt() elif self.tag == 'CHR': self.__get_chr() elif self.tag == 'DEAT': self.__get_deat() elif self.tag == 'BURI': self.__get_buri() elif self.tag == 'DSCR' or self.tag == 'OCCU' or self.tag == '_MILT': self.__get_fact() elif self.tag == 'BAPL': self.indi[self.num].baptism = self.__get_ordinance() elif self.tag == 'CONL': self.indi[self.num].confirmation = self.__get_ordinance() elif self.tag == 'ENDL': self.indi[self.num].endowment = self.__get_ordinance() elif self.tag == 'SLGC': self.indi[self.num].sealing_child = self.__get_ordinance() elif self.tag == 'FAMS': self.indi[self.num].fams_num.add(int(self.data[2:len(self.data) - 1])) elif self.tag == 'FAMC': self.indi[self.num].famc_num.add(int(self.data[2:len(self.data) - 1])) elif self.tag == '_FSFTID': self.indi[self.num].fid = self.data elif self.tag == 'NOTE': num = int(self.data[2:len(self.data) - 1]) if num not in self.note: self.note[num] = Note(tree=self.tree, num=num) self.indi[self.num].notes.add(self.note[num]) elif self.tag == 'SOUR': self.indi[self.num].sources.add(self.__get_link_source()) self.flag = True
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