From 0b2ccdee6d3b34c524109f3adfbd3b045088d995 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Tue, 15 Jan 2013 18:27:43 +0000 Subject: [PATCH] Add family filter to match twins svn: r21132 --- gramps/gen/filters/rules/family/__init__.py | 2 + gramps/gen/filters/rules/family/_hastwins.py | 64 ++++++++++++++++++++ po/POTFILES.in | 1 + 3 files changed, 67 insertions(+) create mode 100644 gramps/gen/filters/rules/family/_hastwins.py diff --git a/gramps/gen/filters/rules/family/__init__.py b/gramps/gen/filters/rules/family/__init__.py index 7d2c5ff01..f61edbacf 100644 --- a/gramps/gen/filters/rules/family/__init__.py +++ b/gramps/gen/filters/rules/family/__init__.py @@ -60,6 +60,7 @@ from ._childhasnameof import ChildHasNameOf from ._childhasidof import ChildHasIdOf from ._changedsince import ChangedSince from ._hastag import HasTag +from ._hastwins import HasTwins editor_rule_list = [ AllFamilies, @@ -89,4 +90,5 @@ editor_rule_list = [ ChildHasIdOf, ChangedSince, HasTag, + HasTwins, ] diff --git a/gramps/gen/filters/rules/family/_hastwins.py b/gramps/gen/filters/rules/family/_hastwins.py new file mode 100644 index 000000000..1f19f732d --- /dev/null +++ b/gramps/gen/filters/rules/family/_hastwins.py @@ -0,0 +1,64 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2013 Nick Hall +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +# $Id$ + +#------------------------------------------------------------------------- +# +# Standard Python modules +# +#------------------------------------------------------------------------- +from ....ggettext import gettext as _ + +#------------------------------------------------------------------------- +# +# GRAMPS modules +# +#------------------------------------------------------------------------- +from .. import Rule +from ....lib.childreftype import ChildRefType + +#------------------------------------------------------------------------- +# +# HasTwins +# +#------------------------------------------------------------------------- +class HasTwins(Rule): + """Rule that checks for a family with twins""" + + name = _('Families with twins') + description = _("Matches families with twins") + category = _('Child filters') + + def apply(self, db, family): + date_list = [] + for childref in family.get_child_ref_list(): + if int(childref.get_mother_relation()) == ChildRefType.BIRTH: + child = db.get_person_from_handle(childref.ref) + birthref = child.get_birth_ref() + if birthref: + birth = db.get_event_from_handle(birthref.ref) + sortval = birth.get_date_object().get_sort_value() + if sortval != 0: + if sortval in date_list: + return True + else: + date_list.append(sortval) + return False diff --git a/po/POTFILES.in b/po/POTFILES.in index 7a076c152..f9d7cc383 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -95,6 +95,7 @@ gramps/gen/filters/rules/family/_hasreltype.py gramps/gen/filters/rules/family/_hassourcecount.py gramps/gen/filters/rules/family/_hassourceof.py gramps/gen/filters/rules/family/_hastag.py +gramps/gen/filters/rules/family/_hastwins.py gramps/gen/filters/rules/family/_isbookmarked.py gramps/gen/filters/rules/family/_matchesfilter.py gramps/gen/filters/rules/family/_matchessourceconfidence.py