move some filter code from ::apply() into ::prepare() to ensure it executes only once
svn: r8901
This commit is contained in:
parent
27aa4ec6a2
commit
adf6bf9cd8
@ -1,3 +1,7 @@
|
|||||||
|
2007-08-31 Stephane Charette <stephanecharette@gmail.com>
|
||||||
|
* src/Filters/Rules/_HasReferenceCountBase.py: move some filter code
|
||||||
|
from ::apply() into ::prepare() to ensure it executes only once
|
||||||
|
|
||||||
2007-08-30 Don Allingham <don@gramps-project.org>
|
2007-08-30 Don Allingham <don@gramps-project.org>
|
||||||
* src/BasicUtils/_UpdateCallback.py: add support for text in progressbar
|
* src/BasicUtils/_UpdateCallback.py: add support for text in progressbar
|
||||||
* src/ExportAssistant.py: add support for text in progressbar
|
* src/ExportAssistant.py: add support for text in progressbar
|
||||||
|
@ -45,17 +45,29 @@ class HasReferenceCountBase(Rule):
|
|||||||
description = _("Matches objects with a certain reference count")
|
description = _("Matches objects with a certain reference count")
|
||||||
category = _('General filters')
|
category = _('General filters')
|
||||||
|
|
||||||
|
|
||||||
|
def prepare(self,db):
|
||||||
|
# things we want to do just once, not for every handle
|
||||||
|
if self.list[0] == _('lesser than'):
|
||||||
|
self.countType = 0
|
||||||
|
elif self.list[0] == _('greater than'):
|
||||||
|
self.countType = 2
|
||||||
|
else:
|
||||||
|
self.countType = 1 # "equal to"
|
||||||
|
|
||||||
|
self.userSelectedCount = int(self.list[1])
|
||||||
|
|
||||||
|
|
||||||
def apply(self,db,object):
|
def apply(self,db,object):
|
||||||
handle = object.get_handle()
|
handle = object.get_handle()
|
||||||
count = 0
|
count = 0
|
||||||
for item in db.find_backlink_handles(handle):
|
for item in db.find_backlink_handles(handle):
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
value = int(self.list[1])
|
if self.countType == 0: # "lesser than"
|
||||||
|
return count < self.userSelectedCount
|
||||||
if self.list[0] == _('lesser than'):
|
elif self.countType == 2: # "greater than"
|
||||||
return count < value
|
return count > self.userSelectedCount
|
||||||
elif self.list[0] == _('greater than'):
|
# "equal to"
|
||||||
return count > value
|
return count == self.userSelectedCount
|
||||||
return count == value
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user