<s> """<STR_LIT>""" <EOL> from prompt_toolkit . shortcuts import create_eventloop as _create_eventloop <EOL> import sys <EOL> import time <EOL> __all__ = ( <EOL> '<STR_LIT>' , <EOL> ) <EOL> def _inputhook_tk ( inputhook_context ) : <EOL> """<STR_LIT>""" <EOL> import _tkinter <EOL> from six . moves import tkinter <EOL> root = tkinter . _default_root <EOL> def wait_using_filehandler ( ) : <EOL> """<STR_LIT>""" <EOL> stop = [ False ] <EOL> def done ( * a ) : <EOL> stop [ <NUM_LIT:0> ] = True <EOL> root . createfilehandler ( inputhook_context . fileno ( ) , _tkinter . READABLE , done ) <EOL> while root . dooneevent ( _tkinter . ALL_EVENTS ) : <EOL> if stop [ <NUM_LIT:0> ] : <EOL> break <EOL> root . deletefilehandler ( inputhook_context . fileno ( ) ) <EOL> def wait_using_polling ( ) : <EOL> """<STR_LIT>""" <EOL> while not inputhook_context . input_is_ready ( ) : <EOL> while root . dooneevent ( _tkinter . ALL_EVENTS | _tkinter . DONT_WAIT ) : <EOL> pass <EOL> time . sleep ( <NUM_LIT> ) <EOL> if root is not None : <EOL> if hasattr ( root , '<STR_LIT>' ) : <EOL> wait_using_filehandler ( ) <EOL> else : <EOL> wait_using_polling ( ) <EOL> def _inputhook ( inputhook_context ) : <EOL> if '<STR_LIT>' in sys . modules or '<STR_LIT>' in sys . modules : <EOL> _inputhook_tk ( inputhook_context ) <EOL> def create_eventloop ( ) : <EOL> return _create_eventloop ( inputhook = _inputhook ) </s>
