diff --git a/gramps/gui/filters/sidebar/_citationsidebarfilter.py b/gramps/gui/filters/sidebar/_citationsidebarfilter.py index bf5db0ffc..cd7cea680 100644 --- a/gramps/gui/filters/sidebar/_citationsidebarfilter.py +++ b/gramps/gui/filters/sidebar/_citationsidebarfilter.py @@ -47,9 +47,8 @@ from .. import build_filter_model from . import SidebarFilter from gramps.gen.constfunc import cuni from gramps.gen.filters import GenericFilterFactory, rules -from gramps.gen.filters.rules.citation import (RegExpIdOf, HasIdOf, HasCitation, - HasNoteMatchingSubstringOf, - HasNoteRegexp, MatchesFilter, HasTag) +from gramps.gen.filters.rules.citation import (RegExpIdOf, HasCitation, HasTag, + HasNoteRegexp, MatchesFilter) from gramps.gen.utils.string import confidence GenericCitationFilter = GenericFilterFactory('Citation') #------------------------------------------------------------------------- @@ -143,20 +142,14 @@ class CitationSidebarFilter(SidebarFilter): else: generic_filter = GenericCitationFilter() if gid: - if regex: - rule = RegExpIdOf([gid]) - else: - rule = HasIdOf([gid]) + rule = RegExpIdOf([gid], use_regex=regex) generic_filter.add_rule(rule) rule = HasCitation([page, date, conf], use_regex=regex) generic_filter.add_rule(rule) if note: - if regex: - rule = HasNoteRegexp([note]) - else: - rule = HasNoteMatchingSubstringOf([note]) + rule = HasNoteRegexp([note], use_regex=regex) generic_filter.add_rule(rule) # check the Tag diff --git a/gramps/gui/filters/sidebar/_eventsidebarfilter.py b/gramps/gui/filters/sidebar/_eventsidebarfilter.py index 5f41b083c..7ec480d35 100644 --- a/gramps/gui/filters/sidebar/_eventsidebarfilter.py +++ b/gramps/gui/filters/sidebar/_eventsidebarfilter.py @@ -46,9 +46,8 @@ from .. import build_filter_model from . import SidebarFilter from gramps.gen.constfunc import cuni from gramps.gen.filters import GenericFilterFactory, rules -from gramps.gen.filters.rules.event import (RegExpIdOf, HasIdOf, HasNoteRegexp, - HasNoteMatchingSubstringOf, MatchesFilter, - HasEvent, HasTag) +from gramps.gen.filters.rules.event import (RegExpIdOf, HasNoteRegexp, + MatchesFilter, HasEvent, HasTag) GenericEventFilter = GenericFilterFactory('Event') #------------------------------------------------------------------------- @@ -140,10 +139,7 @@ class EventSidebarFilter(SidebarFilter): else: generic_filter = GenericEventFilter() if gid: - if regex: - rule = RegExpIdOf([gid]) - else: - rule = HasIdOf([gid]) + rule = RegExpIdOf([gid], use_regex=regex) generic_filter.add_rule(rule) rule = HasEvent([etype, date, place, desc, mainparts], @@ -151,10 +147,7 @@ class EventSidebarFilter(SidebarFilter): generic_filter.add_rule(rule) if note: - if regex: - rule = HasNoteRegexp([note]) - else: - rule = HasNoteMatchingSubstringOf([note]) + rule = HasNoteRegexp([note], use_regex=regex) generic_filter.add_rule(rule) # check the Tag diff --git a/gramps/gui/filters/sidebar/_familysidebarfilter.py b/gramps/gui/filters/sidebar/_familysidebarfilter.py index 9e6838c28..15951b3b9 100644 --- a/gramps/gui/filters/sidebar/_familysidebarfilter.py +++ b/gramps/gui/filters/sidebar/_familysidebarfilter.py @@ -47,12 +47,10 @@ from .. import build_filter_model from . import SidebarFilter from gramps.gen.constfunc import cuni from gramps.gen.filters import GenericFilterFactory, rules -from gramps.gen.filters.rules.family import (RegExpIdOf, HasIdOf, RegExpFatherName, - SearchFatherName, RegExpMotherName, - SearchMotherName, RegExpChildName, - SearchChildName, HasEvent, HasRelType, - HasTag, HasNoteRegexp, - HasNoteMatchingSubstringOf, MatchesFilter) +from gramps.gen.filters.rules.family import (RegExpIdOf, RegExpFatherName, + RegExpMotherName, RegExpChildName, + HasEvent, HasRelType, HasTag, + HasNoteRegexp, MatchesFilter) GenericFamilyFilter = GenericFilterFactory('Family') #------------------------------------------------------------------------- @@ -154,31 +152,19 @@ class FamilySidebarFilter(SidebarFilter): else: generic_filter = GenericFamilyFilter() if gid: - if regex: - rule = RegExpIdOf([gid]) - else: - rule = HasIdOf([gid]) + rule = RegExpIdOf([gid], use_regex=regex) generic_filter.add_rule(rule) if father: - if regex: - rule = RegExpFatherName([father]) - else: - rule = SearchFatherName([father]) + rule = RegExpFatherName([father], use_regex=regex) generic_filter.add_rule(rule) if mother: - if regex: - rule = RegExpMotherName([mother]) - else: - rule = SearchMotherName([mother]) + rule = RegExpMotherName([mother], use_regex=regex) generic_filter.add_rule(rule) if child: - if regex: - rule = RegExpChildName([child]) - else: - rule = SearchChildName([child]) + rule = RegExpChildName([child], use_regex=regex) generic_filter.add_rule(rule) if etype: @@ -190,10 +176,7 @@ class FamilySidebarFilter(SidebarFilter): generic_filter.add_rule(rule) if note: - if regex: - rule = HasNoteRegexp([note]) - else: - rule = HasNoteMatchingSubstringOf([note]) + rule = HasNoteRegexp([note], use_regex=regex) generic_filter.add_rule(rule) # check the Tag diff --git a/gramps/gui/filters/sidebar/_mediasidebarfilter.py b/gramps/gui/filters/sidebar/_mediasidebarfilter.py index a10717e2c..be6a6a7e9 100644 --- a/gramps/gui/filters/sidebar/_mediasidebarfilter.py +++ b/gramps/gui/filters/sidebar/_mediasidebarfilter.py @@ -46,9 +46,8 @@ from .. import build_filter_model from . import SidebarFilter from gramps.gen.constfunc import cuni from gramps.gen.filters import GenericFilterFactory, rules -from gramps.gen.filters.rules.media import (RegExpIdOf, HasIdOf, HasMedia, HasTag, - HasNoteRegexp, MatchesFilter, - HasNoteMatchingSubstringOf) +from gramps.gen.filters.rules.media import (RegExpIdOf, HasMedia, HasTag, + HasNoteRegexp, MatchesFilter) GenericMediaFilter = GenericFilterFactory('Media') #------------------------------------------------------------------------- @@ -126,20 +125,14 @@ class MediaSidebarFilter(SidebarFilter): else: generic_filter = GenericMediaFilter() if gid: - if regex: - rule = RegExpIdOf([gid]) - else: - rule = HasIdOf([gid]) + rule = RegExpIdOf([gid], use_regex=regex) generic_filter.add_rule(rule) rule = HasMedia([title, mime, path, date], use_regex=regex) generic_filter.add_rule(rule) if note: - if regex: - rule = HasNoteRegexp([note]) - else: - rule = HasNoteMatchingSubstringOf([note]) + rule = HasNoteRegexp([note], use_regex=regex) generic_filter.add_rule(rule) # check the Tag diff --git a/gramps/gui/filters/sidebar/_notesidebarfilter.py b/gramps/gui/filters/sidebar/_notesidebarfilter.py index 83ba6698c..6b9420df4 100644 --- a/gramps/gui/filters/sidebar/_notesidebarfilter.py +++ b/gramps/gui/filters/sidebar/_notesidebarfilter.py @@ -47,8 +47,8 @@ from .. import build_filter_model from . import SidebarFilter from gramps.gen.constfunc import cuni from gramps.gen.filters import GenericFilterFactory, rules -from gramps.gen.filters.rules.note import (RegExpIdOf, HasIdOf, HasNote, - MatchesFilter, HasTag) +from gramps.gen.filters.rules.note import (RegExpIdOf, HasNote, MatchesFilter, + HasTag) GenericNoteFilter = GenericFilterFactory('Note') #------------------------------------------------------------------------- @@ -122,10 +122,7 @@ class NoteSidebarFilter(SidebarFilter): else: generic_filter = GenericNoteFilter() if gid: - if regex: - rule = RegExpIdOf([gid]) - else: - rule = HasIdOf([gid]) + rule = RegExpIdOf([gid], use_regex=regex) generic_filter.add_rule(rule) rule = HasNote([text, ntype], use_regex=regex) diff --git a/gramps/gui/filters/sidebar/_personsidebarfilter.py b/gramps/gui/filters/sidebar/_personsidebarfilter.py index 7d994e8ee..6850f7be1 100644 --- a/gramps/gui/filters/sidebar/_personsidebarfilter.py +++ b/gramps/gui/filters/sidebar/_personsidebarfilter.py @@ -48,11 +48,11 @@ from .. import build_filter_model from . import SidebarFilter from gramps.gen.constfunc import cuni from gramps.gen.filters import GenericFilter, rules -from gramps.gen.filters.rules.person import (RegExpName, SearchName, RegExpIdOf, - MatchIdOf, IsMale, IsFemale, - HasUnknownGender, HasEvent, HasTag, - HasBirth, HasDeath, HasNoteRegexp, - HasNoteMatchingSubstringOf, MatchesFilter) +from gramps.gen.filters.rules.person import (RegExpName, RegExpIdOf, IsMale, + IsFemale, HasUnknownGender, + HasEvent, HasTag, HasBirth, + HasDeath, HasNoteRegexp, + MatchesFilter) def extract_text(entry_widget): """ @@ -184,19 +184,13 @@ class PersonSidebarFilter(SidebarFilter): # if the name is not empty, choose either the regular expression # version or the normal text match if name: - if regex: - rule = RegExpName([name]) - else: - rule = SearchName([name]) + rule = RegExpName([name], use_regex=regex) generic_filter.add_rule(rule) # if the id is not empty, choose either the regular expression # version or the normal text match if gid: - if regex: - rule = RegExpIdOf([gid]) - else: - rule = MatchIdOf([gid]) + rule = RegExpIdOf([gid], use_regex=regex) generic_filter.add_rule(rule) # check the gender, and select the right rule based on gender @@ -228,10 +222,7 @@ class PersonSidebarFilter(SidebarFilter): # Build note filter if needed if note: - if regex: - rule = HasNoteRegexp([note]) - else: - rule = HasNoteMatchingSubstringOf([note]) + rule = HasNoteRegexp([note], use_regex=regex) generic_filter.add_rule(rule) # check the Tag diff --git a/gramps/gui/filters/sidebar/_placesidebarfilter.py b/gramps/gui/filters/sidebar/_placesidebarfilter.py index 78460287c..5fe675972 100644 --- a/gramps/gui/filters/sidebar/_placesidebarfilter.py +++ b/gramps/gui/filters/sidebar/_placesidebarfilter.py @@ -47,9 +47,8 @@ from .. import build_filter_model from . import SidebarFilter from gramps.gen.constfunc import cuni from gramps.gen.filters import GenericFilterFactory, rules -from gramps.gen.filters.rules.place import (RegExpIdOf, HasIdOf, HasPlace, - HasNoteRegexp, HasNoteMatchingSubstringOf, - MatchesFilter, HasTag) +from gramps.gen.filters.rules.place import (RegExpIdOf, HasPlace, HasTag, + HasNoteRegexp, MatchesFilter) GenericPlaceFilter = GenericFilterFactory('Place') #------------------------------------------------------------------------- @@ -148,10 +147,7 @@ class PlaceSidebarFilter(SidebarFilter): else: generic_filter = GenericPlaceFilter() if gid: - if regex: - rule = RegExpIdOf([gid]) - else: - rule = HasIdOf([gid]) + rule = RegExpIdOf([gid], use_regex=regex) generic_filter.add_rule(rule) rule = HasPlace([title, street, locality, city, county, state, @@ -159,10 +155,7 @@ class PlaceSidebarFilter(SidebarFilter): generic_filter.add_rule(rule) if note: - if regex: - rule = HasNoteRegexp([note]) - else: - rule = HasNoteMatchingSubstringOf([note]) + rule = HasNoteRegexp([note], use_regex=regex) generic_filter.add_rule(rule) # check the Tag diff --git a/gramps/gui/filters/sidebar/_reposidebarfilter.py b/gramps/gui/filters/sidebar/_reposidebarfilter.py index 648055259..6c53d20ac 100644 --- a/gramps/gui/filters/sidebar/_reposidebarfilter.py +++ b/gramps/gui/filters/sidebar/_reposidebarfilter.py @@ -46,9 +46,8 @@ from .. import build_filter_model from . import SidebarFilter from gramps.gen.constfunc import cuni from gramps.gen.filters import GenericFilterFactory, rules -from gramps.gen.filters.rules.repository import (RegExpIdOf, HasIdOf, HasRepo, - HasNoteRegexp, MatchesFilter, - HasNoteMatchingSubstringOf, HasTag) +from gramps.gen.filters.rules.repository import (RegExpIdOf, HasRepo, HasTag, + HasNoteRegexp, MatchesFilter) GenericRepoFilter = GenericFilterFactory('Repository') #------------------------------------------------------------------------- @@ -136,20 +135,14 @@ class RepoSidebarFilter(SidebarFilter): else: generic_filter = GenericRepoFilter() if gid: - if regex: - rule = RegExpIdOf([gid]) - else: - rule = HasIdOf([gid]) + rule = RegExpIdOf([gid], use_regex=regex) generic_filter.add_rule(rule) rule = HasRepo([title, rtype, address, url], use_regex=regex) generic_filter.add_rule(rule) if note: - if regex: - rule = HasNoteRegexp([note]) - else: - rule = HasNoteMatchingSubstringOf([note]) + rule = HasNoteRegexp([note], use_regex=regex) generic_filter.add_rule(rule) # check the Tag diff --git a/gramps/gui/filters/sidebar/_sourcesidebarfilter.py b/gramps/gui/filters/sidebar/_sourcesidebarfilter.py index 10f8b13e5..7af1a19c1 100644 --- a/gramps/gui/filters/sidebar/_sourcesidebarfilter.py +++ b/gramps/gui/filters/sidebar/_sourcesidebarfilter.py @@ -45,9 +45,8 @@ from .. import build_filter_model from . import SidebarFilter from gramps.gen.constfunc import cuni from gramps.gen.filters import GenericFilterFactory, rules -from gramps.gen.filters.rules.source import (RegExpIdOf, HasIdOf, HasSource, - HasNoteMatchingSubstringOf, - HasNoteRegexp, MatchesFilter, HasTag) +from gramps.gen.filters.rules.source import (RegExpIdOf, HasSource, HasTag, + HasNoteRegexp, MatchesFilter) GenericSourceFilter = GenericFilterFactory('Source') #------------------------------------------------------------------------- @@ -125,20 +124,14 @@ class SourceSidebarFilter(SidebarFilter): else: generic_filter = GenericSourceFilter() if gid: - if regex: - rule = RegExpIdOf([gid]) - else: - rule = HasIdOf([gid]) + rule = RegExpIdOf([gid], use_regex=regex) generic_filter.add_rule(rule) rule = HasSource([title, author, abbr, pub], use_regex=regex) generic_filter.add_rule(rule) if note: - if regex: - rule = HasNoteRegexp([note]) - else: - rule = HasNoteMatchingSubstringOf([note]) + rule = HasNoteRegexp([note], use_regex=regex) generic_filter.add_rule(rule) # check the Tag