From 5d3735123ed57f750597e03bca82bb1ba8b318e5 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Sat, 13 Apr 2013 14:30:12 +0000 Subject: [PATCH] 6622: Change regular expression rules to use search rather than match svn: r21975 --- gramps/gen/filters/rules/_hasnoteregexbase.py | 2 +- gramps/gen/filters/rules/_regexpidbase.py | 2 +- .../filters/rules/note/_matchesregexpof.py | 2 +- gramps/gen/filters/rules/person/_hasnameof.py | 22 +++++++++---------- .../gen/filters/rules/person/_regexpname.py | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/gramps/gen/filters/rules/_hasnoteregexbase.py b/gramps/gen/filters/rules/_hasnoteregexbase.py index 975f343ab..1f1305996 100644 --- a/gramps/gen/filters/rules/_hasnoteregexbase.py +++ b/gramps/gen/filters/rules/_hasnoteregexbase.py @@ -61,6 +61,6 @@ class HasNoteRegexBase(Rule): for notehandle in notelist: note = db.get_note_from_handle(notehandle) n = note.get() - if self.match.match(n) is not None: + if self.match.search(n) is not None: return True return False diff --git a/gramps/gen/filters/rules/_regexpidbase.py b/gramps/gen/filters/rules/_regexpidbase.py index a3fdf32e0..acdf50b02 100644 --- a/gramps/gen/filters/rules/_regexpidbase.py +++ b/gramps/gen/filters/rules/_regexpidbase.py @@ -61,4 +61,4 @@ class RegExpIdBase(Rule): self.match = re.compile('') def apply(self, db, obj): - return self.match.match(obj.gramps_id) is not None + return self.match.search(obj.gramps_id) is not None diff --git a/gramps/gen/filters/rules/note/_matchesregexpof.py b/gramps/gen/filters/rules/note/_matchesregexpof.py index c07ec01f6..7fc1d00ed 100644 --- a/gramps/gen/filters/rules/note/_matchesregexpof.py +++ b/gramps/gen/filters/rules/note/_matchesregexpof.py @@ -59,6 +59,6 @@ class MatchesRegexpOf(Rule): def apply(self, db, note): """ Apply the filter """ text = note.get() - if self.match.match(text) is not None: + if self.match.search(text) is not None: return True return False diff --git a/gramps/gen/filters/rules/person/_hasnameof.py b/gramps/gen/filters/rules/person/_hasnameof.py index f42f0062d..ef073c403 100644 --- a/gramps/gen/filters/rules/person/_hasnameof.py +++ b/gramps/gen/filters/rules/person/_hasnameof.py @@ -111,31 +111,31 @@ class HasNameOf(Rule): valpatr = 1 if self.regular_expression: try: - if self.firstn and not re.match(self.firstn, name.get_first_name(), re.I|re.U|re.L): + if self.firstn and not re.search(self.firstn, name.get_first_name(), re.I|re.U|re.L): val = 0 - elif self.lastn and not re.match(self.lastn, name.get_surname(), re.I|re.U|re.L): + elif self.lastn and not re.search(self.lastn, name.get_surname(), re.I|re.U|re.L): val = 0 - elif self.suffix and not re.match(self.suffix, name.get_suffix(), re.I|re.U|re.L): + elif self.suffix and not re.search(self.suffix, name.get_suffix(), re.I|re.U|re.L): val = 0 - elif self.title and not re.match(self.title, name.get_title(), re.I|re.U|re.L): + elif self.title and not re.search(self.title, name.get_title(), re.I|re.U|re.L): val = 0 - elif self.calln and not re.match(self.calln, name.get_call_name(), re.I|re.U|re.L): + elif self.calln and not re.search(self.calln, name.get_call_name(), re.I|re.U|re.L): val = 0 - elif self.nick and not re.match(self.nick, name.get_nick_name(), re.I|re.U|re.L): + elif self.nick and not re.search(self.nick, name.get_nick_name(), re.I|re.U|re.L): val = 0 - elif self.famnick and not re.match(self.famnick, name.get_family_nick_name(), re.I|re.U|re.L): + elif self.famnick and not re.search(self.famnick, name.get_family_nick_name(), re.I|re.U|re.L): val = 0 else: #obtain surnames for surn in name.get_surname_list(): - if self.prefix and re.match(self.prefix, surn.get_prefix(), re.I|re.U|re.L): + if self.prefix and re.search(self.prefix, surn.get_prefix(), re.I|re.U|re.L): valpref = 1 - if self.surn and re.match(self.surn, surn.get_surname(), re.I|re.U|re.L): + if self.surn and re.search(self.surn, surn.get_surname(), re.I|re.U|re.L): valsurn = 1 - if self.con and re.match(self.con, surn.get_connector(), re.I|re.U|re.L): + if self.con and re.search(self.con, surn.get_connector(), re.I|re.U|re.L): valcon = 1 if self.patr and surn.get_origintype().value == NameOriginType.PATRONYMIC \ - and re.match(self.patr, surn.get_surname(), re.I|re.U|re.L): + and re.search(self.patr, surn.get_surname(), re.I|re.U|re.L): valpatr = 1 except re.error: #indicate error in the pattern by matching everyone diff --git a/gramps/gen/filters/rules/person/_regexpname.py b/gramps/gen/filters/rules/person/_regexpname.py index 2d19c9eba..c04ac64fd 100644 --- a/gramps/gen/filters/rules/person/_regexpname.py +++ b/gramps/gen/filters/rules/person/_regexpname.py @@ -63,7 +63,7 @@ class RegExpName(Rule): for name in [person.get_primary_name()] + person.get_alternate_names(): for field in [name.first_name, name.get_surname(), name.suffix, name.title, name.nick, name.famnick, name.call]: - if self.match.match(field): + if self.match.search(field): return True else: return False