Support "if image in region:" construct

Bug #1087041 reported by anatoly techtonik
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SikuliX
In Progress
Low
RaiMan

Bug Description

if image in region:
  # do something
  # is more intuitive than
  if region.find(image):
    pass

Revision history for this message
anatoly techtonik (techtonik) wrote :

I could send a patch if I could edit .py files, but .py files are locked in .jars and I can't compile Sikuli to test.

So, for now the hint is: use __contains__() magic method.

Revision history for this message
RaiMan (raimund-hocke) wrote :

we already have the with support:

with region:
    if find(image):

We want to avoid too much additional code in the Python layer.

But send me the patch, I will have a look at it.

Changed in sikuli:
assignee: nobody → RaiMan (raimund-hocke)
status: New → In Progress
Revision history for this message
anatoly techtonik (techtonik) wrote :

This is a proof of concept.

Revision history for this message
anatoly techtonik (techtonik) wrote :

This is patch, but as I said - I can not test it.

Revision history for this message
RaiMan (raimund-hocke) wrote :

looks easy.

But we have to use exists(), because find() would break with a FindFailed if not found, which makes the if useless.

I have it on my list now.

RaiMan (raimund-hocke)
tags: added: scriptlanguage
RaiMan (raimund-hocke)
Changed in sikuli:
importance: Undecided → Low
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.