Filter was not working, we need to query global variable when we need it, not once at start
svn: r21129
This commit is contained in:
parent
48f3002e95
commit
01dbd41081
@ -111,6 +111,7 @@ class FilterList(object):
|
||||
parser.parse(the_file)
|
||||
the_file.close()
|
||||
except (IOError, OSError):
|
||||
print("IO/OSError in _filterlist.py")
|
||||
pass
|
||||
except SAXParseException:
|
||||
print("Parser error")
|
||||
|
@ -34,7 +34,9 @@ LOG = logging.getLogger(".filter")
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from .. import CustomFilters
|
||||
# we need global variableCustomFilters, so we need to query gramps.gen.filters
|
||||
# when we need this variable, not import it at the start!
|
||||
import gramps.gen.filters
|
||||
from . import Rule
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -50,15 +52,14 @@ class MatchesFilterBase(Rule):
|
||||
Subclasses need to define the namespace class attribute.
|
||||
|
||||
"""
|
||||
|
||||
labels = [_('Filter name:')]
|
||||
name = 'Objects matching the <filter>'
|
||||
description = "Matches objects matched by the specified filter name"
|
||||
category = _('General filters')
|
||||
|
||||
def prepare(self, db):
|
||||
if CustomFilters:
|
||||
filters = CustomFilters.get_filters_dict(self.namespace)
|
||||
if gramps.gen.filters.CustomFilters:
|
||||
filters = gramps.gen.filters.CustomFilters.get_filters_dict(self.namespace)
|
||||
if self.list[0] in filters:
|
||||
filt = filters[self.list[0]]
|
||||
for rule in filt.flist:
|
||||
@ -71,16 +72,16 @@ class MatchesFilterBase(Rule):
|
||||
% self.list[0])
|
||||
|
||||
def reset(self):
|
||||
if CustomFilters:
|
||||
filters = CustomFilters.get_filters_dict(self.namespace)
|
||||
if gramps.gen.filters.CustomFilters:
|
||||
filters = gramps.gen.filters.CustomFilters.get_filters_dict(self.namespace)
|
||||
if self.list[0] in filters:
|
||||
filt = filters[self.list[0]]
|
||||
for rule in filt.flist:
|
||||
rule.requestreset()
|
||||
|
||||
def apply(self, db, obj):
|
||||
if CustomFilters:
|
||||
filters = CustomFilters.get_filters_dict(self.namespace)
|
||||
if gramps.gen.filters.CustomFilters:
|
||||
filters = gramps.gen.filters.CustomFilters.get_filters_dict(self.namespace)
|
||||
if self.list[0] in filters:
|
||||
filt = filters[self.list[0]]
|
||||
return filt.check(db, obj.handle)
|
||||
@ -90,8 +91,8 @@ class MatchesFilterBase(Rule):
|
||||
"""
|
||||
Return the selected filter or None.
|
||||
"""
|
||||
if CustomFilters:
|
||||
filters = CustomFilters.get_filters_dict(self.namespace)
|
||||
if gramps.gen.filters.CustomFilters:
|
||||
filters = gramps.gen.filters.CustomFilters.get_filters_dict(self.namespace)
|
||||
if self.list[0] in filters:
|
||||
return filters[self.list[0]]
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user