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>
|
||||
* src/BasicUtils/_UpdateCallback.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")
|
||||
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):
|
||||
handle = object.get_handle()
|
||||
count = 0
|
||||
for item in db.find_backlink_handles(handle):
|
||||
count += 1
|
||||
|
||||
value = int(self.list[1])
|
||||
|
||||
if self.list[0] == _('lesser than'):
|
||||
return count < value
|
||||
elif self.list[0] == _('greater than'):
|
||||
return count > value
|
||||
return count == value
|
||||
if self.countType == 0: # "lesser than"
|
||||
return count < self.userSelectedCount
|
||||
elif self.countType == 2: # "greater than"
|
||||
return count > self.userSelectedCount
|
||||
# "equal to"
|
||||
return count == self.userSelectedCount
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user