#NEWLINE# def start( self , body , interval = 0 , iterations = 0 , timeout = 0 ) : #NEWLINE# #INDENT# 'Request the scanning to be started.\n\n        :param body: function to be called at each iteration.\n                     If None, the class body will be used.\n        :param interval: interval between starts of the iteration.\n                         If the body takes too long, the iteration will\n                         be as fast as possible and the overrun flag will be True\n        :param iterations: number of iterations\n        :param timeout: total time in seconds that the scanning will take.\n                        If overdue, the scanning will be stopped.\n                        If 0, there is no timeout.\n        ' #NEWLINE# self . _active = True #NEWLINE# body = ( body or self . body ) #NEWLINE# def internal( counter , overrun = False , schedule = QtCore . QTimer . singleShot ) : #NEWLINE# #INDENT# if ( not self . _active ) : #NEWLINE# #INDENT# self . loop_done . emit ( True ) #NEWLINE# return #NEWLINE# #UNINDENT# st = time . time ( ) #NEWLINE# self . iteration . emit ( counter , iterations , overrun ) #NEWLINE# body ( counter , iterations , overrun ) #NEWLINE# if ( iterations and ( ( counter + 1 ) == iterations ) ) : #NEWLINE# #INDENT# self . _active = False #NEWLINE# self . loop_done . emit ( False ) #NEWLINE# return #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not self . _active ) : #NEWLINE# #INDENT# self . loop_done . emit ( True ) #NEWLINE# return #NEWLINE# #UNINDENT# #UNINDENT# sleep = ( interval - ( time . time ( ) - st ) ) #NEWLINE# schedule ( ( ( sleep * 1000 ) if ( sleep > 0 ) else 0 ) , ( lambda : self . _internal_func ( ( counter + 1 ) , ( sleep < 0 ) ) ) ) #NEWLINE# #UNINDENT# self . _internal_func = body #NEWLINE# if timeout : #NEWLINE# #INDENT# QtCore . QTimer . singleShot ( ( timeout * 1000 ) , self . stop ) #NEWLINE# #UNINDENT# QtCore . QTimer . singleShot ( 0 , ( lambda : self . _internal_func ( 0 ) ) )