@ anatoly
thanks again for the doc hints. changed it accordingly.
Any help, to improve the docs, make things clear and user friendly or even turn 
them into real english (sorry for my german english ;-) are always welcome.

--- "For me returning None when nothing is found is perfectly fine for a 
scripting language."
That might be right in general, but with Sikuli we have a slightly different 
situation. When they started, the default was "do nothing, if not found". This 
left the users with scripts, that might run and finish without doing nothing 
and no information on what happened. Now we have a compromise: If a find is not 
successful, the script stops with an error, since normally it does not make any 
sense to continue.
I usually use exists() for workflow situations, where you have different 
options or it is possible to recover from a not found. If a FindFailed 
exception in such a workflow is raised, I know, that something did not work as 
expected. I analyze the situation and try to make the workflow more robust.
The average Sikuli user mostly has workflows that consist of a sequence of 
find()'s, click()'s and wait()'s. For them I think the default behavior 
together with the new interactive FindFailed options is a good solution.
Others who have some scripting/programming experience will find ways to solve 
more complex situations. 

--- "Maybe it is useful to add parameter for raising exception into findAll()?"
definitely no. The current behavior is consistent with the rest of the API. 
What you could request is an existsAll(), which would be again consistent (it 
is up to you to post a request bug for that).

If I would have the situation, I would do this:
matches = findAll(img) if exists(img, 0) else False

-- 
You received this bug notification because you are a member of Sikuli
Drivers, which is subscribed to Sikuli.
https://bugs.launchpad.net/bugs/777037

Title:
  X-1.0rc2: findAll() fails instead of returning None --- doc updated

Status in Sikuli:
  Fix Released

Bug description:
  the docs have been updated to clearly describe the current behavior of 
findAll()
  --------------------------------------------------------------------------

  According to docs, findAll() should return None if images are not found, but 
it fails instead.
  Docs: http://sikuli.org/docx/region.html#Region.findAll
  Command: fields = findAll([image here])

  [profile] Finder.findAll START
  [profile] Finder.findAll END: 1074ms
  [error] Stopped
  [error] An error occurs at line 6
  [error] Error message: Traceback (most recent call last):
    File "C:\Users\useri\AppData\Local\Temp\sikuli-tmp2446174342086249181.py", 
line 6, in
      lettu_fields = findAll("1304497590779.png")
    File "C:\SikuliX\sikuli-script.jar\Lib\sikuli\Region.py", line 76, in 
findAll
    Line 14, in file 
C:\Users\useri\AppData\Local\Temp\sikuli-tmp2446174342086249181.py

     at org.sikuli.script.Region.handleFindFailed(Region.java:349)
    at org.sikuli.script.Region.findAll(Region.java:386)
    at org.python.proxies.sikuli.Region$Region$1.super__findAll(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)

     org.sikuli.script.FindFailed: FindFailed: can not find 1304497590779.png
    Line 14
  , in file C:\Users\useri\AppData\Local\Temp\sikuli-tmp2446174342086249181.py

_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to     : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp

Reply via email to