Contribution by MD Nauta, Feature Request #2603, Adds ChangedSince filter for all records. Tweaked time match a little, and text

svn: r11605
This commit is contained in:
Doug Blank 2009-01-10 18:41:16 +00:00
parent 6c1fd069f5
commit d8f05e65d4
28 changed files with 325 additions and 1 deletions

View File

@ -479,6 +479,7 @@ src/Filters/_SearchBar.py
src/Filters/_SearchFilter.py
# Filters.Rules package
src/Filters/Rules/_ChangedSinceBase.py
src/Filters/Rules/_Everything.py
src/Filters/Rules/_HasAttributeBase.py
src/Filters/Rules/_HasEventBase.py
@ -496,6 +497,7 @@ src/Filters/Rules/_Rule.py
src/Filters/Rules/_HasMarkerBase.py
# Filters.Rules.Person package
src/Filters/Rules/Person/_ChangedSince.py
src/Filters/Rules/Person/_Disconnected.py
src/Filters/Rules/Person/_Everyone.py
src/Filters/Rules/Person/_FamilyWithIncompleteEvent.py
@ -568,6 +570,7 @@ src/Filters/Rules/Person/_SearchName.py
# Filters.Rules.Family package
src/Filters/Rules/Family/__init__.py
src/Filters/Rules/Family/_AllFamilies.py
src/Filters/Rules/Family/_ChangedSince.py
src/Filters/Rules/Family/_ChildHasIdOf.py
src/Filters/Rules/Family/_ChildHasNameOf.py
src/Filters/Rules/Family/_FamilyPrivate.py
@ -600,6 +603,7 @@ src/Filters/Rules/Family/_RegExpIdOf.py
# Filters.Rules.Event package
src/Filters/Rules/Event/_AllEvents.py
src/Filters/Rules/Event/_ChangedSince.py
src/Filters/Rules/Event/_EventPrivate.py
src/Filters/Rules/Event/_HasAttribute.py
src/Filters/Rules/Event/_HasData.py
@ -619,6 +623,7 @@ src/Filters/Rules/Event/__init__.py
# Filters.Rules.Place package
src/Filters/Rules/Place/_AllPlaces.py
src/Filters/Rules/Place/_ChangedSince.py
src/Filters/Rules/Place/_HasGallery.py
src/Filters/Rules/Place/_HasIdOf.py
src/Filters/Rules/Place/_HasNoLatOrLon.py
@ -636,6 +641,7 @@ src/Filters/Rules/Place/__init__.py
# Filters.Rules.Source package
src/Filters/Rules/Source/_AllSources.py
src/Filters/Rules/Source/_ChangedSince.py
src/Filters/Rules/Source/_HasGallery.py
src/Filters/Rules/Source/_HasIdOf.py
src/Filters/Rules/Source/_HasNote.py
@ -650,6 +656,7 @@ src/Filters/Rules/Source/__init__.py
# Filters.Rules.MediaObject package
src/Filters/Rules/MediaObject/_AllMedia.py
src/Filters/Rules/MediaObject/_ChangedSince.py
src/Filters/Rules/MediaObject/_HasAttribute.py
src/Filters/Rules/MediaObject/_HasIdOf.py
src/Filters/Rules/MediaObject/_HasMedia.py
@ -663,6 +670,7 @@ src/Filters/Rules/MediaObject/__init__.py
# Filters.Rules.Repository package
src/Filters/Rules/Repository/_AllRepos.py
src/Filters/Rules/Repository/_ChangedSince.py
src/Filters/Rules/Repository/_HasIdOf.py
src/Filters/Rules/Repository/_HasNoteMatchingSubstringOf.py
src/Filters/Rules/Repository/_HasNoteRegexp.py
@ -675,6 +683,7 @@ src/Filters/Rules/Repository/__init__.py
# Filters.Rules.Note package
src/Filters/Rules/Note/_AllNotes.py
src/Filters/Rules/Note/_ChangedSince.py
src/Filters/Rules/Note/_HasIdOf.py
src/Filters/Rules/Note/_HasMarkerOf.py
src/Filters/Rules/Note/_MatchesSubstringOf.py

View File

@ -3,6 +3,7 @@
pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules/Event
pkgdata_PYTHON = \
_ChangedSince.py\
_MatchesFilter.py\
_EventPrivate.py\
_HasNoteRegexp.py\

View File

@ -0,0 +1,26 @@
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._ChangedSinceBase import ChangedSinceBase
#-------------------------------------------------------------------------
#
# ChangedSince
#
#-------------------------------------------------------------------------
class ChangedSince(ChangedSinceBase):
"""Rule that checks for an event changed since a specific time."""
name = _('Events changed before <date time>')
description = _("Matches event records changed before a specified "
"date/time (yyyy-mm-dd hh:mm:ss) or in the range, if a second "
"date/time is given")

View File

@ -43,6 +43,7 @@ from _MatchesPersonFilter import MatchesPersonFilter
from _MatchesSourceFilter import MatchesSourceFilter
from _HasAttribute import HasAttribute
from _HasData import HasData
from _ChangedSince import ChangedSince
editor_rule_list = [
AllEvents,
@ -62,4 +63,5 @@ editor_rule_list = [
MatchesSourceFilter,
HasAttribute,
HasData,
ChangedSince
]

View File

@ -4,6 +4,7 @@ pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules/Family
pkgdata_PYTHON = \
_AllFamilies.py\
_ChangedSince.py\
_FamilyPrivate.py\
_HasEvent.py\
_HasAttribute.py\

View File

@ -0,0 +1,26 @@
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._ChangedSinceBase import ChangedSinceBase
#-------------------------------------------------------------------------
#
# ChangedSince
#
#-------------------------------------------------------------------------
class ChangedSince(ChangedSinceBase):
"""Rule that checks for families changed since a specific time."""
name = _('Families changed before <date time>')
description = _("Matches family records changed before a specified "
"date-time (yyyy-mm-dd hh:mm:ss) or in the range, if a second "
"date-time is given")

View File

@ -55,6 +55,7 @@ from _MotherHasNameOf import MotherHasNameOf
from _MotherHasIdOf import MotherHasIdOf
from _ChildHasNameOf import ChildHasNameOf
from _ChildHasIdOf import ChildHasIdOf
from _ChangedSince import ChangedSince
editor_rule_list = [
AllFamilies,
@ -80,4 +81,5 @@ editor_rule_list = [
MotherHasIdOf,
ChildHasNameOf,
ChildHasIdOf,
ChangedSince,
]

View File

@ -5,6 +5,7 @@ SUBDIRS = Person Family Event Place Source MediaObject Repository Note
pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules
pkgdata_PYTHON = \
_ChangedSinceBase.py\
_Everything.py\
_HasEventBase.py\
_HasAttributeBase.py\

View File

@ -4,6 +4,7 @@ pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules/MediaObject
pkgdata_PYTHON = \
_AllMedia.py\
_ChangedSince.py\
_HasIdOf.py\
_HasMedia.py\
_HasNoteMatchingSubstringOf.py\

View File

@ -0,0 +1,26 @@
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._ChangedSinceBase import ChangedSinceBase
#-------------------------------------------------------------------------
#
# ChangedSince
#
#-------------------------------------------------------------------------
class ChangedSince(ChangedSinceBase):
"""Rule that checks for media objects changed since a specific time"""
name = _('Media objects changed before <date time>')
description = _("Matches media objects changed before a specified "
"date:time (yyyy-mm-dd hh:mm:ss) or in the range, if a second "
"date:time is given")

View File

@ -34,6 +34,7 @@ from _MediaPrivate import MediaPrivate
from _MatchesFilter import MatchesFilter
from _HasMedia import HasMedia
from _HasAttribute import HasAttribute
from _ChangedSince import ChangedSince
editor_rule_list = [
AllMedia,
@ -45,4 +46,5 @@ editor_rule_list = [
MediaPrivate,
MatchesFilter,
HasAttribute,
ChangedSince,
]

View File

@ -4,6 +4,7 @@ pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules/Note
pkgdata_PYTHON = \
_AllNotes.py\
_ChangedSince.py\
_HasIdOf.py\
_HasMarkerOf.py\
_MatchesSubstringOf.py\

View File

@ -0,0 +1,26 @@
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._ChangedSinceBase import ChangedSinceBase
#-------------------------------------------------------------------------
#
# ChangedSince
#
#-------------------------------------------------------------------------
class ChangedSince(ChangedSinceBase):
"""Rule that checks for notes changed since a specific time."""
name = _('Notes changed before <date time>')
description = _("Matches note records changed since a specified "
"date-time (yyyy-mm-dd hh:mm:ss) or in the range, if a second "
"date-time is given")

View File

@ -35,6 +35,7 @@ from _HasReferenceCountOf import HasReferenceCountOf
from _NotePrivate import NotePrivate
from _MatchesFilter import MatchesFilter
from _HasNote import HasNote
from _ChangedSince import ChangedSince
editor_rule_list = [
AllNotes,
@ -47,4 +48,5 @@ editor_rule_list = [
HasReferenceCountOf,
NotePrivate,
MatchesFilter,
ChangedSince,
]

View File

@ -3,6 +3,7 @@
pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules/Person
pkgdata_PYTHON = \
_ChangedSince.py\
_Disconnected.py \
_Everyone.py \
_FamilyWithIncompleteEvent.py \

View File

@ -0,0 +1,26 @@
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._ChangedSinceBase import ChangedSinceBase
#-------------------------------------------------------------------------
#
# ChangedSince
#
#-------------------------------------------------------------------------
class ChangedSince(ChangedSinceBase):
"""Rule that checks for persons changed since a specific time."""
name = _('Persons changed after <date time>')
description = _("Matches person records changed after a specified "
"date-time (yyyy-mm-dd hh:mm:ss) or in the range, if a second "
"date-time is given")

View File

@ -98,7 +98,7 @@ from _SearchName import SearchName
from _RegExpName import RegExpName
from _MatchIdOf import MatchIdOf
from _RegExpIdOf import RegExpIdOf
from _ChangedSince import ChangedSince
#-------------------------------------------------------------------------
#
@ -168,5 +168,6 @@ editor_rule_list = [
HasNoteMatchingSubstringOf,
RegExpIdOf,
Disconnected,
ChangedSince,
]

View File

@ -4,6 +4,7 @@ pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules/Place
pkgdata_PYTHON = \
_AllPlaces.py\
_ChangedSince.py\
_HasIdOf.py\
_HasNoLatOrLon.py\
_InLatLonNeighborhood.py\

View File

@ -0,0 +1,26 @@
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._ChangedSinceBase import ChangedSinceBase
#-------------------------------------------------------------------------
#
# ChangedSince
#
#-------------------------------------------------------------------------
class ChangedSince(ChangedSinceBase):
"""Rules that checks for places changed since a specific time."""
name = ('Places changed after <date time>')
description = _("Matches place records changed after a specified "
"date-time (yyyy-mm-dd hh:mm:ss) or in the range, if a second "
"date-time is given")

View File

@ -39,6 +39,7 @@ from _HasPlace import HasPlace
from _HasNoLatOrLon import HasNoLatOrLon
from _InLatLonNeighborhood import InLatLonNeighborhood
from _MatchesEventFilter import MatchesEventFilter
from _ChangedSince import ChangedSince
editor_rule_list = [
AllPlaces,
@ -55,4 +56,5 @@ editor_rule_list = [
HasNoLatOrLon,
InLatLonNeighborhood,
MatchesEventFilter,
ChangedSince,
]

View File

@ -4,6 +4,7 @@ pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules/Repository
pkgdata_PYTHON = \
_AllRepos.py\
_ChangedSince.py\
_HasIdOf.py\
_HasNoteMatchingSubstringOf.py\
_HasNoteRegexp.py\

View File

@ -0,0 +1,26 @@
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._ChangedSinceBase import ChangedSinceBase
#-------------------------------------------------------------------------
#
# ChangedSince
#
#-------------------------------------------------------------------------
class ChangedSince(ChangedSinceBase):
"""Rule that checks for repositories changed since a specific time."""
name = _('Repositories changed after <date time>')
description = _("Matches repository records changed after a specified "
"date/time (yyyy-mm-dd hh:mm:ss) or in the range, if a second "
"date/time is given")

View File

@ -33,6 +33,7 @@ from _HasReferenceCountOf import HasReferenceCountOf
from _RepoPrivate import RepoPrivate
from _MatchesFilter import MatchesFilter
from _HasRepo import HasRepo
from _ChangedSince import ChangedSince
editor_rule_list = [
AllRepos,
@ -43,4 +44,5 @@ editor_rule_list = [
HasReferenceCountOf,
RepoPrivate,
MatchesFilter,
ChangedSince,
]

View File

@ -3,6 +3,7 @@
pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules/Source
pkgdata_PYTHON = \
_ChangedSince.py\
_MatchesFilter.py\
_SourcePrivate.py\
_RegExpIdOf.py\

View File

@ -0,0 +1,26 @@
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._ChangedSinceBase import ChangedSinceBase
#-------------------------------------------------------------------------
#
# ChangedSince
#
#-------------------------------------------------------------------------
class ChangedSince(ChangedSinceBase):
"""Rule that checks for sources changed since a specific time."""
name = _('Sources changed after <date time>')
description = _("Matches source records changed after a specified "
"date-time (yyyy-mm-dd hh:mm:ss) or in the range, if a second "
"date-time is given")

View File

@ -36,6 +36,7 @@ from _HasReferenceCountOf import HasReferenceCountOf
from _SourcePrivate import SourcePrivate
from _MatchesFilter import MatchesFilter
from _HasSource import HasSource
from _ChangedSince import ChangedSince
editor_rule_list = [
AllSources,
@ -48,4 +49,5 @@ editor_rule_list = [
HasReferenceCountOf,
SourcePrivate,
MatchesFilter,
ChangedSince,
]

View File

@ -0,0 +1,82 @@
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
import re
import time
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules import Rule
#-------------------------------------------------------------------------
#
# ChangedSince
#
#-------------------------------------------------------------------------
class ChangedSinceBase(Rule):
"""
Rule that checks for primary objects changed since a specific time.
"""
labels = [ _('Changed after:'), _('but before:') ]
name = _('Objects changed after <date time>')
description = _("Matches object records changed after a specified "
"date/time (yyyy-mm-dd hh:mm:ss) or in range, if a second "
"date/time is given")
category = _('General filters')
def add_time(self, date):
if re.search("\d.*\s+\d{1,2}:\d{2}:\d{2}", date):
return date
elif re.search("\d.*\s+\d{1,2}:\d{2}", date):
return date + ":00"
elif re.search("\d.*\s+\d{1,2}", date):
return date + ":00:00"
elif re.search("\d{4}-\d{1,2}-\d{1,2}", date):
return date + " 00:00:00"
elif re.search("\d{4}-\d{1,2}", date):
return date + "-01 00:00:00"
elif re.search("\d{4}", date):
return date + "-01-01 00:00:00"
else:
return date
def time_str_to_sec(self, time_str):
time_sec = None
iso_date_time = self.add_time(time_str)
try:
time_tup = time.strptime(iso_date_time, "%Y-%m-%d %H:%M:%S")
time_sec = time.mktime(time_tup)
except ValueError:
from QuestionDialog import WarningDialog
WarningDialog(_("Wrong format of date-time"),
_("Only date-times in the iso format of yyyy-mm-dd "
"hh:mm:ss, where the time part is optional, are "
"accepted. %s does not satisfy.") % iso_date_time)
return time_sec
def prepare(self, db):
self.since = None
self.before = None
if self.list[0]:
self.since = self.time_str_to_sec(self.list[0])
if self.list[1]:
self.before = self.time_str_to_sec(self.list[1])
def apply(self, db, obj):
obj_time = obj.get_change_time()
if self.since:
if obj_time < self.since:
return False
if self.before:
return obj_time < self.before
return True
if self.before:
return obj_time < self.before
return False

View File

@ -34,6 +34,7 @@ from Filters.Rules._IsPrivate import IsPrivate
from Filters.Rules._HasTextMatchingSubstringOf import HasTextMatchingSubstringOf
from Filters.Rules._HasTextMatchingRegexpOf import HasTextMatchingRegexpOf
from Filters.Rules._MatchesFilterBase import MatchesFilterBase
from Filters.Rules._ChangedSinceBase import ChangedSinceBase
from Filters.Rules import (Person, Family, Event, Source, Place, MediaObject,
Repository, Note)