This file is indexed.

/usr/share/sikuli/Lib/sikuli/Region.py is in libsikuli-script-java 1.0~x~rc3.tesseract3-dfsg1-8.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
# Copyright 2010-2011, Sikuli.org
# Released under the MIT License.
from org.sikuli.script import Region as JRegion
from org.sikuli.script import Location
from org.sikuli.script import Settings
from org.sikuli.script import SikuliEventAdapter
from org.sikuli.script import SikuliEventObserver
from Constants import *
import inspect
import types
import time
import java.lang.String
import __main__
import __builtin__

class Region(JRegion):

   def __init__(self, *args):
      if len(args)==4:
         JRegion.__init__(self, args[0], args[1], args[2], args[3])
      elif len(args)==1:
         JRegion.__init__(self, args[0])
      else:
         raise Exception("Wrong number of parameters of Region's contructor")

   # override all global sikuli functions by Region's methods.
   def __enter__(self):
      self._global_funcs = {}
      for name in dir(self):
         if inspect.ismethod(getattr(self,name)) and __main__.__dict__.has_key(name):
            self._global_funcs[name] = __main__.__dict__[name]
            #print "save " + name + " :" + str(__main__.__dict__[name])
            __main__.__dict__[name] = eval("self."+name)
      return self

   def __exit__(self, type, value, traceback):
      for name in self._global_funcs.keys():
         #print "restore " + name + " :" + str(self._global_funcs[name])
         __main__.__dict__[name] = self._global_funcs[name]

   #######################################################################
   #---- SIKULI  PUBLIC  API
   #######################################################################

   ##
   # Looks for the best match of a particular GUI element to interact with. 
   # It takes the file name of
   # an image that specifies the element's appearance, 
   # searches the whole screen 
   # and returns the best region matching this pattern or 
   # None if no such region can be found. <br/>
   # In addition to the return value, find() also stores the returning matched 
   # region in find.region. <br/>
   # If the auto waiting timeout ({@link #setAutoWaitTimeout}) is set to 
   # a non-zero
   # value, all find() just act as the {@link #wait} method.
   # @param img The file name of an image, which can be an absolute path or a relative path to file in the source bundle (.sikuli). It also can be a <a href="org/sikuli/script/Pattern.html">Pattern</a> object.
   # @return a <a href="org/sikuli/script/Match.html">Match</a> object that contains the best matching region, or None if nothing is found.
   #
# DELETE ME AFTER MERGING THE JAVA AND PYTHON LAYERS
#   def find(self, target):
#      ret = JRegion.find(self, target)
#      return ret

   ##
   # Looks for all instance of a particular GUI element to interact with. 
   # It takes the file name of an image that specifies the element's 
   # appearance, searches the whole screen 
   # and returns the regions matching this pattern 
   # or None if no such region can be found. <br/>
   # In addition to the return value, findAll() also stores the returning matched 
   # regions in find.regions and the best matched region in find.region. <br/>
   # If the auto waiting timeout ({@link #setAutoWaitTimeout}) is set to a non-zero
   # value, all findAll() just act as the {@link #wait} method.
   # @param img The file name of an image, which can be an absolute path or a relative path to file in the source bundle (.sikuli). It also can be a <a href="org/sikuli/script/Pattern.html">Pattern</a> object.
   # @return a <a href="org/sikuli/script/Matches.html">Matches</a> object that contains a list of <a href="org/sikuli/script/Match.html">Match</a> objects, or None if nothing is found.
   #
# DELETE ME AFTER MERGING THE JAVA AND PYTHON LAYERS
#   def findAll(self, target):
#      ret = JRegion.findAll(self, target)
#      return ret

   ##
   # Keeps searching the given image on the screen until the image appears or 
   # the specified amount of time has elapsed.
   # @param img The file name of an image, which can be an absolute path or a relative path to the file in the source bundle (.sikuli).
   # @param timeout The amount of waiting time, in milliseconds. This value orverrides the auto waiting timeout set by {@link #setAutoWaitTimeout}.
   # @return a <a href="org/sikuli/script/Matches.html">Matches</a> object that contains a list of <a href="org/sikuli/script/Match.html">Match</a> objects, or None if timeout occurs.
   # FIXME: default timeout should be autoWaitTimeout

   # Python wait() needs to be here because Java Object has a final method: wait(long timeout).
   # If we want to let Sikuli users use wait(int/long timeout), we need this Python method.
   def wait(self, target, timeout=None):
      ttype = __builtin__.type(target)
      if ttype is types.IntType or ttype is types.FloatType:
         time.sleep(target)
         return
      if timeout == None:
         ret = JRegion.wait(self, target)
      else:
         ret = JRegion.wait(self, target, timeout)
      return ret

# DELETE ME AFTER MERGING THE JAVA AND PYTHON LAYERS
#   def waitVanish(self, target, timeout=None):
#      if timeout == None:
#         ret = JRegion.waitVanish(self, target)
#      else:
#         ret = JRegion.waitVanish(self, target, timeout)
#      return ret

# DELETE ME AFTER MERGING THE JAVA AND PYTHON LAYERS
#   def exists(self, target, timeout=None):
#      if timeout == None:
#         ret = JRegion.exists(self, target)
#      else:
#         ret = JRegion.exists(self, target, timeout)
#      return ret
   
   ##
   # Performs a mouse clicking on the best matched position of the 
   # given image pattern. It calls
   # find() to locate the pattern if a file name or a <a href="org/sikuli/script/Pattern.html">Pattern</a> object is given.
   # @param img The file name of an image; a <a href="org/sikuli/script/Pattern.html">Pattern</a> object; a <a href="org/sikuli/script/Match.html">Match</a> object; or a <a href="org/sikuli/script/Matches.html">Matches</a> object.
   # @param modifiers The key modifiers. This can be one modifier or union of multiple modifiers combined by the OR(|) operator.
   # @return The number of performed clicking. <br/> Returns -1 if find() fails.
# DELETE ME AFTER MERGING THE JAVA AND PYTHON LAYERS
#   def click(self, target, modifiers=0):
#      return JRegion.click(self, target, modifiers)

   ##
   # Performs a double clicking on the best matched position of the given 
   # image pattern. It calls
   # find() to locate the pattern if a file name or a <a href="org/sikuli/script/Pattern.html">Pattern</a> object is given.
   # @param img The file name of an image; a <a href="org/sikuli/script/Pattern.html">Pattern</a> object; a <a href="org/sikuli/script/Match.html">Match</a> object; or a <a href="org/sikuli/script/Matches.html">Matches</a> object.
   # @param modifiers The key modifiers. This can be one modifier or union of multiple modifiers combined by the OR(|) operator.
   # @return The number of performed clicking. <br/> Returns -1 if find() fails.
# DELETE ME AFTER MERGING THE JAVA AND PYTHON LAYERS
#   def doubleClick(self, target, modifiers=0):
#      return JRegion.doubleClick(self, target, modifiers)

   ##
   # Performs a right clicking on the best matched position of the given 
   # image pattern. It calls
   # find() to locate the pattern if a file name or a <a href="org/sikuli/script/Pattern.html">Pattern</a> object is given.
   # @param img The file name of an image; a <a href="org/sikuli/script/Pattern.html">Pattern</a> object; a <a href="org/sikuli/script/Match.html">Match</a> object; or a <a href="org/sikuli/script/Matches.html">Matches</a> object.
   # @param modifiers The key modifiers. This can be one modifier or union of multiple modifiers combined by the OR(|) operator.
   # @return The number of performed clicking. <br/> Returns -1 if find() fails.
# DELETE ME AFTER MERGING THE JAVA AND PYTHON LAYERS
#   def rightClick(self, target, modifiers=0):
#      return JRegion.rightClick(self, target, modifiers)

   ##
   # Move the mouse cursor to the best matched position of the 
   # given image pattern. It calls
   # find() to locate the pattern if a file name or a <a href="org/sikuli/script/Pattern.html">Pattern</a> object is given.
   # @param img The file name of an image; a <a href="org/sikuli/script/Pattern.html">Pattern</a>  object; a <a href="org/sikuli/script/Match.html">Match</a> object; or a <a href="org/sikuli/script/Matches.html">Matches</a> object.
   # @return 0 <br/> Returns -1 if find() fails.
# DELETE ME AFTER MERGING THE JAVA AND PYTHON LAYERS
#   def hover(self, target):
#      return JRegion.hover(self, target)

   ##
   # Simulate keyboard typing on the best matched position of the given 
   # image pattern. It performs a mouse clicking on the matched position to gain 
   # the focus automatically before typing. If args contains only a string, it
   # performs the typing on the current focused component.
   # See {@link #Key the Key class} for typing special keys, and {@link #paste paste()} if you need to "type" international characters or you are using diffrent keymaps other than QWERTY.
   # @param *args The parameters can be (string), (string, modifiers), (image pattern, string), or (image pattern, string, modifiers). The string specifies the string to be typed in, which can be concatenated with the special keys defined in {@link #Key the Key class}.  The image pattern specifies the object that needs the focus before typing. The modifiers specifies the key modifiers to be pressed while typing.
   # @return Returns 0 if nothing is typed, otherwise returns 1.
# DELETE ME AFTER MERGING THE JAVA AND PYTHON LAYERS
#   def type(self, *args):
#      if len(args) == 1:
#         return JRegion.type(self, None, args[0], 0)
#      if len(args) == 2:
#         if __builtin__.type(args[1]) is types.IntType:
#            return JRegion.type(self, None, args[0], args[1])
#         else:
#            return JRegion.type(self, args[0], args[1], 0)
#      return JRegion.type(self, args[0], args[1], args[2])
#
   ##
   # Paste the given string to the best matched position of the given 
   # image pattern. It performs a mouse clicking on the matched position to gain 
   # the focus automatically before pasting. If args contains only a string, it
   # performs the pasting on the current focused component. Pasting is performed 
   # using OS-level shortcut (Ctrl-V or Cmd-V), so it would mess up the clipboard.
   # paste() is a temporary solution for typing international characters or 
   # typing on different keyboard layouts.
   # @param *args The parameters can be (string) or (image pattern, string). The string specifies the string to be typed in. The image pattern specifies the object that needs the focus before pasting. 
   # @return Returns 0 if nothing is pasted, otherwise returns 1.

   # Python paste() needs to be here because of encoding conversion
   def paste(self, *args):
      if len(args) == 1:
         target = None
         s = args[0]
      elif len(args) == 2:
         target = args[0]
         s = args[1]
      t_str = __builtin__.type(s) 
      if t_str is types.UnicodeType:
         pass # do nothing
      elif t_str is types.StringType:
         s = java.lang.String(s, "utf-8")
      return JRegion.paste(self, target, s)

   ##
   # Drags from the position of <i>src</i>, 
   # and drops on the position of <i>dest</i>.
   # @param src This can be a file name of an image; a <a href="org/sikuli/script/Pattern.html">Pattern</a> object; or a <a href="org/sikuli/script/Match.html">Match</a> object.
   # @param dest This can be a file name of an image; a <a href="org/sikuli/script/Pattern.html">Pattern</a> object; or a <a href="org/sikuli/script/Match.html">Match</a> object. It also can be a tuple or a list of 2 integers <i>x</i> and <i>y</i> that indicates the absolute location of the destination on the screen.
   # @return Returns 1 if both src and dest can be found, otherwise returns 0.
# DELETE ME AFTER MERGING THE JAVA AND PYTHON LAYERS
#   def dragDrop(self, src, dest, modifiers=0):
#      if isinstance(dest, list) or isinstance(dest, tuple):
#         return JRegion.dragDrop(self, src, Location(dest[0], dest[1]), modifiers)
#      else:
#         return JRegion.dragDrop(self, src, dest, modifiers)


# DELETE ME AFTER MERGING THE JAVA AND PYTHON LAYERS
#   def drag(self, target):
#      return JRegion.drag(self, target)

# DELETE ME AFTER MERGING THE JAVA AND PYTHON LAYERS
#   def dropAt(self, target, delay=None):
#      if delay == None:
#         delay = Settings.DelayBeforeDrop
#      return JRegion.dropAt(self, target, delay)

# DELETE ME AFTER MERGING THE JAVA AND PYTHON LAYERS
#   def mouseMove(self, target):
#      return JRegion.hover(self, target)

# DELETE ME AFTER MERGING THE JAVA AND PYTHON LAYERS
#   def mouseDown(self, buttons):
#      return JRegion.mouseDown(self, buttons)

# DELETE ME AFTER MERGING THE JAVA AND PYTHON LAYERS
#   def mouseUp(self, buttons=0):
#      return JRegion.mouseUp(self, buttons)

# DELETE ME AFTER MERGING THE JAVA AND PYTHON LAYERS
#   def keyDown(self, keys):
#      return JRegion.keyDown(self, keys)

# DELETE ME AFTER MERGING THE JAVA AND PYTHON LAYERS
#   def keyUp(self, keys=None):
#      return JRegion.keyUp(self, keys)

   def onAppear(self, target, handler):
      class AnonyObserver(SikuliEventAdapter):
         def targetAppeared(self, event):
            handler(event)
      return JRegion.onAppear(self, target, AnonyObserver())

   def onVanish(self, target, handler):
      class AnonyObserver(SikuliEventAdapter):
         def targetVanished(self, event):
            handler(event)
      return JRegion.onVanish(self, target, AnonyObserver())

   ##
   #  onChange( [min_change_size], handler )
   #
   def onChange(self, arg1, arg2=None):
      t_arg1 = __builtin__.type(arg1)
      if t_arg1 is types.IntType:
         min_size = arg1
         handler = arg2
      else:
         min_size = None
         handler = arg1
      class AnonyObserver(SikuliEventAdapter):
         def targetChanged(self, event):
            handler(event)
      if min_size != None:
         return JRegion.onChange(self, min_size, AnonyObserver())
      return JRegion.onChange(self, AnonyObserver())


   def observe(self, time=FOREVER, background=False):
      if background:
         return self.observeInBackground(time) 
      else:
         return JRegion.observe(self, time)

   ##
   # Sets the flag of throwing exceptions if {@link #find find()} fails. <br/>
   # Setting this flag to <i>True</i> enables all methods that use 
   # find() throws an exception if the find()
   # can not find anything similar on the screen.
   # Once the flag is set to <i>False</i>, all methods that use find()
   # just return <i>None</i> if nothing is found. <br/>
   # The default value of thie flag is <i>True</i>.
   #
# DELETE ME AFTER MERGING THE JAVA AND PYTHON LAYERS
#   def setThrowException(self, flag):
#      return JRegion.setThrowException(self, flag)

   ##
   # Sets the maximum waiting time in seconds for {@link #find find()}. <br/>
   # Setting this time to a non-zero value enables all methods that use find()
   # wait the appearing of the given image pattern until the specified amount of
   # time has elapsed. <br/>
   # The default timeout is <i>3.0 sec</i>.
   #
# DELETE ME AFTER MERGING THE JAVA AND PYTHON LAYERS
#   def setAutoWaitTimeout(self, sec):
#      return JRegion.setAutoWaitTimeout(self, sec)