<s> """<STR_LIT>""" <EOL> import sys <EOL> import shlex <EOL> from pyplease . modules import get_module , get_module_list <EOL> from pyplease . utils import normalize_path <EOL> HISTORY_FILE = normalize_path ( '<STR_LIT>' ) <EOL> def init_readline ( ) : <EOL> try : <EOL> import readline <EOL> readline . read_history_file ( HISTORY_FILE ) <EOL> except : <EOL> pass <EOL> def end_readline ( ) : <EOL> try : <EOL> import readline <EOL> readline . write_history_file ( HISTORY_FILE ) <EOL> except : <EOL> pass <EOL> def print_help ( ) : <EOL> print __doc__ <EOL> print <EOL> print '<STR_LIT>' <EOL> print <EOL> for m in get_module_list ( ) : <EOL> print '<STR_LIT:U+0020>' , m <EOL> def completion ( argv ) : <EOL> line , cmd , prefix , last_word = argv <EOL> t_argv = shlex . split ( line ) <EOL> if len ( t_argv ) == <NUM_LIT:1> or ( len ( t_argv ) == <NUM_LIT:2> and prefix ) : <EOL> for m in get_module_list ( ) : <EOL> if m . startswith ( prefix ) : <EOL> print m <EOL> else : <EOL> try : <EOL> m = get_module ( t_argv [ <NUM_LIT:1> ] ) <EOL> m . completion ( prefix , t_argv [ <NUM_LIT:2> : ] ) <EOL> except : <EOL> pass <EOL> def main ( argv = None ) : <EOL> argv = argv or sys . argv <EOL> if len ( argv ) < <NUM_LIT:2> : <EOL> print_help ( ) <EOL> return <EOL> if argv [ <NUM_LIT:1> ] == '<STR_LIT>' : <EOL> completion ( argv [ <NUM_LIT:2> : ] ) <EOL> return <EOL> vocative = argv [ <NUM_LIT:1> ] <EOL> action = argv [ <NUM_LIT:2> : ] <EOL> try : <EOL> init_readline ( ) <EOL> action_module = get_module ( vocative ) <EOL> action_module . act ( action ) <EOL> end_readline ( ) <EOL> except : <EOL> print >> sys . stderr , "<STR_LIT>" <EOL> raise <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
