@@ -400,11 +400,6 @@ def findAll(self, pattern):
400400 raise FindFailed ("Region outside all visible screens" )
401401 return None
402402 seconds = self .autoWaitTimeout
403- if isinstance (pattern , int ):
404- time .sleep (pattern )
405- return
406- if not pattern :
407- time .sleep (seconds )
408403 if not isinstance (pattern , Pattern ):
409404 if not isinstance (pattern , basestring ):
410405 raise TypeError ("find expected a string [image path] or Pattern object" )
@@ -442,16 +437,21 @@ def findAll(self, pattern):
442437 self ._lastMatchTime = (time .time () - find_time ) * 1000 # Capture find time in milliseconds
443438 return self ._lastMatches
444439
445- def wait (self , pattern , seconds = 3 ):
440+ def wait (self , pattern , seconds = None ):
446441 """ Searches for an image pattern in the given region, given a specified timeout period
447442
448- Functionally identical to find()
443+ Functionally identical to find(). If a number is passed instead of a pattern,
444+ just waits the specified number of seconds.
449445 Sikuli supports OCR search with a text parameter. This does not (yet).
450446 """
451- if seconds :
452- timeout = time .time () + seconds
453- else :
454- timeout = time .time ()
447+ if isinstance (pattern , (int , float )):
448+ time .sleep (pattern )
449+ return None
450+
451+ if seconds is None :
452+ seconds = self .autoWaitTimeout
453+
454+ timeout = time .time () + seconds
455455 while True :
456456 match = self .exists (pattern )
457457 if match :
@@ -473,11 +473,6 @@ def waitVanish(self, pattern, seconds=None):
473473 return None
474474 if seconds is None :
475475 seconds = self .autoWaitTimeout
476- if isinstance (pattern , int ):
477- time .sleep (pattern )
478- return
479- if not pattern :
480- time .sleep (seconds )
481476 if not isinstance (pattern , Pattern ):
482477 if not isinstance (pattern , basestring ):
483478 raise TypeError ("find expected a string [image path] or Pattern object" )
0 commit comments