6599: Add regex parameter to rules which override the constructor
svn: r21941
This commit is contained in:
parent
fc0c0f474e
commit
71040c0fd1
@ -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]
|
||||
|
@ -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)
|
||||
|
@ -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:
|
||||
|
@ -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):
|
||||
|
@ -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:
|
||||
|
@ -43,10 +43,10 @@ class HavePhotos(HasGalleryBase):
|
||||
name = _('People with <count> 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)
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user