/
_hasvaliddate.py
62 lines (51 loc) · 2.13 KB
/
_hasvaliddate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
from gramps.gen.filters._genericfilter import GenericFilterFactory
from gramps.gen.filters.rules import Rule
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#-------------------------------------------------------------------------
#
# HasValidDate
#
#-------------------------------------------------------------------------
class HasValidDate(Rule):
"""Rule that matches an event having a valid date"""
# labels = [ _('') ]
name = _('HasValidDate')
description = _('Matches events with a valid date')
category = _('Event filters')
def apply(self, db, event):
"""Rule that matches an event having a valid date"""
return event.get_date_object().is_valid()
class HasInValidDate(Rule):
"""Rule that matches an event having a non-blank invalid date"""
# labels = [ _('') ]
name = _('HasInValidDate')
description = _('Matches events with an invalid date')
category = _('Event filters')
def apply(self, db, event):
"""Rule that matches an event having a valid date (or a blank date)"""
return not (event.get_date_object().get_text() == "" or event.get_date_object().is_valid())