6599: Add regex parameter to rules which override the constructor
svn: r21943
This commit is contained in:
parent
a71e8f5689
commit
aa0e413d5f
@ -50,13 +50,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
|
||||
|
@ -48,8 +48,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)
|
||||
|
@ -34,8 +34,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
|
||||
|
@ -52,8 +52,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)
|
||||
|
@ -51,8 +51,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]
|
||||
|
@ -48,8 +48,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)
|
||||
|
@ -51,8 +51,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 = parser.parse(self.list[0])
|
||||
else:
|
||||
|
@ -52,8 +52,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):
|
||||
|
@ -51,8 +51,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 = parser.parse(self.list[0])
|
||||
else:
|
||||
|
@ -44,10 +44,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
|
||||
|
@ -51,10 +51,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()
|
||||
|
@ -51,10 +51,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()
|
||||
|
@ -50,8 +50,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)
|
||||
|
Loading…
Reference in New Issue
Block a user