From 71040c0fd1eea98d9eb6df873313bdc9a7cbc50f Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Wed, 10 Apr 2013 13:21:14 +0000 Subject: [PATCH] 6599: Add regex parameter to rules which override the constructor svn: r21941 --- src/Filters/Rules/Event/_HasData.py | 4 ++-- src/Filters/Rules/Note/_MatchesRegexpOf.py | 4 ++-- src/Filters/Rules/Person/_HasBirth.py | 4 ++-- .../Rules/Person/_HasCommonAncestorWithFilterMatch.py | 4 ++-- src/Filters/Rules/Person/_HasDeath.py | 4 ++-- src/Filters/Rules/Person/_HasGallery.py | 6 +++--- src/Filters/Rules/Person/_HasTextMatchingRegexpOf.py | 4 ++-- src/Filters/Rules/Person/_IsAncestorOfFilterMatch.py | 4 ---- src/Filters/Rules/Person/_IsDescendantOfFilterMatch.py | 4 ---- src/Filters/Rules/Person/_RegExpName.py | 4 ++-- src/Filters/Rules/_HasNoteBase.py | 6 +++--- src/Filters/Rules/_HasNoteRegexBase.py | 4 ++-- src/Filters/Rules/_HasTextMatchingRegexpOf.py | 4 ++-- src/Filters/Rules/_RegExpIdBase.py | 4 ++-- 14 files changed, 26 insertions(+), 34 deletions(-) diff --git a/src/Filters/Rules/Event/_HasData.py b/src/Filters/Rules/Event/_HasData.py index d83243950..ef12a1c8a 100644 --- a/src/Filters/Rules/Event/_HasData.py +++ b/src/Filters/Rules/Event/_HasData.py @@ -50,8 +50,8 @@ class HasData(Rule): description = _("Matches events with data of a particular value") category = _('General filters') - def __init__(self, list): - Rule.__init__(self, list) + def __init__(self, list, use_regex=False): + Rule.__init__(self, list, use_regex) self.event_type = self.list[0] self.date = self.list[1] diff --git a/src/Filters/Rules/Note/_MatchesRegexpOf.py b/src/Filters/Rules/Note/_MatchesRegexpOf.py index 95911a00f..a97f18773 100644 --- a/src/Filters/Rules/Note/_MatchesRegexpOf.py +++ b/src/Filters/Rules/Note/_MatchesRegexpOf.py @@ -47,8 +47,8 @@ class MatchesRegexpOf(Rule): "which matches a regular expression") category = _('General filters') - def __init__(self, list): - Rule.__init__(self, list) + def __init__(self, list, use_regex=False): + Rule.__init__(self, list, use_regex) try: self.match = re.compile(list[0], re.I|re.U|re.L) diff --git a/src/Filters/Rules/Person/_HasBirth.py b/src/Filters/Rules/Person/_HasBirth.py index aab112973..89c485586 100644 --- a/src/Filters/Rules/Person/_HasBirth.py +++ b/src/Filters/Rules/Person/_HasBirth.py @@ -49,8 +49,8 @@ class HasBirth(Rule): description = _("Matches people with birth data of a particular value") category = _('Event filters') - def __init__(self,list): - Rule.__init__(self,list) + def __init__(self, list, use_regex=False): + Rule.__init__(self, list, use_regex) if self.list[0]: self.date = DateHandler.parser.parse(self.list[0]) else: diff --git a/src/Filters/Rules/Person/_HasCommonAncestorWithFilterMatch.py b/src/Filters/Rules/Person/_HasCommonAncestorWithFilterMatch.py index 0e1184906..4ab5bd0e9 100644 --- a/src/Filters/Rules/Person/_HasCommonAncestorWithFilterMatch.py +++ b/src/Filters/Rules/Person/_HasCommonAncestorWithFilterMatch.py @@ -51,8 +51,8 @@ class HasCommonAncestorWithFilterMatch(HasCommonAncestorWith): "with anybody matched by a filter") category = _("Ancestral filters") - def __init__(self, list): - HasCommonAncestorWith.__init__(self, list) + def __init__(self, list, use_regex=False): + HasCommonAncestorWith.__init__(self, list, use_regex) self.ancestor_cache = {} def prepare(self, db): diff --git a/src/Filters/Rules/Person/_HasDeath.py b/src/Filters/Rules/Person/_HasDeath.py index 36b19d270..ee9e57824 100644 --- a/src/Filters/Rules/Person/_HasDeath.py +++ b/src/Filters/Rules/Person/_HasDeath.py @@ -49,8 +49,8 @@ class HasDeath(Rule): description = _("Matches people with death data of a particular value") category = _('Event filters') - def __init__(self,list): - Rule.__init__(self,list) + def __init__(self, list, use_regex=False): + Rule.__init__(self, list, use_regex) if self.list[0]: self.date = DateHandler.parser.parse(self.list[0]) else: diff --git a/src/Filters/Rules/Person/_HasGallery.py b/src/Filters/Rules/Person/_HasGallery.py index a2646eb55..8b9a1ee6d 100644 --- a/src/Filters/Rules/Person/_HasGallery.py +++ b/src/Filters/Rules/Person/_HasGallery.py @@ -43,10 +43,10 @@ class HavePhotos(HasGalleryBase): name = _('People with media') description = _("Matches people with a certain number of items in the gallery") - def __init__(self, arg): + def __init__(self, arg, use_regex=False): # Upgrade from pre 3.1 HasPhotos filter, use defaults that correspond # Previous filter had 0 arguments if len(arg) == 0: - HasGalleryBase.__init__(self, ["0", 'greater than']) + HasGalleryBase.__init__(self, ["0", 'greater than'], use_regex) else: - HasGalleryBase.__init__(self, arg) + HasGalleryBase.__init__(self, arg, use_regex) diff --git a/src/Filters/Rules/Person/_HasTextMatchingRegexpOf.py b/src/Filters/Rules/Person/_HasTextMatchingRegexpOf.py index 2a89f6a5a..af831803d 100644 --- a/src/Filters/Rules/Person/_HasTextMatchingRegexpOf.py +++ b/src/Filters/Rules/Person/_HasTextMatchingRegexpOf.py @@ -41,8 +41,8 @@ class HasTextMatchingRegexpOf(HasTextMatchingSubstringOf): parameter. """ - def __init__(self,list): - HasTextMatchingSubstringOf.__init__(self,list) + def __init__(self, list, use_regex=False): + HasTextMatchingSubstringOf.__init__(self, list, use_regex) def prepare(self,db): self.db = db diff --git a/src/Filters/Rules/Person/_IsAncestorOfFilterMatch.py b/src/Filters/Rules/Person/_IsAncestorOfFilterMatch.py index 4d8cb72cb..4300960f0 100644 --- a/src/Filters/Rules/Person/_IsAncestorOfFilterMatch.py +++ b/src/Filters/Rules/Person/_IsAncestorOfFilterMatch.py @@ -50,10 +50,6 @@ class IsAncestorOfFilterMatch(IsAncestorOf): description = _("Matches people that are ancestors " "of anybody matched by a filter") - - def __init__(self,list): - IsAncestorOf.__init__(self,list) - def prepare(self,db): self.db = db self.map = set() diff --git a/src/Filters/Rules/Person/_IsDescendantOfFilterMatch.py b/src/Filters/Rules/Person/_IsDescendantOfFilterMatch.py index 0c65891a3..49cc1f6ed 100644 --- a/src/Filters/Rules/Person/_IsDescendantOfFilterMatch.py +++ b/src/Filters/Rules/Person/_IsDescendantOfFilterMatch.py @@ -50,10 +50,6 @@ class IsDescendantOfFilterMatch(IsDescendantOf): description = _("Matches people that are descendants " "of anybody matched by a filter") - -# def __init__(self,list): -# IsDescendantOf.__init__(self,list) - def prepare(self,db): self.db = db self.map = set() diff --git a/src/Filters/Rules/Person/_RegExpName.py b/src/Filters/Rules/Person/_RegExpName.py index e750e4070..157073757 100644 --- a/src/Filters/Rules/Person/_RegExpName.py +++ b/src/Filters/Rules/Person/_RegExpName.py @@ -49,8 +49,8 @@ class RegExpName(Rule): description = _("Matches people's names with a specified regular expression") category = _('General filters') - def __init__(self, list): - Rule.__init__(self, list) + def __init__(self, list, use_regex=False): + Rule.__init__(self, list, use_regex) try: self.match = re.compile(list[0],re.I|re.U|re.L) diff --git a/src/Filters/Rules/_HasNoteBase.py b/src/Filters/Rules/_HasNoteBase.py index a7a7353fe..e3d15f2ca 100755 --- a/src/Filters/Rules/_HasNoteBase.py +++ b/src/Filters/Rules/_HasNoteBase.py @@ -49,13 +49,13 @@ class HasNoteBase(Rule): description = _("Matches objects that have a certain number of notes") category = _('General filters') - def __init__(self, arg): + def __init__(self, arg, use_regex=False): # Upgrade from pre 3.1 HasNote filter, use defaults that correspond # Previous filter had 0 arguments if len(arg) == 0: - Rule.__init__(self, ["0", 'greater than']) + Rule.__init__(self, ["0", 'greater than'], use_regex) else: - Rule.__init__(self, arg) + Rule.__init__(self, arg, use_regex) def prepare(self, db): # things we want to do just once, not for every handle diff --git a/src/Filters/Rules/_HasNoteRegexBase.py b/src/Filters/Rules/_HasNoteRegexBase.py index 3f19b05df..09a02ab5a 100644 --- a/src/Filters/Rules/_HasNoteRegexBase.py +++ b/src/Filters/Rules/_HasNoteRegexBase.py @@ -47,8 +47,8 @@ class HasNoteRegexBase(Rule): "matching a regular expression") category = _('General filters') - def __init__(self, list): - Rule.__init__(self, list) + def __init__(self, list, use_regex=False): + Rule.__init__(self, list, use_regex) try: self.match = re.compile(list[0],re.I|re.U|re.L) diff --git a/src/Filters/Rules/_HasTextMatchingRegexpOf.py b/src/Filters/Rules/_HasTextMatchingRegexpOf.py index a35f7b409..e1ab6c11f 100644 --- a/src/Filters/Rules/_HasTextMatchingRegexpOf.py +++ b/src/Filters/Rules/_HasTextMatchingRegexpOf.py @@ -40,8 +40,8 @@ class HasTextMatchingRegexpOf(HasTextMatchingSubstringOf): """ Wrap HasTextMatchingSubstringOf to enable the regex_match parameter. """ - def __init__(self, list): - HasTextMatchingSubstringOf.__init__(self, list) + def __init__(self, list, use_regex=False): + HasTextMatchingSubstringOf.__init__(self, list, use_regex) # FIXME: This needs to be written for an arbitrary object # if possible diff --git a/src/Filters/Rules/_RegExpIdBase.py b/src/Filters/Rules/_RegExpIdBase.py index 9156dc7bf..9463592b8 100644 --- a/src/Filters/Rules/_RegExpIdBase.py +++ b/src/Filters/Rules/_RegExpIdBase.py @@ -51,8 +51,8 @@ class RegExpIdBase(Rule): "the regular expression") category = _('General filters') - def __init__(self, list): - Rule.__init__(self, list) + def __init__(self, list, use_regex=False): + Rule.__init__(self, list, use_regex) try: self.match = re.compile(list[0], re.I|re.U|re.L)