<s> import PyV8 <EOL> import sys <EOL> from dnlib . jsapi import RootAPI <EOL> import os <EOL> import readline <EOL> histfile = os . path . join ( os . path . expanduser ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> try : <EOL> readline . read_history_file ( histfile ) <EOL> except IOError : <EOL> pass <EOL> import atexit <EOL> atexit . register ( readline . write_history_file , histfile ) <EOL> del os , histfile <EOL> Version = "<STR_LIT>" <EOL> class Shell ( object ) : <EOL> def __init__ ( self ) : <EOL> self . ctxt = PyV8 . JSContext ( RootAPI ( ) ) <EOL> self . ctxt . enter ( ) <EOL> def evaluate ( self , line ) : <EOL> return self . ctxt . eval ( line ) <EOL> def __del__ ( self ) : <EOL> self . ctxt . leave ( ) <EOL> def run ( ) : <EOL> sh = Shell ( ) <EOL> print """<STR_LIT>""" % Version <EOL> buf = "<STR_LIT>" <EOL> while True : <EOL> try : <EOL> if len ( buf ) == <NUM_LIT:0> : <EOL> prompt = "<STR_LIT:>>" <EOL> else : <EOL> prompt = "<STR_LIT:U+0020>" <EOL> line = raw_input ( prompt ) <EOL> except EOFError : <EOL> break <EOL> if len ( line ) == <NUM_LIT:0> : <EOL> continue <EOL> elif line [ - <NUM_LIT:1> ] == '<STR_LIT:\\>' : <EOL> buf += line [ : - <NUM_LIT:1> ] <EOL> elif len ( buf ) > <NUM_LIT:0> : <EOL> buf += line <EOL> sh . evaluate ( buf ) <EOL> buf = "<STR_LIT>" <EOL> else : <EOL> try : <EOL> sh . evaluate ( line ) <EOL> except : <EOL> print sys . exc_info ( ) [ <NUM_LIT:1> ] <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> run ( ) </s>
