#NEWLINE# @ click . command ( help = 'Open a Python shell, bootstrapping the connection to MongoDB' ) #NEWLINE# @ click . option ( '--no-startup' , is_flag = True ) #NEWLINE# def shell( no_startup = False ) : #NEWLINE# #INDENT# '\n    Open a Python shell, bootstrapping the connection to MongoDB\n    ' #NEWLINE# imported_objects = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# try : #NEWLINE# #INDENT# import readline #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# import rlcompleter #NEWLINE# readline . set_completer ( rlcompleter . Completer ( imported_objects ) . complete ) #NEWLINE# readline . parse_and_bind ( 'tab:complete' ) #NEWLINE# #UNINDENT# if ( not no_startup ) : #NEWLINE# #INDENT# for pythonrc in ( os . environ . get ( 'PYTHONSTARTUP' ) , '~/.pythonrc.py' ) : #NEWLINE# #INDENT# if ( not imported_objects ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# pythonrc = os . path . expanduser ( pythonrc ) #NEWLINE# if ( not os . path . isfile ( pythonrc ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# with open ( pythonrc ) as handle : #NEWLINE# #INDENT# exec ( compile ( handle . read ( ) , pythonrc , 'exec' ) , imported_objects ) #NEWLINE# #UNINDENT# #UNINDENT# except NameError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# code . interact ( local = imported_objects )