#NEWLINE# def __init__( self , symtable = None , writer = None , with_plugins = True ) : #NEWLINE# #INDENT# self . writer = ( writer or StdWriter ( ) ) #NEWLINE# self . writer . _larch = self #NEWLINE# if ( symtable is None ) : #NEWLINE# #INDENT# symtable = SymbolTable ( larch = self ) #NEWLINE# #UNINDENT# self . symtable = symtable #NEWLINE# self . _interrupt = None #NEWLINE# self . error = [ ] #NEWLINE# self . expr = None #NEWLINE# self . retval = None #NEWLINE# self . func = None #NEWLINE# self . fname = '<stdin>' #NEWLINE# self . lineno = 0 #NEWLINE# builtingroup = symtable . _builtin #NEWLINE# mathgroup = symtable . _math #NEWLINE# setattr ( mathgroup , 'j' , 1j ) #NEWLINE# enable_plugins ( ) #NEWLINE# site_config . system_settings ( ) #NEWLINE# for sym in builtins . from_math : #NEWLINE# #INDENT# setattr ( mathgroup , sym , getattr ( math , sym ) ) #NEWLINE# #UNINDENT# for sym in builtins . from_builtin : #NEWLINE# #INDENT# setattr ( builtingroup , sym , __builtins__ [ sym ] ) #NEWLINE# #UNINDENT# for sym in builtins . from_numpy : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# setattr ( mathgroup , sym , getattr ( numpy , sym ) ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# for ( fname , sym ) in list ( builtins . numpy_renames . items ( ) ) : #NEWLINE# #INDENT# setattr ( mathgroup , fname , getattr ( numpy , sym ) ) #NEWLINE# #UNINDENT# for ( groupname , entries ) in builtins . local_funcs . items ( ) : #NEWLINE# #INDENT# group = getattr ( symtable , groupname , None ) #NEWLINE# if ( group is not None ) : #NEWLINE# #INDENT# for ( fname , fcn ) in list ( entries . items ( ) ) : #NEWLINE# #INDENT# setattr ( group , fname , Closure ( func = fcn , _larch = self , _name = fname ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# for cmd in builtins . valid_commands : #NEWLINE# #INDENT# self . symtable . _sys . valid_commands . append ( cmd ) #NEWLINE# #UNINDENT# if with_plugins : #NEWLINE# #INDENT# plugins_dir = os . path . join ( site_config . larchdir , 'plugins' ) #NEWLINE# loaded_plugins = [ ] #NEWLINE# for pname in site_config . core_plugins : #NEWLINE# #INDENT# pdir = os . path . join ( plugins_dir , pname ) #NEWLINE# if os . path . isdir ( pdir ) : #NEWLINE# #INDENT# builtins . _addplugin ( pdir , _larch = self ) #NEWLINE# loaded_plugins . append ( pname ) #NEWLINE# #UNINDENT# #UNINDENT# for pname in sorted ( os . listdir ( plugins_dir ) ) : #NEWLINE# #INDENT# if ( pname not in loaded_plugins ) : #NEWLINE# #INDENT# pdir = os . path . join ( plugins_dir , pname ) #NEWLINE# if os . path . isdir ( pdir ) : #NEWLINE# #INDENT# builtins . _addplugin ( pdir , _larch = self ) #NEWLINE# loaded_plugins . append ( pname ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# self . on_try = self . on_tryexcept #NEWLINE# self . node_handlers = dict ( ( ( node , getattr ( self , ( 'on_%s' % node ) ) ) for node in self . supported_nodes ) )