def add(self, obj): person = Person() # attempt to get the current surname (model, pathlist) = self.selection.get_selected_rows() name = Name() #the editor requires a surname name.add_surname(Surname()) name.set_primary_surname(0) basepers = None if len(pathlist) == 1: path = pathlist[0] pathids = path.get_indices() if len(pathids) == 1: path = Gtk.TreePath((pathids[0], 0)) iter_ = model.get_iter(path) handle = model.get_handle_from_iter(iter_) basepers = self.dbstate.db.get_person_from_handle(handle) if basepers: preset_name(basepers, name) person.set_primary_name(name) try: EditPerson(self.dbstate, self.uistate, [], person) except WindowActiveError: pass
def __add_person(self, button): """ Create a new person and add them to the form. """ person = Person() EditPerson(self.dbstate, self.uistate, self.track, person, self.__person_added)
def create_person(self): """ Used to create a new person we know doesn't exist """ person = Person() if self.default_tag: person.add_tag(self.default_tag.handle) self.db.add_person(person, self.trans) self.indi_count += 1 return person
def next_person(self): """A VCard for another person is started.""" if self.person is not None: self.finish_person() LOG.warn("BEGIN property not properly closed by END property, " "Gramps can't cope with nested VCards.") self.person = Person() self.formatted_name = '' self.name_parts = ''
def next_person(self): """A VCard for another person is started.""" if self.person is not None: self.finish_person() self.__add_msg(_("BEGIN property not properly closed by END " "property, Gramps can't cope with nested VCards."), self.line_num - 1) self.person = Person() self.formatted_name = '' self.name_parts = ''
def __add_person(self, gender, first_name, surname, trans): person = Person() person.gender = gender name = person.primary_name name.first_name = first_name surname1 = Surname() surname1.surname = surname name.set_surname_list([surname1]) self.all_surnames.append(surname) self.db.add_person(person, trans)
def _add_person(gender, first_name, surname, trans, db): person = Person() person.gender = gender _name = person.primary_name _name.first_name = first_name surname1 = Surname() surname1.surname = surname _name.set_surname_list([surname1]) person.gramps_id = "person001" db.add_person(person, trans)
def add_participant(self, *obj): person = Person() ref = EventRef() ref.ref = self.handle person.add_event_ref(ref) try: EditPerson(self.dbstate, self.uistate, [], person) except WindowActiveError: pass
def get_or_create_person(self, firstname, lastname): person = None mykey = firstname + lastname if mykey in self.ikeys and firstname != "?" and lastname != "?": person = self.db.get_person_from_handle(self.ikeys[mykey]) else: person = Person() self.db.add_person(person, self.trans) self.db.commit_person(person, self.trans) self.ikeys[mykey] = person.get_handle() return person
def empty_object(self): """ Return an empty Person object for comparison for changes. This is used by the base class (EditPrimary). """ person = Person() #the editor requires a surname person.primary_name.add_surname(Surname()) person.primary_name.set_primary_surname(0) return person
def add(self, obj): """ Add a new person to the database. """ person = Person() #the editor requires a surname person.primary_name.add_surname(Surname()) person.primary_name.set_primary_surname(0) try: EditPerson(self.dbstate, self.uistate, [], person) except WindowActiveError: pass
def post(self, path): if "/" in path: handle, action = path.split("/") else: handle, action = path, "view" if handle == "add": person = Person() person.primary_name.surname_list.append(Surname()) person.handle = handle = create_id() else: person = self.database.get_person_from_handle(handle) form = PersonForm(self.database, _, instance=person) form.save(handler=self) self.redirect("/person/%(handle)s" % {"handle": handle})
def log(self, ltype, action, handles): for handle in set(handles): if self.last_log == (ltype, action, handle): continue self.last_log = (ltype, action, handle) self.timestamp() # Translators: needed for French, ignore otherwise self.append_text(_("%s: ") % _(action)) if action == 'Deleted': transaction = self.dbstate.db.transaction if ltype == 'Person': name = 'a person' if transaction is not None: for i in transaction.get_recnos(reverse=True): (obj_type, trans_type, hndl, old_data, dummy) = \ transaction.get_record(i) if isinstance(hndl, bytes): hndl = str(hndl, "utf-8") if (obj_type == PERSON_KEY and trans_type == TXNDEL and hndl == handle): person = Person() person.unserialize(old_data) name = name_displayer.display(person) break elif ltype == 'Family': name = 'a family' if transaction is not None: for i in transaction.get_recnos(reverse=True): (obj_type, trans_type, hndl, old_data, dummy) = \ transaction.get_record(i) if isinstance(hndl, bytes): hndl = str(hndl, "utf-8") if (obj_type == FAMILY_KEY and trans_type == TXNDEL and hndl == handle): family = Family() family.unserialize(old_data) name = family_name(family, self.dbstate.db, name) break self.append_text(name) else: if ltype == 'Person': person = self.dbstate.db.get_person_from_handle(handle) name = name_displayer.display(person) elif ltype == 'Family': family = self.dbstate.db.get_family_from_handle(handle) name = family_name(family, self.dbstate.db, 'a family') self.link(name, ltype, handle) self.append_text("\n")
def add_mother_clicked(self, obj): person = Person() person.set_gender(Person.FEMALE) autoname = config.get('behavior.surname-guessing') #_("Father's surname"), #_("None"), #_("Combination of mother's and father's surname"), #_("Icelandic style"), if autoname == 2: name = self.latin_american_child("mother") else: name = self.no_name() person.set_primary_name(name) EditPerson(self.dbstate, self.uistate, self.track, person, self.new_mother_added)
def add_button_clicked(self, obj=None): person = Person() autoname = config.get('behavior.surname-guessing') #_("Father's surname"), #_("None"), #_("Combination of mother's and father's surname"), #_("Icelandic style"), if autoname == 0: name = self.north_american() elif autoname == 2: name = self.latin_american() else: name = self.no_name() person.set_primary_name(name) EditPerson(self.dbstate, self.uistate, self.track, person, self.new_child_added)
def get(self, path=""): """ HANDLE HANDLE/edit|delete /add b2cfa6ca1e174b1f63d/remove/eventref/1 """ page = int(self.get_argument("page", 1)) search = self.get_argument("search", "") if "/" in path: handle, action = path.split("/", 1) else: handle, action = path, "view" if handle: if handle == "add": person = Person() person.primary_name.surname_list.append(Surname()) action = "edit" else: person = self.database.get_person_from_handle(handle) if person: person.probably_alive = True self.render( "person.html", **self.get_template_dict(tview=_("person detail"), action=action, page=page, search=search, form=PersonForm(self.database, _, instance=person), logform=None)) return else: self.clear() self.set_status(404) self.finish("<html><body>No such person</body></html>") return self.render( "page_view.html", **self.get_template_dict( tview=_("person view"), page=page, search=search, form=PersonForm(self.database, _, table="Person"), ))
def add_child_to_fam(self, obj, event, handle): if button_activated(event, _LEFT_BUTTON): callback = lambda x: self.callback_add_child(x, handle) person = Person() name = Name() #the editor requires a surname name.add_surname(Surname()) name.set_primary_surname(0) family = self.dbstate.db.get_family_from_handle(handle) father = self.dbstate.db.get_person_from_handle( family.get_father_handle()) if father: preset_name(father, name) person.set_primary_name(name) try: EditPerson(self.dbstate, self.uistate, [], person, callback=callback) except WindowActiveError: pass
def run_tool(self): self.progress = ProgressMeter(_('Running Date Test'), '', parent=self.parent_window) self.progress.set_pass(_('Generating dates'), 4) dates = [] # first some valid dates calendar = Date.CAL_GREGORIAN for quality in (Date.QUAL_NONE, Date.QUAL_ESTIMATED, Date.QUAL_CALCULATED): for modifier in (Date.MOD_NONE, Date.MOD_BEFORE, Date.MOD_AFTER, Date.MOD_ABOUT): for slash1 in (False, True): for month in range(0, 13): for day in (0, 5, 27): if not month and day: continue d = Date() d.set(quality, modifier, calendar, (day, month, 1789, slash1), "Text comment") dates.append(d) for modifier in (Date.MOD_RANGE, Date.MOD_SPAN): for slash1 in (False, True): for slash2 in (False, True): for month in range(0, 13): for day in (0, 5, 27): if not month and day: continue d = Date() d.set(quality, modifier, calendar, (day, month, 1789, slash1, day, month, 1876, slash2), "Text comment") dates.append(d) if not month: continue d = Date() d.set(quality, modifier, calendar, (day, month, 1789, slash1, day, 13 - month, 1876, slash2), "Text comment") dates.append(d) if not day: continue d = Date() d.set(quality, modifier, calendar, (day, month, 1789, slash1, 32 - day, month, 1876, slash2), "Text comment") dates.append(d) d = Date() d.set(quality, modifier, calendar, (day, month, 1789, slash1, 32 - day, 13 - month, 1876, slash2), "Text comment") dates.append(d) modifier = Date.MOD_TEXTONLY d = Date() d.set(quality, modifier, calendar, Date.EMPTY, "This is a textual date") dates.append(d) self.progress.step() # test invalid dates #dateval = (4,7,1789,False,5,8,1876,False) #for l in range(1,len(dateval)): # d = Date() # try: # d.set(Date.QUAL_NONE,Date.MOD_NONE, # Date.CAL_GREGORIAN,dateval[:l],"Text comment") # dates.append( d) # except DateError, e: # d.set_as_text("Date identified value correctly as invalid.\n%s" % e) # dates.append( d) # except: # d = Date() # d.set_as_text("Date.set Exception %s" % ("".join(traceback.format_exception(*sys.exc_info())),)) # dates.append( d) #for l in range(1,len(dateval)): # d = Date() # try: # d.set(Date.QUAL_NONE,Date.MOD_SPAN,Date.CAL_GREGORIAN,dateval[:l],"Text comment") # dates.append( d) # except DateError, e: # d.set_as_text("Date identified value correctly as invalid.\n%s" % e) # dates.append( d) # except: # d = Date() # d.set_as_text("Date.set Exception %s" % ("".join(traceback.format_exception(*sys.exc_info())),)) # dates.append( d) #self.progress.step() #d = Date() #d.set(Date.QUAL_NONE,Date.MOD_NONE, # Date.CAL_GREGORIAN,(44,7,1789,False),"Text comment") #dates.append( d) #d = Date() #d.set(Date.QUAL_NONE,Date.MOD_NONE, # Date.CAL_GREGORIAN,(4,77,1789,False),"Text comment") #dates.append( d) #d = Date() #d.set(Date.QUAL_NONE,Date.MOD_SPAN, # Date.CAL_GREGORIAN, # (4,7,1789,False,55,8,1876,False),"Text comment") #dates.append( d) #d = Date() #d.set(Date.QUAL_NONE,Date.MOD_SPAN, # Date.CAL_GREGORIAN, # (4,7,1789,False,5,88,1876,False),"Text comment") #dates.append( d) with DbTxn(_("Date Test Plugin"), self.db, batch=True) as self.trans: self.db.disable_signals() self.progress.set_pass(_('Generating dates'), len(dates)) # create pass and fail tags pass_handle = self.create_tag(_('Pass'), '#0000FFFF0000') fail_handle = self.create_tag(_('Fail'), '#FFFF00000000') # now add them as birth to new persons i = 1 for dateval in dates: person = Person() surname = Surname() surname.set_surname("DateTest") name = Name() name.add_surname(surname) name.set_first_name("Test %d" % i) person.set_primary_name(name) self.db.add_person(person, self.trans) bevent = Event() bevent.set_type(EventType.BIRTH) bevent.set_date_object(dateval) bevent.set_description("Date Test %d (source)" % i) bevent_h = self.db.add_event(bevent, self.trans) bevent_ref = EventRef() bevent_ref.set_reference_handle(bevent_h) # for the death event display the date as text and parse it back to a new date ndate = None try: datestr = _dd.display(dateval) try: ndate = _dp.parse(datestr) if not ndate: ndate = Date() ndate.set_as_text("DateParser None") person.add_tag(fail_handle) else: person.add_tag(pass_handle) except: ndate = Date() ndate.set_as_text("DateParser Exception %s" % ("".join( traceback.format_exception(*sys.exc_info())), )) person.add_tag(fail_handle) else: person.add_tag(pass_handle) except: ndate = Date() ndate.set_as_text("DateDisplay Exception: %s" % ("".join( traceback.format_exception(*sys.exc_info())), )) person.add_tag(fail_handle) if dateval.get_modifier() != Date.MOD_TEXTONLY \ and ndate.get_modifier() == Date.MOD_TEXTONLY: # parser was unable to correctly parse the string ndate.set_as_text("TEXTONLY: " + ndate.get_text()) person.add_tag(fail_handle) if dateval.get_modifier() == Date.MOD_TEXTONLY \ and dateval.get_text().count("Traceback") \ and pass_handle in person.get_tag_list(): person.add_tag(fail_handle) devent = Event() devent.set_type(EventType.DEATH) devent.set_date_object(ndate) devent.set_description("Date Test %d (result)" % i) devent_h = self.db.add_event(devent, self.trans) devent_ref = EventRef() devent_ref.set_reference_handle(devent_h) person.set_birth_ref(bevent_ref) person.set_death_ref(devent_ref) self.db.commit_person(person, self.trans) i = i + 1 self.progress.step() self.db.enable_signals() self.db.request_rebuild() self.progress.close()
def dump_parent(self, title, person_handle): if not person_handle and not self.missingInfo: return elif not person_handle: person = Person() else: person = self.database.get_person_from_handle(person_handle) name = self._name_display.display(person) self.doc.start_table(title, 'FGR-ParentTable') self.doc.start_row() self.doc.start_cell('FGR-ParentHead', 3) self.doc.start_paragraph('FGR-ParentName') self.doc.write_text(title + ': ') mark = ReportUtils.get_person_mark(self.database, person) self.doc.write_text(name, mark) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() birth_ref = person.get_birth_ref() birth = None evtName = self._("Birth") if birth_ref: birth = self.database.get_event_from_handle(birth_ref.ref) if birth or self.missingInfo: self.dump_parent_event(evtName, birth) death_ref = person.get_death_ref() death = None evtName = self._("Death") if death_ref: death = self.database.get_event_from_handle(death_ref.ref) if death or self.missingInfo: self.dump_parent_event(evtName, death) self.dump_parent_parents(person) if self.incParEvents: for event_ref in person.get_primary_event_ref_list(): if event_ref != birth_ref and event_ref != death_ref: event = self.database.get_event_from_handle(event_ref.ref) event_type = self._get_type(event.get_type()) self.dump_parent_event(self._(event_type), event) if self.incParAddr: addrlist = person.get_address_list()[:] for addr in addrlist: location = ReportUtils.get_address_str(addr) date = self._get_date(addr.get_date_object()) self.doc.start_row() self.doc.start_cell("FGR-TextContents") self.doc.start_paragraph('FGR-Normal') self.doc.write_text(self._("Address")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("FGR-TextContents") self.doc.start_paragraph('FGR-Normal') self.doc.write_text(date) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("FGR-TextContentsEnd") self.doc.start_paragraph('FGR-Normal') self.doc.write_text(location) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() if self.incParNotes: for notehandle in person.get_note_list(): note = self.database.get_note_from_handle(notehandle) self.dump_parent_noteline(self._("Note"), note) if self.includeAttrs: for attr in person.get_attribute_list(): attr_type = self._get_type(attr.get_type()) self.dump_parent_line(self._(attr_type), attr.get_value()) if self.incParNames: for alt_name in person.get_alternate_names(): name_type = self._get_type(alt_name.get_type()) name = self._name_display.display_name(alt_name) self.dump_parent_line(self._(name_type), name) self.doc.end_table()
def _process(self, count, total, sql): # --------------------------------- # Process note # --------------------------------- notes = sql.query("""select * from note;""") for note in notes: (handle, gid, text, _format, note_type1, note_type2, change, private) = note styled_text = [text, []] markups = sql.query( """select * from link where from_handle = ? """ """and to_type = 'markup';""", handle) for markup_link in markups: _from_type, _from_handle, _to_type, to_handle = markup_link markup_detail = sql.query( """select * from markup where handle = ?;""", to_handle) for markup in markup_detail: (_mhandle, markup0, markup1, value, start_stop_list) = markup ss_list = eval(start_stop_list) styled_text[1] += [((markup0, markup1), value, ss_list)] tags = self.get_links(sql, "note", handle, "tag") g_note = Note() g_note.unserialize( (handle, gid, styled_text, _format, (note_type1, note_type2), change, tags, bool(private))) self.db.add_note(g_note, self.trans) count += 1 self.callback(100 * count / total) # --------------------------------- # Process event # --------------------------------- events = sql.query("""select * from event;""") for event in events: (handle, gid, the_type0, the_type1, description, change, private) = event note_list = self.get_note_list(sql, "event", handle) citation_list = self.get_citation_list(sql, "event", handle) media_list = self.get_media_list(sql, "event", handle) attribute_list = self.get_attribute_list(sql, "event", handle) date_handle = self.get_link(sql, "event", handle, "date") date = self.get_date(sql, date_handle) place_handle = self.get_link(sql, "event", handle, "place") place = self.get_place_from_handle(sql, place_handle) tags = self.get_links(sql, "event", handle, "tag") data = (handle, gid, (the_type0, the_type1), date, description, place, citation_list, note_list, media_list, attribute_list, change, tags, bool(private)) g_event = Event() g_event.unserialize(data) self.db.add_event(g_event, self.trans) count += 1 self.callback(100 * count / total) # --------------------------------- # Process person # --------------------------------- people = sql.query("""select * from person;""") for person in people: if person is None: continue ( handle, # 0 gid, # 1 gender, # 2 death_ref_handle, # 5 birth_ref_handle, # 6 change, # 17 private, # 19 ) = person primary_name = self.get_names(sql, "person", handle, True) # one alternate_names = self.get_names(sql, "person", handle, False) event_ref_list = self.get_event_ref_list(sql, "person", handle) family_list = self.get_family_list(sql, "person", handle) parent_family_list = self.get_parent_family_list( sql, "person", handle) media_list = self.get_media_list(sql, "person", handle) address_list = self.get_address_list(sql, "person", handle, with_parish=False) attribute_list = self.get_attribute_list(sql, "person", handle) urls = self.get_url_list(sql, "person", handle) lds_ord_list = self.get_lds_list(sql, "person", handle) pcitation_list = self.get_citation_list(sql, "person", handle) pnote_list = self.get_note_list(sql, "person", handle) person_ref_list = self.get_person_ref_list(sql, "person", handle) death_ref_index = lookup(death_ref_handle, event_ref_list) birth_ref_index = lookup(birth_ref_handle, event_ref_list) tags = self.get_links(sql, "person", handle, "tag") data = ( handle, # 0 gid, # 1 gender, # 2 primary_name, # 3 alternate_names, # 4 death_ref_index, # 5 birth_ref_index, # 6 event_ref_list, # 7 family_list, # 8 parent_family_list, # 9 media_list, # 10 address_list, # 11 attribute_list, # 12 urls, # 13 lds_ord_list, # 14 pcitation_list, # 15 pnote_list, # 16 change, # 17 tags, bool(private), # 19 person_ref_list, ) # 20 g_pers = Person() g_pers.unserialize(data) self.db.add_person(g_pers, self.trans) count += 1 self.callback(100 * count / total) # --------------------------------- # Process family # --------------------------------- families = sql.query("""select * from family;""") for family in families: (handle, gid, father_handle, mother_handle, the_type0, the_type1, change, private) = family child_ref_list = self.get_child_ref_list(sql, "family", handle) event_ref_list = self.get_event_ref_list(sql, "family", handle) media_list = self.get_media_list(sql, "family", handle) attribute_list = self.get_attribute_list(sql, "family", handle) lds_seal_list = self.get_lds_list(sql, "family", handle) citation_list = self.get_citation_list(sql, "family", handle) note_list = self.get_note_list(sql, "family", handle) tags = self.get_links(sql, "family", handle, "tag") data = (handle, gid, father_handle, mother_handle, child_ref_list, (the_type0, the_type1), event_ref_list, media_list, attribute_list, lds_seal_list, citation_list, note_list, change, tags, private) g_fam = Family() g_fam.unserialize(data) self.db.add_family(g_fam, self.trans) count += 1 self.callback(100 * count / total) # --------------------------------- # Process repository # --------------------------------- repositories = sql.query("""select * from repository;""") for repo in repositories: (handle, gid, the_type0, the_type1, name, change, private) = repo note_list = self.get_note_list(sql, "repository", handle) address_list = self.get_address_list(sql, "repository", handle, with_parish=False) urls = self.get_url_list(sql, "repository", handle) tags = self.get_links(sql, "repository", handle, "tag") data = (handle, gid, (the_type0, the_type1), name, note_list, address_list, urls, change, tags, private) g_rep = Repository() g_rep.unserialize(data) self.db.add_repository(g_rep, self.trans) count += 1 self.callback(100 * count / total) # --------------------------------- # Process place # --------------------------------- places = sql.query("""select * from place;""") for place in places: count += 1 (handle, gid, title, value, the_type0, the_type1, code, long, lat, lang, change, private) = place # We could look this up by "place_main", but we have the handle: #main_loc = self.get_main_location(sql, handle, with_parish=True) alt_loc_list = self.get_location_list(sql, "place_alt", handle, with_parish=True) urls = self.get_url_list(sql, "place", handle) media_list = self.get_media_list(sql, "place", handle) citation_list = self.get_citation_list(sql, "place", handle) note_list = self.get_note_list(sql, "place", handle) tags = self.get_links(sql, "place", handle, "tag") place_type = (the_type0, the_type1) alt_place_name_list = self.get_alt_place_name_list(sql, handle) place_ref_list = self.get_place_ref_list(sql, handle) data = (handle, gid, title, long, lat, place_ref_list, PlaceName(value=value, lang=lang).serialize(), alt_place_name_list, place_type, code, alt_loc_list, urls, media_list, citation_list, note_list, change, tags, private) g_plac = Place() g_plac.unserialize(data) self.db.commit_place(g_plac, self.trans) self.callback(100 * count / total) # --------------------------------- # Process citation # --------------------------------- citations = sql.query("""select * from citation;""") for citation in citations: (handle, gid, confidence, page, source_handle, change, private) = citation date_handle = self.get_link(sql, "citation", handle, "date") date = self.get_date(sql, date_handle) note_list = self.get_note_list(sql, "citation", handle) media_list = self.get_media_list(sql, "citation", handle) datamap = self.get_datamap_list(sql, "citation", handle) tags = self.get_links(sql, "citation", handle, "tag") data = (handle, gid, date, page, confidence, source_handle, note_list, media_list, datamap, change, tags, private) g_cit = Citation() g_cit.unserialize(data) self.db.commit_citation(g_cit, self.trans) count += 1 self.callback(100 * count / total) # --------------------------------- # Process source # --------------------------------- sources = sql.query("""select * from source;""") for source in sources: (handle, gid, title, author, pubinfo, abbrev, change, private) = source note_list = self.get_note_list(sql, "source", handle) media_list = self.get_media_list(sql, "source", handle) datamap = self.get_datamap_list(sql, "source", handle) reporef_list = self.get_repository_ref_list(sql, "source", handle) tags = self.get_links(sql, "source", handle, "tag") data = (handle, gid, title, author, pubinfo, note_list, media_list, abbrev, change, datamap, reporef_list, tags, private) g_src = Source() g_src.unserialize(data) self.db.commit_source(g_src, self.trans) count += 1 self.callback(100 * count / total) # --------------------------------- # Process media # --------------------------------- media = sql.query("""select * from media;""") for med in media: (handle, gid, path, mime, desc, checksum, change, private) = med attribute_list = self.get_attribute_list(sql, "media", handle) citation_list = self.get_citation_list(sql, "media", handle) note_list = self.get_note_list(sql, "media", handle) date_handle = self.get_link(sql, "media", handle, "date") date = self.get_date(sql, date_handle) tags = self.get_links(sql, "media", handle, "tag") data = (handle, gid, path, mime, desc, checksum, attribute_list, citation_list, note_list, change, date, tags, private) g_med = Media() g_med.unserialize(data) self.db.commit_media(g_med, self.trans) count += 1 self.callback(100 * count / total) # --------------------------------- # Process tag # --------------------------------- tags = sql.query("""select * from tag;""") for tag in tags: (handle, name, color, priority, change) = tag data = (handle, name, color, priority, change) g_tag = Tag() g_tag.unserialize(data) self.db.commit_tag(g_tag, self.trans) count += 1 self.callback(100 * count / total)
def add_person_clicked(self, event): if self.selection_widget.get_current(): person = Person() EditPerson(self.dbstate, self.uistate, self.track, person, self.new_person_added)
def __add_clicked(self, obj): person = Person() EditPerson(self.dbstate, self.uistate, self.track, person, self.__added)
def dump_parent(self, title, person_handle): if not person_handle and not self.missing_info: return elif not person_handle: person = Person() else: person = self.db.get_person_from_handle(person_handle) name = self._name_display.display(person) self.doc.start_table(title, 'FGR-ParentTable') self.doc.start_row() self.doc.start_cell('FGR-ParentHead', 3) self.doc.start_paragraph('FGR-ParentName') mark = utils.get_person_mark(self.db, person) # translators: needed for French, ignore otherwise self.doc.write_text( self._("%(str1)s: %(str2)s") % { 'str1': title, 'str2': name }, mark) if self.gramps_ids: gid = person.get_gramps_id() if gid: self.doc.write_text(" (%s)" % gid) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() birth_ref = person.get_birth_ref() birth = None ev_name = self._("Birth") if birth_ref: birth = self.db.get_event_from_handle(birth_ref.ref) if birth or self.missing_info: self.dump_parent_event(ev_name, birth) death_ref = person.get_death_ref() death = None ev_name = self._("Death") if death_ref: death = self.db.get_event_from_handle(death_ref.ref) if death or self.missing_info: self.dump_parent_event(ev_name, death) self.dump_parent_parents(person) if self.inc_par_events: for event_ref in person.get_primary_event_ref_list(): if event_ref != birth_ref and event_ref != death_ref: event = self.db.get_event_from_handle(event_ref.ref) event_type = self._get_type(event.get_type()) self.dump_parent_event(self._(event_type), event) if self.inc_par_addr: addrlist = person.get_address_list()[:] for addr in addrlist: location = utils.get_address_str(addr) date = self._get_date(addr.get_date_object()) self.doc.start_row() self.doc.start_cell("FGR-TextContents") self.doc.start_paragraph('FGR-Normal') self.doc.write_text(self._("Address")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("FGR-TextContents") self.doc.start_paragraph('FGR-Normal') self.doc.write_text(date) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("FGR-TextContentsEnd") self.doc.start_paragraph('FGR-Normal') self.doc.write_text(location) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() if self.inc_par_notes: for notehandle in person.get_note_list(): note = self.db.get_note_from_handle(notehandle) self.dump_parent_noteline(self._("Note"), note) if self.include_attrs: for attr in person.get_attribute_list(): attr_type = self._get_type(attr.get_type()) self.dump_parent_line(self._(attr_type), attr.get_value()) if self.inc_par_names: for alt_name in person.get_alternate_names(): name_type = self._get_type(alt_name.get_type()) name = self._name_display.display_name(alt_name) self.dump_parent_line(self._(name_type), name) self.doc.end_table()