def apply(self, db, event): if not self.list[0]: return False else: specified_type = EventType() specified_type.set_from_xml_str(self.list[0]) return event.get_type() == specified_type
def apply(self,db,person): for f_id in person.get_family_handle_list(): f = db.get_family_from_handle(f_id) if not f: continue for event_ref in f.get_event_ref_list(): if not event_ref: continue event_handle = event_ref.ref event = db.get_event_from_handle(event_handle) val = 1 if self.list[0]: specified_type = EventType() specified_type.set_from_xml_str(self.list[0]) if event.type != specified_type: val = 0 if self.list[3]: if not self.match_substring(3, event.get_description()): val = 0 if self.date: if not event.get_date_object().match(self.date): val = 0 if self.list[2]: place_id = event.get_place_handle() if place_id: place = db.get_place_from_handle(place_id) if not self.match_substring(2, place.get_title()): val = 0 else: val = 0 if val == 1: return True return False
class HasEventBase(Rule): """Rule that checks for an event with a particular value.""" labels = [ _('Event type:'), _('Date:'), _('Place:'), _('Description:'), _('Main Participants:') ] name = _('Events matching parameters') description = _("Matches events with particular parameters") category = _('Event filters') allow_regex = True def prepare(self, db): self.date = None if self.list[0]: self.etype = EventType() self.etype.set_from_xml_str(self.list[0]) else: self.etype = None try: if self.list[1]: self.date = DateHandler.parser.parse(self.list[1]) except: pass def apply(self, db, event): if self.etype: if self.etype.is_custom() and self.use_regex: if self.regex[0].search(str(event.type)) is None: return False elif event.type != self.etype: return False if not self.match_substring(3, event.get_description()): return False if self.date: if not event.get_date_object().match(self.date): return False if self.list[2]: place_id = event.get_place_handle() if place_id: place = db.get_place_from_handle(place_id) place_name = place.get_title() if not self.match_substring(2, place_name): return False else: return False if not self.match_substring( 4, get_participant_from_event( db, event.get_handle(), all_=True)): return False return True
def prepare(self, dbase): self.event_type = self.list[0] self.date = self.list[1] if self.event_type: self.event_type = EventType() self.event_type.set_from_xml_str(self.list[0]) if self.date: self.date = DateHandler.parser.parse(self.date)
def prepare(self, db): self.date = None if self.list[0]: self.etype = EventType() self.etype.set_from_xml_str(self.list[0]) else: self.etype = None try: if self.list[1]: self.date = DateHandler.parser.parse(self.list[1]) except: pass
def apply(self,db,person): for event_ref in person.event_ref_list: if event_ref and event_ref.role == EventRoleType.WITNESS: # This is the witness. # If event type was given, then check it. if self.list[0]: event = db.get_event_from_handle(event_ref.ref) specified_type = EventType() specified_type.set_from_xml_str(self.list[0]) if event.type == specified_type: return True else: # event type was not specified, we're returning a match return True return False
class HasData(Rule): """Rule that checks for an event containing particular values""" labels = [_('Event type:'), _('Date:'), _('Place:'), _('Description:')] name = _('Events with <data>') description = _("Matches events with data of a particular value") category = _('General filters') allow_regex = True def prepare(self, dbase): self.event_type = self.list[0] self.date = self.list[1] if self.event_type: self.event_type = EventType() self.event_type.set_from_xml_str(self.list[0]) if self.date: self.date = DateHandler.parser.parse(self.date) def apply(self, db, event): if self.event_type and event.get_type() != self.event_type: # No match return False if self.date and not event.get_date_object().match(self.date): # No match return False if self.list[2]: place_id = event.get_place_handle() if place_id: place = db.get_place_from_handle(place_id) if not self.match_substring(2, place.get_title()): # No match return False else: # No place attached to event return False if not self.match_substring(3, event.get_description()): # No match return False # All conditions matched return True
def init_gui(self): # Draw dialog and make it handle everything self.glade = Glade() self.auto1 = self.glade.get_object("original") self.auto2 = self.glade.get_object("new") # Need to display localized event names etype = EventType() event_names = sorted(etype.get_standard_names(), key=locale.strxfrm) AutoComp.fill_combo(self.auto1, event_names) AutoComp.fill_combo(self.auto2, event_names) etype.set_from_xml_str(self.options.handler.options_dict['fromtype']) self.auto1.child.set_text(str(etype)) etype.set_from_xml_str(self.options.handler.options_dict['totype']) self.auto2.child.set_text(str(etype)) window = self.glade.toplevel self.set_window(window, self.glade.get_object('title'), self.title) self.glade.connect_signals({ "on_close_clicked": self.close, "on_apply_clicked": self.on_apply_clicked, "on_delete_event": self.close, }) self.show()
def display_person(self, active_person): """ Display details of the active person. """ self.load_person_image(active_person) self.name.set_text(name_displayer.display(active_person)) self.clear_table() self.display_alternate_names(active_person) self.display_parents(active_person) self.display_separator() self.display_type(active_person, EventType(EventType.BIRTH)) self.display_type(active_person, EventType(EventType.BAPTISM)) self.display_type(active_person, EventType(EventType.DEATH)) self.display_type(active_person, EventType(EventType.BURIAL)) self.display_separator() self.display_attribute(active_person, _('Occupation')) self.display_attribute(active_person, _('Title')) self.display_attribute(active_person, _('Religion'))
def on_apply_clicked(self, obj): # Need to store English names for later comparison the_type = EventType() the_type.set(self.auto1.child.get_text()) self.options.handler.options_dict['fromtype'] = the_type.xml_str() the_type.set(self.auto2.child.get_text()) self.options.handler.options_dict['totype'] = the_type.xml_str() modified, msg = self.run_tool(cli=False) OkDialog(_('Change types'), msg, self.window) # Save options self.options.handler.save_options() self.close()
from gen.display.name import displayer as global_name_display from Utils import media_path_full #------------------------------------------------------------------------ # # Global variables # #------------------------------------------------------------------------ SECTION_CATEGORY = _("Sections") CUSTOM = _("Custom") # Construct section list and type to group map SECTION_LIST = [] TYPE2GROUP = {} for event_group, type_list in EventType().get_menu(): SECTION_LIST.append(event_group) for event_type in type_list: TYPE2GROUP[event_type] = event_group SECTION_LIST.append(CUSTOM) TYPE2GROUP[EventType.CUSTOM] = CUSTOM #------------------------------------------------------------------------ # # IndivCompleteReport # #------------------------------------------------------------------------ class IndivCompleteReport(Report): def __init__(self, database, options, user): """