← Back to team overview

sikuli-driver team mailing list archive

[Bug 779099] Re: [request] findAll() should force getLastMatch() to return None if nothing was found

 

** Changed in: sikuli
       Status: New => Fix Committed

** Changed in: sikuli
    Milestone: None => x1.0-rc3

** Summary changed:

- [request] findAll() should force getLastMatch() to return None if nothing was found
+ [request] findAll() should force getLastMatches() to return None if nothing was found

-- 
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 getLastMatches() to return None if
  nothing was found

Status in Sikuli:
  Fix Committed

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.

To manage notifications about this bug go to:
https://bugs.launchpad.net/sikuli/+bug/779099/+subscriptions


References