<s> """<STR_LIT>""" <EOL> import os , bisect <EOL> import sys <EOL> from IPython . core . error import TryNext <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] <EOL> def editor ( self , filename , linenum = None ) : <EOL> """<STR_LIT>""" <EOL> editor = self . editor <EOL> if linenum is None or editor == '<STR_LIT>' : <EOL> linemark = '<STR_LIT>' <EOL> else : <EOL> linemark = '<STR_LIT>' % int ( linenum ) <EOL> if '<STR_LIT:U+0020>' in editor and os . path . isfile ( editor ) and editor [ <NUM_LIT:0> ] != '<STR_LIT:">' : <EOL> editor = '<STR_LIT>' % editor <EOL> if os . system ( '<STR_LIT>' % ( editor , linemark , filename ) ) != <NUM_LIT:0> : <EOL> raise TryNext ( ) <EOL> import tempfile <EOL> def fix_error_editor ( self , filename , linenum , column , msg ) : <EOL> """<STR_LIT>""" <EOL> def vim_quickfix_file ( ) : <EOL> t = tempfile . NamedTemporaryFile ( ) <EOL> t . write ( '<STR_LIT>' % ( filename , linenum , column , msg ) ) <EOL> t . flush ( ) <EOL> return t <EOL> if os . path . basename ( self . editor ) != '<STR_LIT>' : <EOL> self . hooks . editor ( filename , linenum ) <EOL> return <EOL> t = vim_quickfix_file ( ) <EOL> try : <EOL> if os . system ( '<STR_LIT>' + t . name ) : <EOL> raise TryNext ( ) <EOL> finally : <EOL> t . close ( ) <EOL> def synchronize_with_editor ( self , filename , linenum , column ) : <EOL> pass <EOL> class CommandChainDispatcher : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , commands = None ) : <EOL> if commands is None : <EOL> self . chain = [ ] <EOL> else : <EOL> self . chain = commands <EOL> def __call__ ( self , * args , ** kw ) : <EOL> """<STR_LIT>""" <EOL> for prio , cmd in self . chain : <EOL> try : <EOL> return cmd ( * args , ** kw ) <EOL> except TryNext as exc : <EOL> if exc . args or exc . kwargs : <EOL> args = exc . args <EOL> kw = exc . kwargs <EOL> raise TryNext <EOL> def __str__ ( self ) : <EOL> return str ( self . chain ) <EOL> def add ( self , func , priority = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> bisect . insort ( self . chain , ( priority , func ) ) <EOL> def __iter__ ( self ) : <EOL> """<STR_LIT>""" <EOL> return iter ( self . chain ) <EOL> def input_prefilter ( self , line ) : <EOL> """<STR_LIT>""" <EOL> return line <EOL> def shutdown_hook ( self ) : <EOL> """<STR_LIT>""" <EOL> return <EOL> def late_startup_hook ( self ) : <EOL> """<STR_LIT>""" <EOL> def generate_prompt ( self , is_continuation ) : <EOL> """<STR_LIT>""" <EOL> if is_continuation : <EOL> return str ( self . displayhook . prompt2 ) <EOL> return str ( self . displayhook . prompt1 ) <EOL> def show_in_pager ( self , s ) : <EOL> """<STR_LIT>""" <EOL> raise TryNext <EOL> def pre_prompt_hook ( self ) : <EOL> """<STR_LIT>""" <EOL> return None <EOL> def pre_run_code_hook ( self ) : <EOL> """<STR_LIT>""" <EOL> return None <EOL> def clipboard_get ( self ) : <EOL> """<STR_LIT>""" <EOL> from IPython . lib . clipboard import ( <EOL> osx_clipboard_get , tkinter_clipboard_get , <EOL> win32_clipboard_get <EOL> ) <EOL> if sys . platform == '<STR_LIT:win32>' : <EOL> chain = [ win32_clipboard_get , tkinter_clipboard_get ] <EOL> elif sys . platform == '<STR_LIT>' : <EOL> chain = [ osx_clipboard_get , tkinter_clipboard_get ] <EOL> else : <EOL> chain = [ tkinter_clipboard_get ] <EOL> dispatcher = CommandChainDispatcher ( ) <EOL> for func in chain : <EOL> dispatcher . add ( func ) <EOL> text = dispatcher ( ) <EOL> return text </s>
