From 0e89688da957b79a849542e344ccbc33ef41efce Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Sat, 13 Apr 2013 14:11:20 +0000 Subject: [PATCH] 6622: Change regular expression rules to use search rather than match svn: r21974 --- src/Filters/Rules/Note/_MatchesRegexpOf.py | 2 +- src/Filters/Rules/Person/_HasNameOf.py | 22 +++++++++++----------- src/Filters/Rules/Person/_RegExpName.py | 2 +- src/Filters/Rules/_HasNoteRegexBase.py | 2 +- src/Filters/Rules/_RegExpIdBase.py | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Filters/Rules/Note/_MatchesRegexpOf.py b/src/Filters/Rules/Note/_MatchesRegexpOf.py index a97f18773..77974a707 100644 --- a/src/Filters/Rules/Note/_MatchesRegexpOf.py +++ b/src/Filters/Rules/Note/_MatchesRegexpOf.py @@ -58,6 +58,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/src/Filters/Rules/Person/_HasNameOf.py b/src/Filters/Rules/Person/_HasNameOf.py index dceb39af6..fc72aeaa8 100644 --- a/src/Filters/Rules/Person/_HasNameOf.py +++ b/src/Filters/Rules/Person/_HasNameOf.py @@ -110,31 +110,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/src/Filters/Rules/Person/_RegExpName.py b/src/Filters/Rules/Person/_RegExpName.py index 157073757..5b72b1468 100644 --- a/src/Filters/Rules/Person/_RegExpName.py +++ b/src/Filters/Rules/Person/_RegExpName.py @@ -62,7 +62,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 diff --git a/src/Filters/Rules/_HasNoteRegexBase.py b/src/Filters/Rules/_HasNoteRegexBase.py index 09a02ab5a..2e98cdf9a 100644 --- a/src/Filters/Rules/_HasNoteRegexBase.py +++ b/src/Filters/Rules/_HasNoteRegexBase.py @@ -60,6 +60,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/src/Filters/Rules/_RegExpIdBase.py b/src/Filters/Rules/_RegExpIdBase.py index 9463592b8..476b3ac4e 100644 --- a/src/Filters/Rules/_RegExpIdBase.py +++ b/src/Filters/Rules/_RegExpIdBase.py @@ -60,4 +60,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