sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #02673
[Bug 779099] [NEW] [request] findAll() should force getLastMatch() to return None if nothing was found
Public bug reported:
This would help to write lean code.
Currently getLastMatches() returns a Finder object in all cases. If
nothing was found, the first entry (hasNext() returns True) is set to
None.
So if you handle the FindFailed exception or ignore it, you at least
have to pop one entry to check it for None. If it is not None and you
want to loop through all entries, you cannot push the first entry back -
this has to be handled as a special case in the while/for loop. Or you
have to set up additional switches to catch None in the first entry.
a compact workaround currently with the cost of an additional search when successful:
matches = findAll(img) if exists(img, 0) else ()
for x in matches:
pass # will not execute if nothing found
This is possible, but I guess the average Sikuli user might not find
this solution.
** Affects: sikuli
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Sikuli
Drivers, which is subscribed to Sikuli.
https://bugs.launchpad.net/bugs/779099
Title:
[request] findAll() should force getLastMatch() to return None if
nothing was found
Status in Sikuli:
New
Bug description:
This would help to write lean code.
Currently getLastMatches() returns a Finder object in all cases. If
nothing was found, the first entry (hasNext() returns True) is set to
None.
So if you handle the FindFailed exception or ignore it, you at least
have to pop one entry to check it for None. If it is not None and you
want to loop through all entries, you cannot push the first entry back
- this has to be handled as a special case in the while/for loop. Or
you have to set up additional switches to catch None in the first
entry.
a compact workaround currently with the cost of an additional search when successful:
matches = findAll(img) if exists(img, 0) else ()
for x in matches:
pass # will not execute if nothing found
This is possible, but I guess the average Sikuli user might not find
this solution.
Follow ups
References