8 """ Searches for label and properties in a list of objects using a BasicDataAccessor.
10 One can search using findUsingFindDialog where a FindDialog is used as input for the search label and properties.
11 Navigation through the results in supported by next(), previous(),numberOfResult(),currentNumber()
14 ObjectHolder.__init__(self)
20 logging.debug(__name__ +
": setDataAccessor")
21 if not isinstance(accessor, BasicDataAccessor):
22 raise TypeError(__name__ +
" requires data accessor of type BasicDataAccessor.")
23 ObjectHolder.setDataAccessor(self, accessor)
30 logging.debug(__name__ +
': findUsingFindDialog')
44 findLabel=dialog.label()
48 if not dialog.caseSensitive():
50 findLabel=findLabel.lower()
51 if dialog.exactMatch():
52 foundLabel=findLabel==
"" or findLabel==label
54 foundLabel=findLabel
in label
58 findProperties=dialog.properties()
59 if len(findProperties)>0
and (findProperties[0][0]!=
"" or findProperties[0][1]!=
""):
60 properties=[(p[1],p[2])
for p
in self.
dataAccessor().properties(object)]
61 if not dialog.caseSensitive():
62 properties=[(str(property[0]).lower(),str(property[1]).lower())
for property
in properties]
63 findProperties=[(str(property[0]).lower(),str(property[1]).lower())
for property
in findProperties]
64 if dialog.exactMatch():
65 for findProperty
in findProperties:
66 foundProperties=(foundProperties
and\
67 True in [(findProperty[0]==
"" or findProperty[0]==p[0])
and\
68 (findProperty[1]==
"" or findProperty[1]==p[1])
for p
in properties])
70 for findProperty
in findProperties:
71 foundProperties=(foundProperties
and\
72 True in [findProperty[0]
in p[0]
and\
73 findProperty[1]
in p[1]
for p
in properties])
76 findScripts=dialog.scripts()
78 if len(findScripts)>0
and findScripts[0]!=
"":
80 for findScript
in findScripts:
82 foundScripts=(foundScripts
and\
83 (findScript==
"" or dataAccessorObject.runScript(findScript)))
87 self.
_message=
"Error in script: "+ str(e)
90 found=foundLabel
and foundProperties
and foundScripts
96 for object
in self.
_findIn(daughter,dialog):
97 if not object
in results: