Skip to content

Commit 3a7b74d

Browse files
committed
Some new Filter Rules
1 parent 8230ca1 commit 3a7b74d

File tree

5 files changed

+336
-0
lines changed

5 files changed

+336
-0
lines changed

FilterRules/hasrolerule.gpr.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#
2+
# Gramps - a GTK+/GNOME based genealogy program
3+
#
4+
# Copyright (C) 2018 Paul Culley
5+
#
6+
# This program is free software; you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation; either version 2 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with this program; if not, write to the Free Software
18+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19+
#
20+
21+
"""
22+
Filter rule to match an Event Role with a particular value.
23+
"""
24+
register(RULE,
25+
id = 'HasPersonEventRole',
26+
name = _("People with events with a selected role"),
27+
description = _("Matches people with an event with a selected role"),
28+
version = '0.0.2',
29+
authors = ["Paul Culley"],
30+
authors_email = ["[email protected]"],
31+
gramps_target_version = '5.1',
32+
status = STABLE,
33+
fname = "hasrolerule.py",
34+
ruleclass = 'HasPersonEventRole', # must be rule class name
35+
namespace = 'Person', # one of the primary object classes
36+
)
37+
38+
register(RULE,
39+
id = 'HasFamilyEventRole',
40+
name = _("Families with events with a selected role"),
41+
description = _("Matches families with an event with a selected role"),
42+
version = '0.0.2',
43+
authors = ["Paul Culley"],
44+
authors_email = ["[email protected]"],
45+
gramps_target_version = '5.1',
46+
status = STABLE,
47+
fname = "hasrolerule.py",
48+
ruleclass = 'HasFamilyEventRole', # must be rule class name
49+
namespace = 'Family', # one of the primary object classes
50+
)

FilterRules/hasrolerule.py

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#
2+
# Gramps - a GTK+/GNOME based genealogy program
3+
#
4+
# Copyright (C) 2018 Paul Culley
5+
#
6+
# This program is free software; you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation; either version 2 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with this program; if not, write to the Free Software
18+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19+
#
20+
21+
"""
22+
Filter rule to match persons with a particular event.
23+
"""
24+
#-------------------------------------------------------------------------
25+
#
26+
# Standard Python modules
27+
#
28+
#-------------------------------------------------------------------------
29+
from gramps.gen.const import GRAMPS_LOCALE as glocale
30+
_ = glocale.translation.gettext
31+
32+
#-------------------------------------------------------------------------
33+
#
34+
# Gramps modules
35+
#
36+
#-------------------------------------------------------------------------
37+
from gramps.gen.lib.eventroletype import EventRoleType
38+
from gramps.gui.editors.filtereditor import MySelect, MyBoolean
39+
from gramps.gen.filters.rules import Rule
40+
41+
42+
class Roletype(MySelect):
43+
""" Provide a Role type selector """
44+
def __init__(self, db):
45+
MySelect.__init__(self, EventRoleType, db.get_event_roles())
46+
47+
48+
class NoMatch(MyBoolean):
49+
""" Provide a negation switch """
50+
def __init__(self, db):
51+
MyBoolean.__init__(self, _("Does NOT match with selected Role"))
52+
self.set_tooltip_text(_("Finds the items that don't have event Roles "
53+
"of the selected type."))
54+
#-------------------------------------------------------------------------
55+
#
56+
# HasEvent
57+
#
58+
#-------------------------------------------------------------------------
59+
class HasPersonEventRole(Rule):
60+
"""Rule that checks for a person with a selected event role"""
61+
62+
labels = [(_('Role'), Roletype),
63+
(_('Inverse'), NoMatch)]
64+
name = _('People with events with a selected role')
65+
description = _("Matches people with an event with a selected role")
66+
category = _('Event filters')
67+
68+
def apply(self, dbase, person):
69+
if not self.list[0]:
70+
return False
71+
for event_ref in person.get_event_ref_list():
72+
if not event_ref:
73+
continue
74+
if self.list[1] == '1':
75+
if event_ref.role.xml_str() != self.list[0]:
76+
return True
77+
else:
78+
if event_ref.role.xml_str() == self.list[0]:
79+
return True
80+
return False
81+
82+
83+
class HasFamilyEventRole(Rule):
84+
"""Rule that checks for a family with a selected event role"""
85+
86+
labels = [(_('Role'), Roletype),
87+
(_('Inverse'), NoMatch)]
88+
name = _('Families with events with a selected role')
89+
description = _("Matches families with an event with a selected role")
90+
category = _('Event filters')
91+
92+
def apply(self, dbase, family):
93+
if not self.list[0]:
94+
return False
95+
for event_ref in family.get_event_ref_list():
96+
if not event_ref:
97+
continue
98+
if self.list[1] == '1':
99+
if event_ref.role.xml_str() != self.list[0]:
100+
return True
101+
else:
102+
if event_ref.role.xml_str() == self.list[0]:
103+
return True
104+
return False

FilterRules/hassourcefilter.gpr.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#
2+
# Gramps - a GTK+/GNOME based genealogy program
3+
#
4+
# Copyright (C) 2017 Dave Scheipers
5+
# Copyright (C) 2017 Paul Culley
6+
#
7+
# This program is free software; you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation; either version 2 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program; if not, write to the Free Software
19+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20+
#
21+
22+
"""
23+
Filter rule to match source with a particular value.
24+
"""
25+
register(RULE,
26+
id = 'HasSourceParameter',
27+
name = _("Source matching parameters"),
28+
description = _("Matches Sources with values containing the chosen parameters"),
29+
version = '0.0.2',
30+
authors = ["Dave Scheipers", "Paul Culley"],
31+
authors_email = ["[email protected]"],
32+
gramps_target_version = '5.1',
33+
status = STABLE,
34+
fname = "hassourcefilter.py",
35+
ruleclass = 'HasSourceParameter', # must be rule class name
36+
namespace = 'Source', # one of the primary object classes
37+
)

FilterRules/hassourcefilter.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#
2+
# Gramps - a GTK+/GNOME based genealogy program
3+
#
4+
# Copyright (C) 2017 Dave Scheipers
5+
# Copyright (C) 2017 Paul Culley
6+
#
7+
# This program is free software; you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation; either version 2 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program; if not, write to the Free Software
19+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20+
#
21+
22+
"""
23+
Filter rule to match source with a particular value.
24+
"""
25+
#-------------------------------------------------------------------------
26+
#
27+
# Standard Python modules
28+
#
29+
#-------------------------------------------------------------------------
30+
from gramps.gen.const import GRAMPS_LOCALE as glocale
31+
_ = glocale.translation.gettext
32+
33+
#-------------------------------------------------------------------------
34+
#
35+
# GRAMPS modules
36+
#
37+
#-------------------------------------------------------------------------
38+
from gramps.gen.filters.rules._hassourcebase import HasSourceBase
39+
40+
41+
#-------------------------------------------------------------------------
42+
#
43+
# HasEvent
44+
#
45+
#-------------------------------------------------------------------------
46+
class HasSourceParameter(HasSourceBase):
47+
"""Rule that checks for an source with a particular value"""
48+
49+
labels = [_('Title:'),
50+
_('Author:'),
51+
_('Abbreviation:'),
52+
_('Publication:')]
53+
name = _('Sources matching parameters')
54+
description = _("Matches sources with a particular value")
55+
category = _('General filters')

FilterRules/po/template.pot

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# SOME DESCRIPTIVE TITLE.
2+
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3+
# This file is distributed under the same license as the PACKAGE package.
4+
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5+
#
6+
#, fuzzy
7+
msgid ""
8+
msgstr ""
9+
"Project-Id-Version: PACKAGE VERSION\n"
10+
"Report-Msgid-Bugs-To: \n"
11+
"POT-Creation-Date: 2019-10-25 09:28-0500\n"
12+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14+
"Language-Team: LANGUAGE <[email protected]>\n"
15+
"Language: \n"
16+
"MIME-Version: 1.0\n"
17+
"Content-Type: text/plain; charset=CHARSET\n"
18+
"Content-Transfer-Encoding: 8bit\n"
19+
20+
#: FilterRules/hasrolerule.gpr.py:26 FilterRules/hasrolerule.py:64
21+
msgid "People with events with a selected role"
22+
msgstr ""
23+
24+
#: FilterRules/hasrolerule.gpr.py:27 FilterRules/hasrolerule.py:65
25+
msgid "Matches people with an event with a selected role"
26+
msgstr ""
27+
28+
#: FilterRules/hasrolerule.gpr.py:40 FilterRules/hasrolerule.py:88
29+
msgid "Families with events with a selected role"
30+
msgstr ""
31+
32+
#: FilterRules/hasrolerule.gpr.py:41 FilterRules/hasrolerule.py:89
33+
msgid "Matches families with an event with a selected role"
34+
msgstr ""
35+
36+
#: FilterRules/hasrolerule.py:51
37+
msgid "Does NOT match with selected Role"
38+
msgstr ""
39+
40+
#: FilterRules/hasrolerule.py:52
41+
msgid "Finds the items that don't have event Roles of the selected type."
42+
msgstr ""
43+
44+
#: FilterRules/hasrolerule.py:62 FilterRules/hasrolerule.py:86
45+
msgid "Role"
46+
msgstr ""
47+
48+
#: FilterRules/hasrolerule.py:63 FilterRules/hasrolerule.py:87
49+
msgid "Inverse"
50+
msgstr ""
51+
52+
#: FilterRules/hasrolerule.py:66 FilterRules/hasrolerule.py:90
53+
msgid "Event filters"
54+
msgstr ""
55+
56+
#: FilterRules/hassourcefilter.gpr.py:27
57+
msgid "Source matching parameters"
58+
msgstr ""
59+
60+
#: FilterRules/hassourcefilter.gpr.py:28
61+
msgid "Matches Sources with values containing the chosen parameters"
62+
msgstr ""
63+
64+
#: FilterRules/hassourcefilter.py:49
65+
msgid "Title:"
66+
msgstr ""
67+
68+
#: FilterRules/hassourcefilter.py:50
69+
msgid "Author:"
70+
msgstr ""
71+
72+
#: FilterRules/hassourcefilter.py:51
73+
msgid "Abbreviation:"
74+
msgstr ""
75+
76+
#: FilterRules/hassourcefilter.py:52
77+
msgid "Publication:"
78+
msgstr ""
79+
80+
#: FilterRules/hassourcefilter.py:53
81+
msgid "Sources matching parameters"
82+
msgstr ""
83+
84+
#: FilterRules/hassourcefilter.py:54
85+
msgid "Matches sources with a particular value"
86+
msgstr ""
87+
88+
#: FilterRules/hassourcefilter.py:55
89+
msgid "General filters"
90+
msgstr ""

0 commit comments

Comments
 (0)