Add HasDayOfWeek rule
This commit is contained in:
@@ -576,6 +576,7 @@ src/Filters/Rules/Event/_EventPrivate.py
|
|||||||
src/Filters/Rules/Event/_HasAttribute.py
|
src/Filters/Rules/Event/_HasAttribute.py
|
||||||
src/Filters/Rules/Event/_HasCitation.py
|
src/Filters/Rules/Event/_HasCitation.py
|
||||||
src/Filters/Rules/Event/_HasData.py
|
src/Filters/Rules/Event/_HasData.py
|
||||||
|
src/Filters/Rules/Event/_HasDayOfWeek.py
|
||||||
src/Filters/Rules/Event/_HasGallery.py
|
src/Filters/Rules/Event/_HasGallery.py
|
||||||
src/Filters/Rules/Event/_HasIdOf.py
|
src/Filters/Rules/Event/_HasIdOf.py
|
||||||
src/Filters/Rules/Event/_HasNote.py
|
src/Filters/Rules/Event/_HasNote.py
|
||||||
|
@@ -24,6 +24,7 @@ pkgpython_PYTHON = \
|
|||||||
_MatchesSourceConfidence.py\
|
_MatchesSourceConfidence.py\
|
||||||
_MatchesSourceFilter.py\
|
_MatchesSourceFilter.py\
|
||||||
_HasAttribute.py\
|
_HasAttribute.py\
|
||||||
|
_HasDayOfWeek.py\
|
||||||
__init__.py
|
__init__.py
|
||||||
|
|
||||||
pkgpyexecdir = @pkgpyexecdir@/Filters/Rules/Event
|
pkgpyexecdir = @pkgpyexecdir@/Filters/Rules/Event
|
||||||
|
53
src/Filters/Rules/Event/_HasDayOfWeek.py
Normal file
53
src/Filters/Rules/Event/_HasDayOfWeek.py
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
#
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Standard Python modules
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
from gen.ggettext import gettext as _
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Gramps modules
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
from Filters.Rules import Rule
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# HasDayOfWeek
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
class HasDayOfWeek(Rule):
|
||||||
|
"""Rule that matches an event occurring on a particular day of the week."""
|
||||||
|
|
||||||
|
labels = [ _('Day of Week:') ]
|
||||||
|
name = _('Events occurring on a particular day of the week')
|
||||||
|
description = _('Matches events occurring on a particular day of the week')
|
||||||
|
category = _('General filters')
|
||||||
|
|
||||||
|
def apply(self, db, event):
|
||||||
|
if not self.list[0]:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
dow = event.get_date_object().get_dow()
|
||||||
|
return dow == int(self.list[0])
|
@@ -48,6 +48,7 @@ from _HasAttribute import HasAttribute
|
|||||||
from _HasData import HasData
|
from _HasData import HasData
|
||||||
from _ChangedSince import ChangedSince
|
from _ChangedSince import ChangedSince
|
||||||
from _MatchesPlaceFilter import MatchesPlaceFilter
|
from _MatchesPlaceFilter import MatchesPlaceFilter
|
||||||
|
from _HasDayOfWeek import HasDayOfWeek
|
||||||
|
|
||||||
editor_rule_list = [
|
editor_rule_list = [
|
||||||
AllEvents,
|
AllEvents,
|
||||||
@@ -68,5 +69,6 @@ editor_rule_list = [
|
|||||||
HasAttribute,
|
HasAttribute,
|
||||||
HasData,
|
HasData,
|
||||||
ChangedSince,
|
ChangedSince,
|
||||||
MatchesPlaceFilter
|
MatchesPlaceFilter,
|
||||||
|
HasDayOfWeek
|
||||||
]
|
]
|
||||||
|
@@ -1492,6 +1492,16 @@ class Date(object):
|
|||||||
"""
|
"""
|
||||||
return self.text
|
return self.text
|
||||||
|
|
||||||
|
def get_dow(self):
|
||||||
|
"""
|
||||||
|
Return an integer representing the day of the week associated with the
|
||||||
|
date (Monday=0).
|
||||||
|
|
||||||
|
If the day is not defined, a None is returned. If the date is a
|
||||||
|
compound date, the lower date day is returned.
|
||||||
|
"""
|
||||||
|
return self.sortval % 7 if self.is_regular() else None
|
||||||
|
|
||||||
def _zero_adjust_ymd(self, y, m, d):
|
def _zero_adjust_ymd(self, y, m, d):
|
||||||
year = y if y != 0 else 1
|
year = y if y != 0 else 1
|
||||||
month = max(m, 1)
|
month = max(m, 1)
|
||||||
|
@@ -69,6 +69,7 @@ from gui.selectors import SelectorFactory
|
|||||||
from gen.display.name import displayer as _nd
|
from gen.display.name import displayer as _nd
|
||||||
import Utils
|
import Utils
|
||||||
from gui.widgets import DateEntry
|
from gui.widgets import DateEntry
|
||||||
|
from GrampsLocale import long_days
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@@ -581,6 +582,9 @@ class EditRule(ManagedWindow.ManagedWindow):
|
|||||||
[Utils.confidence[i] for i in range(5)])
|
[Utils.confidence[i] for i in range(5)])
|
||||||
elif v == _('Date:'):
|
elif v == _('Date:'):
|
||||||
t = DateEntry(self.uistate, self.track)
|
t = DateEntry(self.uistate, self.track)
|
||||||
|
elif v == _('Day of Week:'):
|
||||||
|
days_of_week = long_days[2:] + long_days[1:2]
|
||||||
|
t = MyList(map(str, range(7)), days_of_week)
|
||||||
else:
|
else:
|
||||||
t = MyEntry()
|
t = MyEntry()
|
||||||
tlist.append(t)
|
tlist.append(t)
|
||||||
|
Reference in New Issue
Block a user