def add_menu_options(self, menu):
        """Add the menu options for the tool."""
        # Get generic 'all families' filter and all custom familiy filters
        menu.filter_list = CustomFilters.get_filters("Family")
        all_families = GenericFilterFactory("Family")()
        all_families.set_name(_("All Families"))
        all_families.add_rule(rules.family.AllFamilies([]))
        all_filter_in_list = False
        for fltr in menu.filter_list:
            if fltr.get_name() == all_families.get_name():
                all_filter_in_list = True
        if not all_filter_in_list:
            menu.filter_list.insert(0, all_families)

        # family filter menu option
        fam = FilterOption(_("Family Filter"), 0)
        fam.set_help(_("Choose the set of families to process.\n"
                     "Create custom filters if empty."))
        fam.set_filters(menu.filter_list)
        menu.add_option(_("Options"), "families", fam)

        # add family relationship type menu option
        rel = FilterOption(_("Relationship Type"), 0)
        rel.set_help(_("Choose the new family relationship type.\n"
                     "Custom relationship types aren't supported."))
        rel.set_items([(0, _("Married")), (1, _("Unmarried")),
                       (2, _("Civil Union")), (3, _("Unknown"))])
        menu.add_option(_("Options"), "relationship", rel)
    def add_menu_options(self, menu):
        """Menu options."""
        menu.filter_list = CustomFilters.get_filters("Event")
        all_filter = GenericFilterFactory("Event")()
        all_filter.set_name(_("All Events"))
        all_filter.add_rule(rules.event.AllEvents([]))
        all_filter_in_list = False
        for fltr in menu.filter_list:
            if fltr.get_name() == all_filter.get_name():
                all_filter_in_list = True
        if not all_filter_in_list:
            menu.filter_list.insert(0, all_filter)

        events = FilterOption(_("Events"), 0)
        menu.add_option(_("Option"), "events", events)
        events.set_filters(menu.filter_list)

        find = StringOption(_("Find"), "")
        menu.add_option(_("Option"), "find", find)

        replace = StringOption(_("Replace"), "")
        menu.add_option(_("Option"), "replace", replace)

        keep_old = BooleanOption(_("Replace substring only"), False)
        keep_old.set_help(_("If True only the substring will be replaced, "
                            "otherwise the whole description will be deleted "
                            "and replaced by the new one."))
        menu.add_option(_("Option"), "keep_old", keep_old)

        regex = BooleanOption(_("Allow regex"), False)
        regex.set_help(_("Allow regular expressions."))
        menu.add_option(_("Option"), "regex", regex)
Exemplo n.º 3
0
 def get_filter(index, pers_id):
     """Create a filter."""
     fltr = GenericFilterFactory("Person")()
     custom = enumerate(CustomFilters.get_filters("Person"), start=2)
     if index == 0:
         fltr.add_rule(rules.person.IsAncestorOf([pers_id, True]))
     elif index == 1:
         fltr.add_rule(rules.person.IsDescendantOf([pers_id, True]))
     else:
         for num, item in list(custom):
             if num == index:
                 fltr = item
     return fltr
Exemplo n.º 4
0
def run_given(database, document, person):
    """
    Loops through the families that the person is a child in, and displays
    the information about the other children.
    """
    # setup the simple access functions
    sdb = SimpleAccess(database)
    sdoc = SimpleDoc(document)
    stab = QuickTable(sdb)
    if isinstance(person, Person):
        rgivenname = person.get_primary_name().get_first_name()
    else:
        rgivenname = person
    if " " in rgivenname.strip():
        rgivenname, second = rgivenname.strip().split(" ", 1)
    # display the title
    sdoc.title(_("People with the given name '%s'") % rgivenname)
    sdoc.paragraph("")
    stab.columns(_("Person"), _("Birth Date"), _("Name type"))
    filter = GenericFilterFactory('Person')()
    if rgivenname != '':
        rule = SameGiven([rgivenname])
    else:
        rule = IncompleteGiven([])
    filter.add_rule(rule)
    people = filter.apply(database, database.iter_person_handles())

    matches = 0
    for person_handle in people:
        person = database.get_person_from_handle(person_handle)
        stab.row(person, sdb.birth_or_fallback(person),
                 str(person.get_primary_name().get_type()))
        matches += 1

    document.has_data = matches > 0
    sdoc.paragraph(
        # Translators: leave all/any {...} untranslated
        ngettext(
            "There is {number_of} person "
            "with a matching name, or alternate name.\n",
            "There are {number_of} people "
            "with a matching name, or alternate name.\n",
            matches).format(number_of=matches))
    stab.write(sdoc)
Exemplo n.º 5
0
def run(database, document, person):
    """
    Loops through the families that the person is a child in, and displays
    the information about the other children.
    """
    # setup the simple access functions
    sdb = SimpleAccess(database)
    sdoc = SimpleDoc(document)
    stab = QuickTable(sdb)
    if isinstance(person, Person):
        surname = sdb.surname(person)
        rsurname = person.get_primary_name().get_group_name()
    else:
        surname = person
        rsurname = person
    # display the title
    sdoc.title(_("People sharing the surname '%s'") % surname)
    sdoc.paragraph("")
    stab.columns(_("Person"), _("Birth Date"), _("Name type"))
    filter = GenericFilterFactory('Person')()
    if rsurname != '':
        rule = SameSurname([rsurname])
    else:
        rule = IncompleteSurname([])
    filter.add_rule(rule)
    people = filter.apply(database,
                          database.iter_person_handles())

    matches = 0
    for person_handle in people:
        person = database.get_person_from_handle(person_handle)
        stab.row(person, sdb.birth_or_fallback(person),
                 str(person.get_primary_name().get_type()))
        matches += 1

    document.has_data = matches > 0
    sdoc.paragraph(
        # translators: leave all/any {...} untranslated
        ngettext("There is {number_of} person "
                     "with a matching name, or alternate name.\n",
                 "There are {number_of} people "
                     "with a matching name, or alternate name.\n", matches
                ).format(number_of=matches) )
    stab.write(sdoc)