def marriage_place(self, person): """ Return a string describing the place where the person and his/her spouse where married. @param person: Person object @type person: L{gen.lib.Person} @return: Returns a string describing the place where the person and his/her spouse where married. @rtype: unicode """ if type(person) in [str, unicode]: person = self.dbase.get_person_from_handle(person) assert(isinstance(person, (gen.lib.Person, NoneType))) if person: family_handle_list = person.get_family_handle_list() if family_handle_list: family_id = family_handle_list[0] family = self.dbase.get_family_from_handle(family_id) if family: reflist = family.get_event_ref_list() if reflist: elist = [ self.dbase.get_event_from_handle(ref.ref) for ref in reflist ] events = [ evnt for evnt in elist if event.type == EventType.MARRIAGE ] if events: place_handle = events[0].get_place_handle() return place_name(self.dbase, place_handle) return u''
def display(self, object_class, prop, value): """ Given a object_class, prop, and value return a display string describing object. object_class is "Person", "Source", etc. prop is "gramps_id", or "handle" value is a gramps_id or handle. """ if object_class in self.dbase.get_table_names(): obj = self.dbase.get_table_metadata(object_class)\ [prop + "_func"](value) if obj: if isinstance(obj, gen.lib.Person): return "%s: %s [%s]" % (_(object_class), self.name(obj), self.gid(obj)) elif isinstance(obj, gen.lib.Event): return "%s: %s [%s]" % (_(object_class), self.event_type(obj), self.gid(obj)) elif isinstance(obj, gen.lib.Family): return "%s: %s/%s [%s]" % (_(object_class), self.name(self.mother(obj)), self.name(self.father(obj)), self.gid(obj)) elif isinstance(obj, gen.lib.MediaObject): return "%s: %s [%s]" % (_(object_class), obj.desc, self.gid(obj)) elif isinstance(obj, gen.lib.Source): return "%s: %s [%s]" % (_(object_class), self.title(obj), self.gid(obj)) elif isinstance(obj, gen.lib.Citation): return "%s: [%s]" % (_(object_class), self.gid(obj)) elif isinstance(obj, gen.lib.Place): return "%s: %s [%s]" % (_(object_class), place_name(self.dbase, obj.handle), self.gid(obj)) elif isinstance(obj, gen.lib.Repository): return "%s: %s [%s]" % (_(object_class), obj.type, self.gid(obj)) elif isinstance(obj, gen.lib.Note): return "%s: %s [%s]" % (_(object_class), obj.type, self.gid(obj)) else: return "Error: incorrect object class: '%s'" % type(obj) else: return "Error: missing object" else: return "Error: invalid object class: '%s'" % object_class
def dump_parent_event(self, name, event): place = "" date = "" descr = "" if event: date = DateHandler.get_date(event) place_handle = event.get_place_handle() place = ReportUtils.place_name(self.database, place_handle) descr = event.get_description() if self.includeAttrs: for attr in event.get_attribute_list(): if descr: # translators: needed for Arabic, ignore otherwise descr += self._("; ") descr += _("%(type)s: %(value)s") % { 'type': attr.get_type(), 'value': attr.get_value() } self.doc.start_row() self.doc.start_cell("FGR-TextContents") self.doc.start_paragraph('FGR-Normal') self.doc.write_text(name) self.doc.end_paragraph() self.doc.end_cell() if descr: self.doc.start_cell("FGR-TextContentsEnd", 2) self.doc.start_paragraph('FGR-Normal') self.doc.write_text(descr) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() if date or place: self.doc.start_row() self.doc.start_cell("FGR-TextContents") self.doc.start_paragraph('FGR-Normal') self.doc.end_paragraph() self.doc.end_cell() if (date or place) or not descr: 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(place) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row()
def event_place(self, event): """ Return a string indicating the place of the event @param event: Event object @type event: L{gen.lib.Event} @return: Returns a string indicating the place of the event @rtype: unicode """ assert(isinstance(event, (gen.lib.Event, NoneType))) if event: place_handle = event.get_place_handle() return place_name(self.dbase, place_handle) else: return u''
def __event_place(self, person, func): """ Return a string describing the place associated with the person @param person: Person object @type person: L{gen.lib.Person} @param func: function used to extract the associated place information @type func: function @return: Returns a string describing the place @rtype: unicode """ assert(isinstance(person, (gen.lib.Person, NoneType))) if person: ref = func(person) if ref: event_handle = ref.get_reference_handle() if event_handle: event = self.dbase.get_event_from_handle(event_handle) place_handle = event.get_place_handle() return place_name(self.dbase, place_handle) return u''
def describe(self, obj): """ Given a object, return a string describing the object. """ if isinstance(obj, gen.lib.Person): return self.name(obj) elif isinstance(obj, gen.lib.Event): return self.event_type(obj) elif isinstance(obj, gen.lib.Family): father = self.father(obj) mother = self.mother(obj) if father: father_text = self.name(father) else: father_text = _("Unknown father") if mother: mother_text = self.name(mother) else: mother_text = _("Unknown mother") return "%s and %s" % (mother_text, father_text) elif isinstance(obj, gen.lib.MediaObject): return obj.desc elif isinstance(obj, gen.lib.Citation): return obj.gramps_id elif isinstance(obj, gen.lib.Source): return self.title(obj) elif isinstance(obj, gen.lib.Place): return place_name(self.dbase, obj.handle) elif isinstance(obj, gen.lib.Repository): return obj.gramps_id elif isinstance(obj, gen.lib.Note): return obj.gramps_id elif obj is None: return "" else: return "Error: incorrect object class: '%s'" % type(obj)
def write_events(self): # At the time of this writing, the GRAMPS UI does not allow the setting # of tags for events. elist = self.database.get_event_handles() FilterClass = GenericFilterFactory('Event') filter = FilterClass() filter.add_rule(Rules.Event.HasTag([self.tag])) event_list = filter.apply(self.database, elist) if not event_list: return self.doc.start_paragraph("TR-Heading") header = _("Events") mark = IndexMark(header, INDEX_TYPE_TOC, 2) self.doc.write_text(header, mark) self.doc.end_paragraph() self.doc.start_table('EventTable', 'TR-Table') self.doc.start_row() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal-Bold') self.doc.write_text(_("Id")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal-Bold') self.doc.write_text(_("Date")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal-Bold') self.doc.write_text(_("Place")) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal-Bold') self.doc.write_text(_("Description")) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() for event_handle in event_list: event = self.database.get_event_from_handle(event_handle) self.doc.start_row() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal') self.doc.write_text(event.get_gramps_id()) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal') date = DateHandler.get_date(event) if date: self.doc.write_text(date) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal') place_handle = event.get_place_handle() place = ReportUtils.place_name(self.database, place_handle) if place: self.doc.write_text(place) self.doc.end_paragraph() self.doc.end_cell() self.doc.start_cell('TR-TableCell') self.doc.start_paragraph('TR-Normal') descr = event.get_description() if descr: self.doc.write_text(descr) self.doc.end_paragraph() self.doc.end_cell() self.doc.end_row() self.doc.end_table()