def get_person_age(person, dbstate_db, age_precision): """ Function to get person age. Returns string for age column. """ birth = get_birth_or_fallback(dbstate_db, person) death = get_death_or_fallback(dbstate_db, person) is_dead = False if birth: birth_date = birth.get_date_object() if (birth_date and birth_date.get_valid()): if death: death_date = death.get_date_object() if (death_date and death_date.get_valid()): age = (death_date - birth_date) is_dead = True if not is_dead: # if person is alive age = (Today() - birth_date) # formating age string age_str = age.format(precision=age_precision) if is_dead: gender = person.get_gender() # we get localized "Dead at %s age" if gender == person.MALE: age_str = _("Male person|Dead at %s") % (age_str) elif gender == person.FEMALE: age_str = _("Female person|Dead at %s") % (age_str) else: age_str = _("Unknown gender person|Dead at %s") % (age_str) return age_str return None
def write_person(self, person_handle): """ Write information about the given person. """ person = self.database.get_person_from_handle(person_handle) name = self._name_display.display(person) mark = utils.get_person_mark(self.database, person) birth_date = "" birth = get_birth_or_fallback(self.database, person) if birth: birth_date = self._get_date(birth.get_date_object()) death_date = "" death = get_death_or_fallback(self.database, person) if death: death_date = self._get_date(death.get_date_object()) dates = '' if birth_date or death_date: dates = self._(" (%(birth_date)s - %(death_date)s)" ) % {'birth_date' : birth_date, 'death_date' : death_date} self.doc.start_paragraph('KIN-Normal') self.doc.write_text(name, mark) self.doc.write_text(dates) self.doc.end_paragraph()
def dump_string(self, person, family=None): """ generate a descriptive string for a person """ string = self.__date_place( get_birth_or_fallback(self.database, person)) tmp = self.__date_place( get_death_or_fallback(self.database, person)) if string and tmp: string += ", " string += tmp if string: string = " (" + string + ")" if family and self.showmarriage: tmp = self.__date_place( get_marriage_or_fallback(self.database, family)) if tmp: string += ", " + tmp if family and self.showdivorce: tmp = self.__date_place( get_divorce_or_fallback(self.database, family)) if tmp: string += ", " + tmp if family and self.want_ids: string += ' (%s)' % family.get_gramps_id() self.doc.write_text(string)
def add_birthdate(dbase, ppl_handle_list, rlocale): """ This will sort a list of child handles in birth order For each entry in the list, we'll have : birth date The transtated birth date for the configured locale The transtated death date for the configured locale The handle for the child @param: dbase -- The database to use @param: ppl_handle_list -- the handle for the people @param: rlocale -- the locale for date translation """ sortable_individuals = [] for person_handle in ppl_handle_list: birth_date = 0 # dummy value in case none is found person = dbase.get_person_from_handle(person_handle) if person: birth_ref = person.get_birth_ref() birth1 = "" if birth_ref: birth = dbase.get_event_from_handle(birth_ref.ref) if birth: birth1 = rlocale.get_date(birth.get_date_object()) birth_date = birth.get_date_object().get_sort_value() death_event = get_death_or_fallback(dbase, person) if death_event: death = rlocale.get_date(death_event.get_date_object()) else: death = "" sortable_individuals.append((birth_date, birth1, death, person_handle)) # return a list of handles with the individual's birthdate attached return sortable_individuals
def dump_string(self, person, family=None): string = self.__date_place( get_birth_or_fallback(self.database, person) ) tmp = self.__date_place(get_death_or_fallback(self.database, person)) if string and tmp: string += ", " string += tmp if string: string = " (" + string + ")" if family and self.showmarriage: tmp = self.__date_place(get_marriage_or_fallback(self.database, family)) if tmp: string += ", " + tmp if family and self.showdivorce: tmp = self.__date_place(get_divorce_or_fallback(self.database, family)) if tmp: string += ", " + tmp self.doc.write_text(string)
def write_person(self, person_handle): """ Write information about the given person. """ person = self.database.get_person_from_handle(person_handle) name = self._name_display.display(person) mark = utils.get_person_mark(self.database, person) birth_date = "" birth = get_birth_or_fallback(self.database, person) if birth: birth_date = self._get_date(birth.get_date_object()) death_date = "" death = get_death_or_fallback(self.database, person) if death: death_date = self._get_date(death.get_date_object()) dates = '' if birth_date or death_date: dates = " (%(birth_date)s - %(death_date)s)" % { 'birth_date' : birth_date, 'death_date' : death_date} self.doc.start_paragraph('KIN-Normal') self.doc.write_text(name, mark) self.doc.write_text(dates) self.doc.end_paragraph()
def dump_string(self, person, family=None): """ generate a descriptive string for a person """ string = self.__date_place( get_birth_or_fallback(self.database, person)) tmp = self.__date_place( get_death_or_fallback(self.database, person)) if string and tmp: string += ", " string += tmp if string: string = " (" + string + ")" if family and self.showmarriage: tmp = self.__date_place( get_marriage_or_fallback(self.database, family)) if tmp: string += ", " + tmp if family and self.showdivorce: tmp = self.__date_place( get_divorce_or_fallback(self.database, family)) if tmp: string += ", " + tmp self.doc.write_text(string)
def add_to_tree(self, parent_id, person_handle): person = self.dbstate.db.get_person_from_handle(person_handle) name = name_displayer.display(person) birth = get_birth_or_fallback(self.dbstate.db, person) death = get_death_or_fallback(self.dbstate.db, person) birth_text = birth_date = birth_sort = '' if birth: birth_date = get_date(birth) birth_sort = '%012d' % birth.get_date_object().get_sort_value() birth_text = _('%(abbr)s %(date)s') % \ {'abbr': birth.type.get_abbreviation(), 'date': birth_date} death_date = death_sort = death_text = '' if death: death_date = get_date(death) death_sort = '%012d' % death.get_date_object().get_sort_value() death_text = _('%(abbr)s %(date)s') % \ {'abbr': death.type.get_abbreviation(), 'date': death_date} tooltip = name + '\n' + birth_text + '\n' + death_text item_id = self.model.add([name, birth_date, birth_sort, tooltip, person_handle], node=parent_id) for family_handle in person.get_family_handle_list(): family = self.dbstate.db.get_family_from_handle(family_handle) for child_ref in family.get_child_ref_list(): self.add_to_tree(item_id, child_ref.ref) return item_id
def dump_string(self, person, family=None): """ generate a descriptive string for a person """ string = self.__date_place(get_birth_or_fallback( self.database, person)) tmp = self.__date_place(get_death_or_fallback(self.database, person)) if string and tmp: string += self._(", ") # Arabic OK string += tmp if string: string = " (" + string + ")" if family and self.showmarriage: tmp = self.__date_place( get_marriage_or_fallback(self.database, family)) if tmp: string += self._(", ") + tmp # Arabic OK if family and self.showdivorce: tmp = self.__date_place( get_divorce_or_fallback(self.database, family)) if tmp: string += self._(", ") + tmp # Arabic OK if family and self.want_ids: string += ' (%s)' % family.get_gramps_id() self.doc.write_text(string)
def add_person(self, person): """ Add a person to the Graph. The node id will be the person's gramps id. """ p_id = person.get_gramps_id() name = self._name_display.display(person) birth_evt = get_birth_or_fallback(self.__db, person) if birth_evt: birth = self._get_date(birth_evt.get_date_object()) else: birth = "" death_evt = get_death_or_fallback(self.__db, person) if death_evt: death = self._get_date(death_evt.get_date_object()) else: death = "" if self.includeid == 0: # no ID label = "%s \\n(%s - %s)" % (name, birth, death) elif self.includeid == 1: # same line label = "%s (%s)\\n(%s - %s)" % (name, p_id, birth, death) elif self.includeid == 2: # own line label = "%s \\n(%s - %s)\\n(%s)" % (name, birth, death, p_id) label = label.replace('"', '\\\"') (shape, style, color, fill) = self.get_gender_style(person) self.doc.add_node(p_id, label, shape, color, style, fill)
def add_person(self, person): """ Add a person to the Graph. The node id will be the person's gramps id. """ p_id = person.get_gramps_id() name = self._name_display.display(person) name = name.replace('"', '"') name = name.replace('<', '<').replace('>', '>') birth_evt = get_birth_or_fallback(self.__db, person) if birth_evt: birth = self._get_date(birth_evt.get_date_object()) else: birth = "" death_evt = get_death_or_fallback(self.__db, person) if death_evt: death = self._get_date(death_evt.get_date_object()) else: death = "" if self.includeid == 0: # no ID label = "%s \\n(%s – %s)" % (name, birth, death) elif self.includeid == 1: # same line label = "%s (%s)\\n(%s – %s)" % (name, p_id, birth, death) elif self.includeid == 2: # own line label = "%s \\n(%s – %s)\\n(%s)" % (name, birth, death, p_id) label = label.replace('"', '\\\"') (shape, style, color, fill) = self.get_gender_style(person) self.doc.add_node(p_id, label, shape, color, style, fill)
def find_year_range(self): """ Finds the range of years that will be displayed on the chart. Returns a tuple of low and high years. If no dates are found, the function returns (None, None). """ low = None high = None def min_max_year(low, high, year): """ convenience function """ if year is not None and year != 0: if low is not None: low = min(low, year) else: low = year if high is not None: high = max(high, year) else: high = year return (low, high) with self._user.progress(_('Timeline'), _('Finding date range...'), len(self.plist)) as step: for p_id in self.plist: person = self.database.get_person_from_handle(p_id) birth = get_birth_or_fallback(self.database, person) if birth: bth = birth.get_date_object() bth = bth.to_calendar(self.calendar).get_year() (low, high) = min_max_year(low, high, bth) death = get_death_or_fallback(self.database, person) if death: dth = death.get_date_object() dth = dth.to_calendar(self.calendar).get_year() (low, high) = min_max_year(low, high, dth) step() # round the dates to the nearest decade if low is not None: low = int((low / 10)) * 10 else: low = high if high is not None: high = int(((high + 9) / 10)) * 10 else: high = low # Make sure the difference is a multiple of 50 so # all year ranges land on a decade. if low is not None and high is not None: low -= 50 - ((high - low) % 50) return (low, high)
def get_events(person, sa, all=False): if all: return sa.events(person) else: return [ get_birth_or_fallback(sa.dbase, person), get_death_or_fallback(sa.dbase, person) ]
def get_person_birthdeath(self, person, format=None): def _get_date(date): if date: return get_date(date) birth = _get_date(get_birth_or_fallback(self.database, person, format)) death = _get_date(get_death_or_fallback(self.database, person, format)) result = (birth, death) return result
def column_death_day(self, data): death = get_death_or_fallback(self.db, data) if death: if death.get_type() == EventType.DEATH: return get_date(death) else: return '<i>%s</i>' % escape(get_date(death)) else: return ""
def add_relative(self, handle: Handle, ancestors: int = 1, offspring: int = 1): """Add events for a relative of the anchor person.""" person = self.db_handle.get_person_from_handle(handle) calculator = get_relationship_calculator(reinit=True, clocale=self.locale) calculator.set_depth(self.depth) relationship = calculator.get_one_relationship(self.db_handle, self.anchor_person, person) if self.relative_filters: found = False for relative in self.relative_filters: if relative in relationship: found = True break if not found: return if self.relative_event_filters: for event_ref in person.event_ref_list: event = self.db_handle.get_event_from_handle(event_ref.ref) self.add_event((event, person, relationship), relative=True) event = get_birth_or_fallback(self.db_handle, person) if event: self.add_event((event, person, relationship), relative=True) if person.handle not in self.birth_dates: self.birth_dates.update({person.handle: event.date}) event = get_death_or_fallback(self.db_handle, person) if event: self.add_event((event, person, relationship), relative=True) for family_handle in person.family_list: family = self.db_handle.get_family_from_handle(family_handle) event = get_marriage_or_fallback(self.db_handle, family) if event: self.add_event((event, person, relationship), relative=True) event = get_divorce_or_fallback(self.db_handle, family) if event: self.add_event((event, person, relationship), relative=True) if offspring > 1: for child_ref in family.child_ref_list: self.add_relative(child_ref.ref, offspring=offspring - 1) if ancestors > 1: if "father" in relationship or "mother" in relationship: for family_handle in person.parent_family_list: self.add_family(family_handle, include_children=False, ancestors=ancestors - 1)
def by_person_deathdate_key(self, handle): """Compare by death date, if equal sorts by name.""" obj = self.query_method(handle) death = get_death_or_fallback(self.database, obj) if death: date = death.get_date_object() else: date = Date() return "%08d" % date.get_sort_value() + str( self.by_person_surname_key(handle))
def add_child(self, child): """ Add a child to the model. """ name = name_displayer.display(child) birth = get_birth_or_fallback(self.dbstate.db, child) birth_date, birth_sort, birth_place = self.get_date_place(birth) death = get_death_or_fallback(self.dbstate.db, child) death_date, death_sort, death_place = self.get_date_place(death) self.model.add((child.get_handle(), name, birth_date, birth_sort, death_date, death_sort))
def load_parent(self, handle, name_obj, birth_obj, birth_label, death_obj, death_label, btn_index, btn_add, btn_del, btn_edit): # is a parent used here: is_used = handle is not None # now we display the area: if is_used: db = self.db person = db.get_person_from_handle(handle) name = "%s [%s]" % (name_displayer.display(person), person.gramps_id) birth = get_birth_or_fallback(db, person) self.callman.register_handles({'person': [handle]}) if birth: #if event changes it view needs to update self.callman.register_handles({'event': [birth.get_handle()]}) # translators: needed for French, ignore otherwise birth_label.set_label(_("%s:") % birth.get_type()) death = get_death_or_fallback(db, person) if death: #if event changes it view needs to update self.callman.register_handles({'event': [death.get_handle()]}) # translators: needed for French, ignore otherwise death_label.set_label(_("%s:") % death.get_type()) btn_edit.set_tooltip_text(_('Edit %s') % name) btn_index.hide() btn_add.hide() btn_del.show() btn_edit.show() else: name = "" birth = None death = None btn_index.show() btn_add.show() btn_del.hide() btn_edit.hide() if name_obj: name_obj.set_text(name) if birth: birth_str = displayer.display(birth.get_date_object()) else: birth_str = "" birth_obj.set_text(birth_str) if death: death_str = displayer.display(death.get_date_object()) else: death_str = "" death_obj.set_text(death_str)
def column_death_sort(self, data): """ Return a sort key to use for the death column. As python int can be larger than C int, we cast int to a string of 10 long prepended with 0 as needed. This gives correct string sort for years in the millenia around today """ death = get_death_or_fallback(self.db, data) if death: return '%012d' % death.get_date_object().get_sort_value() else: return '%012d' % 0
def get_death_profile( db_handle: DbReadBase, person: Person, locale: GrampsLocale = glocale) -> Tuple[Dict, Union[Event, None]]: """Return best available death information for a person.""" event = get_death_or_fallback(db_handle, person) if event is None: return {}, None return get_event_profile_for_object(db_handle, event, args=[], locale=locale), event
def format_person_birth_and_death(self, person): text = self.__date_place(get_birth_or_fallback(self.database, person)) tmp = self.__date_place(get_death_or_fallback(self.database, person)) if text and tmp: text += ", " text += tmp if text: text = " (" + text + ")" return text
def format_person_birth_and_death(self, person): text = self.__date_place( get_birth_or_fallback(self.database, person) ) tmp = self.__date_place(get_death_or_fallback(self.database, person)) if text and tmp: text += ", " text += tmp if text: text = " (" + text + ")" return text
def get_date_strings(self, person): "returns tuple of birth/christening and death/burying date strings" birth_event = get_birth_or_fallback(self.database, person) if birth_event: birth = self.get_event_string(birth_event) else: birth = "" death_event = get_death_or_fallback(self.database, person) if death_event: death = self.get_event_string(death_event) else: death = "" return (birth, death)
def add_to_tree(self, depth, parent_id, person_handle): """ Add a person to the tree. """ if depth > config.get('behavior.generation-depth'): return person = self.dbstate.db.get_person_from_handle(person_handle) name = name_displayer.display(person) birth = get_birth_or_fallback(self.dbstate.db, person) death = get_death_or_fallback(self.dbstate.db, person) birth_text = birth_date = birth_sort = '' if birth: birth_date = get_date(birth) birth_sort = '%012d' % birth.get_date_object().get_sort_value() birth_text = _('%(abbr)s %(date)s') % \ {'abbr': birth.type.get_abbreviation(), 'date': birth_date} death_date = death_sort = death_text = '' if death: death_date = get_date(death) death_sort = '%012d' % death.get_date_object().get_sort_value() death_text = _('%(abbr)s %(date)s') % \ {'abbr': death.type.get_abbreviation(), 'date': death_date} tooltip = name + '\n' + birth_text + '\n' + death_text label = _('%(depth)s. %(name)s') % {'depth': depth, 'name': name} item_id = self.model.add( [label, birth_date, birth_sort, tooltip, person_handle], node=parent_id) family_handle = person.get_main_parents_family_handle() if family_handle: family = self.dbstate.db.get_family_from_handle(family_handle) if family: father_handle = family.get_father_handle() if father_handle: self.add_to_tree(depth + 1, item_id, father_handle) mother_handle = family.get_mother_handle() if mother_handle: self.add_to_tree(depth + 1, item_id, mother_handle) return item_id
def death(self, person): """ return "" or the death date of the person """ death = get_death_or_fallback(self.dbstate.db, person) if death and death.get_type() != EventType.DEATH: sdate = get_date(death) if sdate: ddate = "<i>%s</i>" % escape(sdate) else: ddate = "" elif death: ddate = escape(get_date(death)) else: ddate = "" return ddate
def death(self, person): """ return "" or the death date of the person """ death = get_death_or_fallback(self.dbstate.db, person) if death and death.get_type() != EventType.DEATH: sdate = get_date(death) if sdate: ddate = "<i>%s</i>" % cgi.escape(sdate) else: ddate = "" elif death: ddate = cgi.escape(get_date(death)) else: ddate = "" return ddate
def get_event_strings(self, person): "returns tuple of birth/christening and death/burying date strings" birth_date = birth_place = death_date = death_place = "" birth_event = get_birth_or_fallback(self.database, person) if birth_event: birth_date = self.get_date_string(birth_event) birth_place = self.get_place_string(birth_event) death_event = get_death_or_fallback(self.database, person) if death_event: death_date = self.get_date_string(death_event) death_place = self.get_place_string(death_event) return (birth_date, death_date, birth_place, death_place)
def get_person_tooltip(person, database): """ Get Person tooltip string. """ # get birth/christening and death/burying date strings. birth_event = get_birth_or_fallback(database, person) if birth_event: birth = datehandler.get_date(birth_event) else: birth = '' death_event = get_death_or_fallback(database, person) if death_event: death = datehandler.get_date(death_event) else: death = '' # get list of parents. parents = [] parents_list = find_parents(database, person) for parent_id in parents_list: if not parent_id: continue parent = database.get_person_from_handle(parent_id) if not parent: continue parents.append(displayer.display(parent)) # build tooltip string tooltip = '' if birth: tooltip += _('Birth: %s' % birth) if death: if tooltip: tooltip += '\n' tooltip += _('Death: %s' % death) if (birth or death) and parents: tooltip += '\n\n' if parents: tooltip += _('Parents:') for p in parents: tooltip += ('\n %s' % p) return tooltip
def add_to_tree(self, depth, parent_id, person_handle): """ Add a person to the tree. """ if depth > config.get('behavior.generation-depth'): return person = self.dbstate.db.get_person_from_handle(person_handle) name = name_displayer.display(person) birth = get_birth_or_fallback(self.dbstate.db, person) death = get_death_or_fallback(self.dbstate.db, person) birth_text = birth_date = birth_sort = '' if birth: birth_date = get_date(birth) birth_sort = '%012d' % birth.get_date_object().get_sort_value() birth_text = _('%(abbr)s %(date)s') % \ {'abbr': birth.type.get_abbreviation(), 'date': birth_date} death_date = death_sort = death_text = '' if death: death_date = get_date(death) death_sort = '%012d' % death.get_date_object().get_sort_value() death_text = _('%(abbr)s %(date)s') % \ {'abbr': death.type.get_abbreviation(), 'date': death_date} tooltip = name + '\n' + birth_text + '\n' + death_text label = _('%(depth)s. %(name)s') % {'depth': depth, 'name': name} item_id = self.model.add([label, birth_date, birth_sort, tooltip, person_handle], node=parent_id) family_handle = person.get_main_parents_family_handle() if family_handle: family = self.dbstate.db.get_family_from_handle(family_handle) if family: father_handle = family.get_father_handle() if father_handle: self.add_to_tree(depth + 1, item_id, father_handle) mother_handle = family.get_mother_handle() if mother_handle: self.add_to_tree(depth + 1, item_id, mother_handle) return item_id
def info_box(self, handle): if self.vertical: box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) else: box = Gtk.Box() box.set_spacing(6) person = self.dbstate.db.get_person_from_handle(handle) if not person: return box birth = get_birth_or_fallback(self.dbstate.db, person) label1 = widgets.MarkupLabel(self.format_box(birth, EventType.BIRTH)) box.pack_start(label1, False, False, 0) death = get_death_or_fallback(self.dbstate.db, person) label2 = widgets.MarkupLabel(self.format_box(death, EventType.DEATH)) box.pack_start(label2, False, False, 0) return box
def add_person(self, person, sosanumber): """ Add a person to the Graph. The node id will be the person's gramps id. """ p_id = person.get_gramps_id() name = self._name_display.display(person) name = name.replace('"', '"') name = name.replace('<', '<').replace('>', '>') birth_evt = get_birth_or_fallback(self.__db, person) if birth_evt: birth = self._get_date(birth_evt.get_date_object()) else: birth = "" death_evt = get_death_or_fallback(self.__db, person) if death_evt: death = self._get_date(death_evt.get_date_object()) else: death = "" if death: death = " – %s" % death if self.includeid == 0: # no ID label = "%s \\n(%s%s)" % (name, birth, death) elif self.includeid == 1: # same line label = "%s (%s)\\n(%s%s)" % (name, p_id, birth, death) elif self.includeid == 2: # own line label = "%s \\n(%s%s)\\n(%s)" % (name, birth, death, p_id) if self.ahnentafelnum and sosanumber != 0: label +="\\n #%s" % (sosanumber) label = label.replace('"', '\\\"') (shape, style, color, fill) = self.get_gender_style(person) self.doc.add_node(p_id, label, shape, color, style, fill) # save node with them label, father node id, mother node id and sosanumber self.__node_label[p_id] = [label, '', '']
def add_person(self, person): """ Add a person to the Graph. The node id will be the person's gramps id. """ p_id = person.get_gramps_id() name = self._name_display.display(person) birth_evt = get_birth_or_fallback(self.__db, person) if birth_evt: birth = self._get_date(birth_evt.get_date_object()) else: birth = "" death_evt = get_death_or_fallback(self.__db, person) if death_evt: death = self._get_date(death_evt.get_date_object()) else: death = "" label = "%s \\n(%s - %s)" % (name, birth, death) (shape, style, color, fill) = self.get_gender_style(person) self.doc.add_node(p_id, label, shape, color, style, fill)
def getNameAndBirthDeath(self, person): bth_event = get_birth_or_fallback(self._db, person) dth_event = get_death_or_fallback(self._db, person) birthStr = None deathStr = None if bth_event and self._incdates: if not bth_event.private or self._incprivate: date = bth_event.get_date_object() birthStr = '%i' % date.get_year() if dth_event and self._incdates: if not dth_event.private or self._incprivate: date = dth_event.get_date_object() deathStr = '%i' % date.get_year() label = self._name_display.display(person) if birthStr or deathStr: label += ' (' if birthStr: label += '*%s' % birthStr if deathStr: label += '-%s' % deathStr label += ')' return label
def info_string(self, person): birth = get_birth_or_fallback(self.dbstate.db, person) if birth and birth.get_type() != EventType.BIRTH: sdate = get_date(birth) if sdate: bdate = "<i>%s</i>" % escape(sdate) else: bdate = "" elif birth: bdate = escape(get_date(birth)) else: bdate = "" death = get_death_or_fallback(self.dbstate.db, person) if death and death.get_type() != EventType.DEATH: sdate = get_date(death) if sdate: ddate = "<i>%s</i>" % escape(sdate) else: ddate = "" elif death: ddate = escape(get_date(death)) else: ddate = "" if bdate and ddate: value = _("(b. %(birthdate)s, d. %(deathdate)s)") % { 'birthdate' : bdate, 'deathdate' : ddate } elif bdate: value = _("(b. %s)") % (bdate) elif ddate: value = _("(d. %s)") % (ddate) else: value = "" return value
def info_string(self, person): birth = get_birth_or_fallback(self.dbstate.db, person) if birth and birth.get_type() != EventType.BIRTH: sdate = get_date(birth) if sdate: bdate = "<i>%s</i>" % escape(sdate) else: bdate = "" elif birth: bdate = escape(get_date(birth)) else: bdate = "" death = get_death_or_fallback(self.dbstate.db, person) if death and death.get_type() != EventType.DEATH: sdate = get_date(death) if sdate: ddate = "<i>%s</i>" % escape(sdate) else: ddate = "" elif death: ddate = escape(get_date(death)) else: ddate = "" if bdate and ddate: value = _("(b. %(birthdate)s, d. %(deathdate)s)") % { 'birthdate': bdate, 'deathdate': ddate } elif bdate: value = _("(b. %s)") % (bdate) elif ddate: value = _("(d. %s)") % (ddate) else: value = "" return value
def get_events(person, sa, all=False): if all: return sa.events(person) else: return [get_birth_or_fallback(sa.dbase, person), get_death_or_fallback(sa.dbase, person)]
def listpersonref(self): sc = {'source': 'S_ID', 'citalist': 'C_ID'} stc = {} citation_without_notes = 0 EMPTY = " " def toYear(date): yeartext = date.get_year() return yeartext genderlist = ['w', 'm', 'u'] self.doc.start_paragraph("SRC-SourceTitle") self.doc.write_text(_("Person with Citations")) self.doc.end_paragraph() self.doc.start_table("VISONETable", "SRC-VISONETable") column_titles = [ _("Gramps_ID"), _("Gramps_ID"), _("LNr"), _("Birthdate"), _("Deathdate"), _("Birthyear"), _("Deathyear"), _("Age on Death"), _("gender"), _("Name"), _("Surname"), _("LabelID"), _("LabelGT"), _("Clan"), _("Birth Place"), _("Death Place"), _("Birth Country"), _("Death Country"), _("Birth Lat"), _("Birth Lon") ] i = 0 self.doc.start_row() for title in column_titles: self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(title) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() i = 0 ii = 0 pe_list = [] for pe in self.__db.get_person_handles(): pe_index = [self.__db.get_person_from_handle(pe).gramps_id, pe] pe_list.append(pe_index) with self._user.progress(_("VIS ATTR Report"), _("Generating report"), len(pe_list)) as step: for pedet in sorted(pe_list, key=lambda t: (t[1])): # for pe in self.__db.get_person_handles(sort_handles=True): i += 1 # increment progress bar step() # print (i, pedet) person = self.__db.get_person_from_handle(pedet[1]) birth = get_birth_or_fallback(self.__db, person) birth_date, birth_sort, birth_place = self.get_date_place( birth) birth_country = _pd.display_event(self.__db, birth, fmt=self.place_fmt) print(birth_country, fmt, fmt.levels) death = get_death_or_fallback(self.__db, person) death_date, death_sort, death_place = self.get_date_place( death) death_country = _pd.display_event(self.__db, death, fmt=self.place_fmt) age = get_age(self.__db, person) birth_year = "" death_year = "" if birth: birth_year = birth.get_date_object().get_year() if death: death_year = death.get_date_object().get_year() self.doc.start_row() # Person ID self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % person.gramps_id) self.doc.end_paragraph() self.doc.end_cell() # Person ID 2nd time self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % person.gramps_id) self.doc.end_paragraph() self.doc.end_cell() # LNR self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % i) self.doc.end_paragraph() self.doc.end_cell() # Birth Date self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") birth = get_birth_or_fallback(self.__db, person) self.doc.write_text(_(" %s") % birth_date) self.doc.end_paragraph() self.doc.end_cell() # Death Date self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_(" %s") % death_date) self.doc.end_paragraph() self.doc.end_cell() # Birth year self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_(" %s") % birth_year) self.doc.end_paragraph() self.doc.end_cell() # Death year self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_(" %s") % death_year) self.doc.end_paragraph() self.doc.end_cell() # Age on death self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-SourceDetails") if age: if age[0] > 0: self.doc.write_text(_("%s") % age[0]) else: if age[1] > 0: self.doc.write_text(_("%s M.") % age[1]) else: if age[2] > 0: self.doc.write_text(_("%s T.") % age[2]) self.doc.end_paragraph() self.doc.end_cell() # Person gender self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % genderlist[person.gender]) self.doc.end_paragraph() self.doc.end_cell() # Person Name self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text( _("%s") % person.get_primary_name().get_regular_name()) self.doc.end_paragraph() self.doc.end_cell() # Person Surname, givenname self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text( _("%s") % person.get_primary_name().get_name()) self.doc.end_paragraph() self.doc.end_cell() # Label Name (ID) self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") label = "" label = _(" %s") % person.get_primary_name().get_regular_name() label = label + _(" [%s]") % person.gramps_id self.doc.write_text(_("%s") % label) self.doc.end_paragraph() self.doc.end_cell() # Label Name (geb-to) self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") label = "" label = _(" %s") % person.get_primary_name().get_regular_name() label = label + _(" (%s") % birth_year label = label + _("-%s)") % death_year if label[-3:] == "(-)": label = label[:-3] self.doc.write_text(_("%s") % label) self.doc.end_paragraph() self.doc.end_cell() # Clan Name self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % self.find_clan(pe)) self.doc.end_paragraph() self.doc.end_cell() #Place of birth self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % birth_place) self.doc.end_paragraph() self.doc.end_cell() #Place of death self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % death_place) self.doc.end_paragraph() self.doc.end_cell() #Country of birth self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % birth_country) self.doc.end_paragraph() self.doc.end_cell() #Country of death self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % death_country) # death_country[4:]) self.doc.end_paragraph() self.doc.end_cell() #Latitude of Place of Birth self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") lat_txt = "" lon_txt = "" if birth: lat_txt, lon_txt = self.find_place_lat_lon(birth) self.doc.write_text(_("%s") % lat_txt) self.doc.end_paragraph() self.doc.end_cell() #Longitude of Place of Birth self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") lat_txt = "" lon_txt = "" if birth: lat_txt, lon_txt = self.find_place_lat_lon(birth) self.doc.write_text(_("%s") % lon_txt) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() self.doc.end_table()
def generate_timeline(self, low, high): """ generate the timeline """ st_size = self.name_size() style_sheet = self.doc.get_style_sheet() font = style_sheet.get_paragraph_style('TLG-Name').get_font() incr = utils.pt2cm(font.get_size()) pad = incr * 0.75 _x1, _x2, _y1, _y2 = (0, 0, 0, 0) start = st_size + 0.5 stop = self.doc.get_usable_width() - 0.5 size = stop - start self.header = 2.6 # Sort the people as requested with self._user.progress(_('Timeline'), _('Sorting dates...'), 0) as step: self.plist.sort(key=self.sort_func) self.doc.start_page() self.build_grid(low, high, start, stop, True) index = 1 current = 1 length = len(self.plist) with self._user.progress(_('Timeline'), _('Calculating timeline...'), length) as step: for p_id in self.plist: person = self.database.get_person_from_handle(p_id) birth = get_birth_or_fallback(self.database, person) if birth: bth = birth.get_date_object() bth = bth.to_calendar(self.calendar).get_year() else: bth = None death = get_death_or_fallback(self.database, person) if death: dth = death.get_date_object() dth = dth.to_calendar(self.calendar).get_year() else: dth = None dname = self._name_display.display(person) mark = utils.get_person_mark(self.database, person) self.doc.draw_text('TLG-text', dname, incr + pad, self.header + (incr + pad) * index, mark) _y1 = self.header + (pad + incr) * index _y2 = self.header + ((pad + incr) * index) + incr _y3 = (_y1 + _y2) / 2.0 w05 = 0.05 if bth: start_offset = ((float(bth - low) / float(high - low)) * size) _x1 = start + start_offset path = [(_x1, _y1), (_x1 + w05, _y3), (_x1, _y2), (_x1 - w05, _y3)] self.doc.draw_path('TLG-line', path) if dth: start_offset = ((float(dth - low) / float(high - low)) * size) _x1 = start + start_offset path = [(_x1, _y1), (_x1 + w05, _y3), (_x1, _y2), (_x1 - w05, _y3)] self.doc.draw_path('TLG-solid', path) if bth and dth: start_offset = ((float(bth - low) / float(high - low)) * size) + w05 stop_offset = ((float(dth - low) / float(high - low)) * size) - w05 _x1 = start + start_offset _x2 = start + stop_offset self.doc.draw_line('open', _x1, _y3, _x2, _y3) if (_y2 + incr) >= self.doc.get_usable_height(): if current != length: self.doc.end_page() self.doc.start_page() self.build_grid(low, high, start, stop) index = 1 _x1, _x2, _y1, _y2 = (0, 0, 0, 0) else: index += 1 current += 1 step() self.doc.end_page()
def get_info(self, person_handle, generation): """ get info about a person """ person = self.database.get_person_from_handle(person_handle) p_pn = person.get_primary_name() self.calendar = config.get('preferences.calendar-format-report') birth = get_birth_or_fallback(self.database, person) bth = "" if birth: bth = birth.get_date_object() bth = str(bth.to_calendar(self.calendar).get_year()) if bth == 0: bth = "" elif birth.get_type() != EventType.BIRTH: bth += '*' death = get_death_or_fallback(self.database, person) dth = "" if death: dth = death.get_date_object() dth = str(dth.to_calendar(self.calendar).get_year()) if dth == 0: dth = "" elif death.get_type() != EventType.DEATH: dth += '*' if bth and dth: val = "%s - %s" % (str(bth), str(dth)) elif bth: val = "* %s" % (str(bth)) elif dth: val = "+ %s" % (str(dth)) else: val = "" if generation > 7: if (p_pn.get_first_name() != "") and (p_pn.get_surname() != ""): name = p_pn.get_first_name() + " " + p_pn.get_surname() else: name = p_pn.get_first_name() + p_pn.get_surname() if (name != "") and (val != ""): string = name + ", " + val else: string = name + val return [string] elif generation == 7: if (p_pn.get_first_name() != "") and (p_pn.get_surname() != ""): name = p_pn.get_first_name() + " " + p_pn.get_surname() else: name = p_pn.get_first_name() + p_pn.get_surname() if self.circle == FULL_CIRCLE: return [name, val] elif self.circle == HALF_CIRCLE: return [name, val] else: if (name != "") and (val != ""): string = name + ", " + val else: string = name + val return [string] elif generation == 6: if self.circle == FULL_CIRCLE: return [p_pn.get_first_name(), p_pn.get_surname(), val] elif self.circle == HALF_CIRCLE: return [p_pn.get_first_name(), p_pn.get_surname(), val] else: if (p_pn.get_first_name() != "") and (p_pn.get_surname() != ""): name = p_pn.get_first_name() + " " + p_pn.get_surname() else: name = p_pn.get_first_name() + p_pn.get_surname() return [name, val] else: return [p_pn.get_first_name(), p_pn.get_surname(), val]
def write_people(self): """ write the people """ self.doc.add_comment('') # If we're going to attempt to include images, then use the HTML style # of .gv file. use_html_output = False if self._incimages: use_html_output = True # loop through all the people we need to output for handle in sorted(self._people): # enable a diff person = self._db.get_person_from_handle(handle) name = self._name_display.display(person) p_id = person.get_gramps_id() # figure out what colour to use gender = person.get_gender() colour = self._colorunknown if gender == Person.MALE: colour = self._colormales elif gender == Person.FEMALE: colour = self._colorfemales # see if we have surname colours that match this person surname = person.get_primary_name().get_surname() surname = surname.encode('iso-8859-1', 'xmlcharrefreplace') if surname in self._surnamecolors: colour = self._surnamecolors[surname] # see if we have a birth/death or fallback dates we can use if self._incdates or self._incplaces: bth_event = get_birth_or_fallback(self._db, person) dth_event = get_death_or_fallback(self._db, person) else: bth_event = None dth_event = None # output the birth or fallback event birth_str = None if bth_event and self._incdates: date = bth_event.get_date_object() if self._just_years and date.get_year_valid(): birth_str = self._get_date( # localized year Date(date.get_year())) else: birth_str = self._get_date(date) # get birth place (one of: hamlet, village, town, city, parish, # county, province, region, state or country) birthplace = None if bth_event and self._incplaces: birthplace = self.get_event_place(bth_event) # see if we have a deceased date we can use death_str = None if dth_event and self._incdates: date = dth_event.get_date_object() if self._just_years and date.get_year_valid(): death_str = self._get_date( # localized year Date(date.get_year())) else: death_str = self._get_date(date) # get death place (one of: hamlet, village, town, city, parish, # county, province, region, state or country) deathplace = None if dth_event and self._incplaces: deathplace = self.get_event_place(dth_event) # see if we have an image to use for this person image_path = None if self._incimages: media_list = person.get_media_list() if len(media_list) > 0: media_handle = media_list[0].get_reference_handle() media = self._db.get_media_from_handle(media_handle) media_mime_type = media.get_mime_type() if media_mime_type[0:5] == "image": image_path = get_thumbnail_path( media_path_full(self._db, media.get_path()), rectangle=media_list[0].get_rectangle(), size=self._imagesize) # put the label together and output this person label = "" line_delimiter = '\\n' if use_html_output: line_delimiter = '<BR/>' # if we have an image, then start an HTML table; # remember to close the table afterwards! if image_path: label = ('<TABLE BORDER="0" CELLSPACING="2" CELLPADDING="0" ' 'CELLBORDER="0"><TR><TD><IMG SRC="%s"/></TD>' % image_path) if self._imageonside == 0: label += '</TR><TR>' label += '<TD>' # at the very least, the label must have the person's name name = name.replace('"', '"') label += name.replace('<', '<').replace('>', '>') if self.includeid == 1: # same line label += " (%s)" % p_id elif self.includeid == 2: # own line label += "%s(%s)" % (line_delimiter, p_id) if birth_str or death_str: label += '%s(' % line_delimiter if birth_str: label += '%s' % birth_str label += ' – ' if death_str: label += '%s' % death_str label += ')' if birthplace or deathplace: if birthplace == deathplace: deathplace = None # no need to print the same name twice label += '%s' % line_delimiter if birthplace: label += '%s' % birthplace if birthplace and deathplace: label += ' / ' if deathplace: label += '%s' % deathplace # see if we have a table that needs to be terminated if image_path: label += '</TD></TR></TABLE>' else: # non html label is enclosed by "" so escape other " label = label.replace('"', '\\\"') shape = "box" style = "solid" border = colour fill = colour # do not use colour if this is B&W outline if self._colorize == 'outline': border = "" fill = "" if gender == person.FEMALE and ("f" in self._useroundedcorners): style = "rounded" elif gender == person.MALE and ("m" in self._useroundedcorners): style = "rounded" elif gender == person.UNKNOWN: shape = "hexagon" # if we're filling the entire node: if self._colorize == 'filled': style += ",filled" border = "" # we're done -- add the node self.doc.add_node(p_id, label=label, shape=shape, color=border, style=style, fillcolor=fill, htmloutput=use_html_output)
def parse_format(self): """Parse the $ variables. """ if not self.is_a(): return attrib_parse = AttributeParse(self._in) next_char = self._in.next self._in.step2() if PRIVACY: # only parse Events as the other standard parsers do NOT check privacy if next_char == "e": #person event return self.__parse_an_event(self.friend.person, attrib_parse) elif next_char == "t": #family event return self.__parse_an_event(self.friend.family, attrib_parse) else: if next_char == "n": #Person's name return self.__parse_name(self.friend.person) elif next_char == "s": #Souses name return self.__parse_name(self.friend.spouse) elif next_char == "i": #Person's Id return self.__parse_id(self.friend.person) elif next_char == "j": #Marriage Id return self.__parse_id(self.friend.family) elif next_char == "b": #Person's Birth date if self.empty_item(self.friend.person): return return self.__parse_date( get_birth_or_fallback(self.friend.database, self.friend.person)) elif next_char == "d": #Person's Death date if self.empty_item(self.friend.person): return return self.__parse_date( get_death_or_fallback(self.friend.database, self.friend.person)) elif next_char == "m": #Marriage date if self.empty_item(self.friend.family): return return self.__parse_date( self.get_event_by_type(self.friend.family, EventType.MARRIAGE)) elif next_char == "v": #Divorce date if self.empty_item(self.friend.family): return return self.__parse_date( self.get_event_by_type(self.friend.family, EventType.DIVORCE)) elif next_char == "T": #Todays date date_f = DateFormat(self._in) from gramps.gen.lib.date import Today date = Today() if self.empty_item(date): return return date_f.parse_format(date) elif next_char == "B": #Person's birth place if self.empty_item(self.friend.person): return return self.__parse_place( get_birth_or_fallback(self.friend.database, self.friend.person)) elif next_char == "D": #Person's death place if self.empty_item(self.friend.person): return return self.__parse_place( get_death_or_fallback(self.friend.database, self.friend.person)) elif next_char == "M": #Marriage place if self.empty_item(self.friend.family): return return self.__parse_place( self.get_event_by_type(self.friend.family, EventType.MARRIAGE)) elif next_char == "V": #Divorce place if self.empty_item(self.friend.family): return return self.__parse_place( self.get_event_by_type(self.friend.family, EventType.DIVORCE)) elif next_char == "a": #Person's Atribute if self.empty_attribute(self.friend.person): return return attrib_parse.parse_format( self.friend.person.get_attribute_list()) elif next_char == "u": #Marriage Atribute if self.empty_attribute(self.friend.family): return return attrib_parse.parse_format( self.friend.family.get_attribute_list()) elif next_char == "e": #person event return self.__parse_an_event(self.friend.person, attrib_parse) elif next_char == "t": #family event return self.__parse_an_event(self.friend.family, attrib_parse) elif next_char == 'p': #photo for the person return self.__parse_photo(self.friend.person) elif next_char == 'P': #photo for the marriage return self.__parse_photo(self.friend.family) elif next_char == "G": gramps_format = GrampsFormat(self._in, self.database) return gramps_format.parse_format()
def listpersonref(self): sc = {'source': 'S_ID', 'citalist': 'C_ID' } stc = {} citation_without_notes = 0 EMPTY = " " def toYear(date): yeartext = date.get_year() return yeartext # genderlist = ['w','m'] genderlist = ['w','m','u'] self.doc.start_paragraph("SRC-SourceTitle") self.doc.write_text(_("Person with Citations")) self.doc.end_paragraph() self.doc.start_table("VISONETable", "SRC-VISONETable") column_titles = [_("Gramps_ID"), _("Gramps_ID"), _("LNr"), _("Birthdate"), _("Deathdate"),_("Birthyear"), _("Deathyear"), _("Age on Death"), _("gender"), _("Name"), _("Surname"),_("LabelID"),_("LabelGT"),_("Clan"),_("Birth Place"),_("Death Place"),_("Birth Country"),_("Death Country"),_("Birth Lat"),_("Birth Lon")] i = 0 self.doc.start_row() for title in column_titles: self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(title) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() i=0 ii=0 pe_list =[] for pe in self.__db.get_person_handles(): pe_index = [ self.__db.get_person_from_handle(pe).gramps_id, pe] pe_list.append(pe_index) with self._user.progress(_("VIS ATTR Report"), _("Generating report"), len(pe_list)) as step: for pedet in sorted(pe_list, key=lambda t: (t[1])): # for pe in self.__db.get_person_handles(sort_handles=True): i += 1 # increment progress bar step() # print (i, pedet) person = self.__db.get_person_from_handle(pedet[1]) birth = get_birth_or_fallback(self.__db, person) birth_date, birth_sort, birth_place = self.get_date_place(birth) birth_country = place_displayer.display_event(self.__db, birth, "country") death = get_death_or_fallback(self.__db, person) death_date, death_sort, death_place = self.get_date_place(death) death_country = place_displayer.display_event(self.__db, death, "country") age = get_age(self.__db, person) birth_year = "" death_year = "" if birth: birth_year = birth.get_date_object().get_year() if death: death_year = death.get_date_object().get_year() self.doc.start_row() # Person ID self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % person.gramps_id) self.doc.end_paragraph() self.doc.end_cell() # Person ID 2nd time self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % person.gramps_id) self.doc.end_paragraph() self.doc.end_cell() # LNR self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % i) self.doc.end_paragraph() self.doc.end_cell() # Birth Date self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") birth = get_birth_or_fallback(self.__db, person) self.doc.write_text(_(" %s") % birth_date) self.doc.end_paragraph() self.doc.end_cell() # Death Date self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_(" %s") % death_date) self.doc.end_paragraph() self.doc.end_cell() # Birth year self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_(" %s") % birth_year) self.doc.end_paragraph() self.doc.end_cell() # Death year self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_(" %s") % death_year) self.doc.end_paragraph() self.doc.end_cell() # Age on death self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-SourceDetails") if age: if age[0]>0: self.doc.write_text(_("%s") % age[0]) else: if age[1]>0: self.doc.write_text(_("%s M.") % age[1]) else: if age[2]>0: self.doc.write_text(_("%s T.") % age[2]) self.doc.end_paragraph() self.doc.end_cell() # Person gender self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % genderlist[person.gender]) self.doc.end_paragraph() self.doc.end_cell() # Person Name self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % person.get_primary_name().get_regular_name()) self.doc.end_paragraph() self.doc.end_cell() # Person Surname, givenname self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % person.get_primary_name().get_name()) self.doc.end_paragraph() self.doc.end_cell() # Label Name (ID) self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") label ="" label = _(" %s") % person.get_primary_name().get_regular_name() label = label + _(" [%s]") % person.gramps_id self.doc.write_text(_("%s") % label) self.doc.end_paragraph() self.doc.end_cell() # Label Name (geb-to) self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") label ="" label = _(" %s") % person.get_primary_name().get_regular_name() label = label + _(" (%s") % birth_year label = label + _("-%s)") % death_year if label[-3:] == "(-)": label =label[:-3] self.doc.write_text(_("%s") % label) self.doc.end_paragraph() self.doc.end_cell() # Clan Name self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % self.find_clan(pe)) self.doc.end_paragraph() self.doc.end_cell() #Place of birth self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % birth_place) self.doc.end_paragraph() self.doc.end_cell() #Place of death self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % death_place) self.doc.end_paragraph() self.doc.end_cell() #Country of birth self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % birth_country) self.doc.end_paragraph() self.doc.end_cell() #Country of death self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") self.doc.write_text(_("%s") % death_country) # death_country[4:]) self.doc.end_paragraph() self.doc.end_cell() #Latitude of Place of Birth self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") lat_txt ="" lon_txt ="" if birth: lat_txt, lon_txt = self.find_place_lat_lon(birth) self.doc.write_text(_("%s") % lat_txt) self.doc.end_paragraph() self.doc.end_cell() #Longitude of Place of Birth self.doc.start_cell("SRC-Cell") self.doc.start_paragraph("SRC-SourceDetails") lat_txt ="" lon_txt ="" if birth: lat_txt, lon_txt = self.find_place_lat_lon(birth) self.doc.write_text(_("%s") % lon_txt) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() self.doc.end_table()
def generate_timeline(self, low, high): st_size = self.name_size() style_sheet = self.doc.get_style_sheet() font = style_sheet.get_paragraph_style('TLG-Name').get_font() incr = pt2cm(font.get_size()) pad = incr * 0.75 x1,x2,y1,y2 = (0, 0, 0, 0) start = st_size + 0.5 stop = self.doc.get_usable_width() - 0.5 size = (stop - start) self.header = 2.0 # Sort the people as requested with self._user.progress(_('Timeline'), _('Sorting dates...'), 0) as step: self.plist.sort(key=self.sort_func) self.doc.start_page() self.build_grid(low, high, start, stop, True) index = 1 current = 1; length = len(self.plist) with self._user.progress(_('Timeline'), _('Calculating timeline...'), length) as step: for p_id in self.plist: p = self.database.get_person_from_handle(p_id) birth = get_birth_or_fallback(self.database, p) if birth: b = birth.get_date_object().to_calendar(self.calendar).get_year() else: b = None death = get_death_or_fallback(self.database, p) if death: d = death.get_date_object().to_calendar(self.calendar).get_year() else: d = None n = self._name_display.display(p) mark = ReportUtils.get_person_mark(self.database, p) self.doc.draw_text('TLG-text', n, incr+pad, self.header + (incr+pad)*index, mark) y1 = self.header + (pad+incr)*index y2 = self.header + ((pad+incr)*index)+incr y3 = (y1+y2)/2.0 w = 0.05 if b: start_offset = ((float(b-low)/float(high-low)) * (size)) x1 = start+start_offset path = [(x1,y1),(x1+w,y3),(x1,y2),(x1-w,y3)] self.doc.draw_path('TLG-line',path) if d: start_offset = ((float(d-low)/float(high-low)) * (size)) x1 = start+start_offset path = [(x1,y1),(x1+w,y3),(x1,y2),(x1-w,y3)] self.doc.draw_path('TLG-solid',path) if b and d: start_offset = ((float(b-low)/float(high-low)) * size) + w stop_offset = ((float(d-low)/float(high-low)) * size) - w x1 = start+start_offset x2 = start+stop_offset self.doc.draw_line('open',x1,y3,x2,y3) if (y2 + incr) >= self.doc.get_usable_height(): if current != length: self.doc.end_page() self.doc.start_page() self.build_grid(low, high,start,stop) index = 1 x1,x2,y1,y2 = (0,0,0,0) else: index += 1; current += 1 step() self.doc.end_page()
def get_info(self, person_handle, generation): person = self.database.get_person_from_handle(person_handle) pn = person.get_primary_name() self.calendar = config.get("preferences.calendar-format-report") birth = get_birth_or_fallback(self.database, person) b = "" if birth: b = str(birth.get_date_object().to_calendar(self.calendar).get_year()) if b == 0: b = "" elif birth.get_type() != EventType.BIRTH: b += "*" death = get_death_or_fallback(self.database, person) d = "" if death: d = str(death.get_date_object().to_calendar(self.calendar).get_year()) if d == 0: d = "" elif death.get_type() != EventType.DEATH: d += "*" if b and d: val = "%s - %s" % (str(b), str(d)) elif b: val = "* %s" % (str(b)) elif d: val = "+ %s" % (str(d)) else: val = "" if generation > 7: if (pn.get_first_name() != "") and (pn.get_surname() != ""): name = pn.get_first_name() + " " + pn.get_surname() else: name = pn.get_first_name() + pn.get_surname() if (name != "") and (val != ""): string = name + ", " + val else: string = name + val return [string] elif generation == 7: if (pn.get_first_name() != "") and (pn.get_surname() != ""): name = pn.get_first_name() + " " + pn.get_surname() else: name = pn.get_first_name() + pn.get_surname() if self.circle == FULL_CIRCLE: return [name, val] elif self.circle == HALF_CIRCLE: return [name, val] else: if (name != "") and (val != ""): string = name + ", " + val else: string = name + val return [string] elif generation == 6: if self.circle == FULL_CIRCLE: return [pn.get_first_name(), pn.get_surname(), val] elif self.circle == HALF_CIRCLE: return [pn.get_first_name(), pn.get_surname(), val] else: if (pn.get_first_name() != "") and (pn.get_surname() != ""): name = pn.get_first_name() + " " + pn.get_surname() else: name = pn.get_first_name() + pn.get_surname() return [name, val] else: return [pn.get_first_name(), pn.get_surname(), val]
def __write_data(self): """ This procedure writes out each of the families related to the place """ i = 0 iw = 0 ifam = 0 p_set=set() pdet_list=[] QUAL_ESTIMATED = 1 gender_dict ={0:"w",1:"m", 2:"u"} for person in self.database.iter_people(): birth_event = get_birth_or_fallback(self.database, person) b_year = 0 alt_tod = 0 b_role = "ROLLE" if birth_event: if birth_event.get_place_handle() in self.place_handles: birth_obj = birth_event.get_date_object() if birth_obj.get_quality() is not QUAL_ESTIMATED: place_d = place_displayer.display_event(self.database, birth_event) person_name = person.get_primary_name().get_surname() person_ID = person.get_gramps_id() gender = gender_dict[person.get_gender()] m_date = self._get_date(birth_obj) # if birth_obj.get_quality() is not QUAL_ESTIMATED: b_year = birth_obj.get_year() # b_role = "ROLLE "+ str(birth_event.role) # b_place = death_event = get_death_or_fallback(self.database, person) d_year = 0 if death_event: death_obj = death_event.get_date_object() # if death_obj.get_quality() is not QUAL_ESTIMATED: d_year = death_obj.get_year() alt_tod = d_year - b_year m_year = 0 alt_marr = 0 m_list=[] # m_date = "" m_wm = "WEIT" for family_handle in person.get_family_handle_list(): # print(family_handle) family = self.database.get_family_from_handle(family_handle) for fam_event_ref in family.get_event_ref_list(): # print(fam_event_ref) if fam_event_ref: fam_event = self.database.get_event_from_handle(fam_event_ref.ref) if fam_event.type == EventType.MARRIAGE: print(fam_event.type) m_list.append(fam_event.get_date_object().get_year()) # print(fam_event.get_date_object().get_year()) # m_year = fam_event.get_date_object().get_year() if len(m_list)>0: m_year = min(m_list) alt_marr = m_year - b_year # else: # m_year = 0 for m in m_list: m_wm = m_wm+" "+str(m) # person_details = [ person, person_name, person_ID, gender, b_year, d_year, m_year, b_role, m_date, diff,place_d] person_details = [ person, person_name, person_ID, gender, b_year, d_year, m_year, m_date, m_wm, alt_tod, alt_marr, place_d] pdet_list.append(person_details) i=1 for pn in pdet_list: self.doc.start_row() # self.doc.start_cell("SRC-TableColumn") # self.doc.start_paragraph("SRC-ColumnTitle") # ST = "PN"+ str(pn[0]) # self.doc.write_text(_("%s") % ST) # # self.doc.write_text(_("Hallo0")) # self.doc.end_paragraph() # self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[1]) # self.doc.write_text(_("Hallo1")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[2]) # self.doc.write_text(_("Hallo2")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[3]) # self.doc.write_text(_("Hallo3")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[4]) # self.doc.write_text(_("Hallo4")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[5]) # self.doc.write_text(_("Hallo5")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[6]) # self.doc.write_text(_("Hallo6")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[7]) # self.doc.write_text(_("Hallo7")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[8]) # self.doc.write_text(_("Hallo8")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[9]) # self.doc.write_text(_("Hallo9")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") # diff= pn[6] - pn[4] self.doc.write_text(_("%s") % pn[10]) # self.doc.write_text(diff) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % pn[11]) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell("SRC-TableColumn") self.doc.start_paragraph("SRC-ColumnTitle") self.doc.write_text(_("%s") % i) # self.doc.write_text(i) # self.doc.write_text(_("LNR")) self.doc.end_paragraph() self.doc.end_cell() i +=1 self.doc.end_row()