[request] findAll() should force getLastMatches() to return None if nothing was found
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SikuliX |
Fix Released
|
Wishlist
|
Unassigned |
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.
Changed in sikuli: | |
importance: | Undecided → Wishlist |
Changed in sikuli: | |
status: | New → Fix Committed |
milestone: | none → x1.0-rc3 |
summary: |
- [request] findAll() should force getLastMatch() to return None if + [request] findAll() should force getLastMatches() to return None if nothing was found |
Changed in sikuli: | |
status: | Fix Committed → Fix Released |