Fix regular expressions in sidebar filters
svn: r22968
This commit is contained in:
parent
4ad659b083
commit
b4d924f996
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user