Ejemplo n.º 1
0
def load_ipython_extension(ipython):
    # The `ipython` argument is the currently active `InteractiveShell`
    # instance, which can be used in any way. This allows you to register
    # new magics or aliases, for example.

    aSimulator = ecell.emc.Simulator()
    aSimulator.setDMSearchPath(
        aSimulator.DM_SEARCH_PATH_SEPARATOR.join(ecell.config.dm_path))
    aSession = Session(aSimulator)

    ipython.push(createScriptContext(aSession, {}))

    def FullID_completer(self, event):
        # Completer for createLoggerStub
        return FullID_matcher(event, aSession)

    ipython.set_hook('complete_command',
                     FullID_completer,
                     re_key=r'.*createEntityStub\(\s*[\'\"]')
    ipython.set_hook('complete_command',
                     FullID_completer,
                     re_key=r'.*createLoggerStub\(\s*[\'\"]')

    @register_line_magic
    def loadModel(line):
        model_file = model_chooser()
        loadModel(model_file)
        print '{} is loaded.'.format(model_file)
Ejemplo n.º 2
0
def loadScript( aTupple ):
    aSession = aTupple[0]
    anEssFile = aTupple[1]

    #loads script after main has been called
    try:
        # load ane execute script file
        thread.start_new_thread( execfile, ( anEssFile, createScriptContext( aSession, {} ) ) )
    except:
        aSession.message(' can\'t load [%s]' %anEssFile)
        anErrorMessage = '\n'.join( traceback.format_exception( sys.exc_type,sys.exc_value,sys.exc_traceback ) )
        aSession.message("-----------")
        aSession.message(anErrorMessage)
        aSession.message("-----------")
Ejemplo n.º 3
0
def load_ipython_extension( ipython ):
    # The `ipython` argument is the currently active `InteractiveShell`
    # instance, which can be used in any way. This allows you to register
    # new magics or aliases, for example.
    
    aSimulator = ecell.emc.Simulator()
    aSimulator.setDMSearchPath( aSimulator.DM_SEARCH_PATH_SEPARATOR.join( ecell.config.dm_path ) )
    aSession = Session( aSimulator )
    
    ipython.push( createScriptContext( aSession, {} ) )
    
    def FullID_completer( self, event ):
        # Completer for createLoggerStub
        return FullID_matcher( event, aSession )
    
    ipython.set_hook('complete_command', FullID_completer, re_key = r'.*createEntityStub\(\s*[\'\"]')
    ipython.set_hook('complete_command', FullID_completer, re_key = r'.*createLoggerStub\(\s*[\'\"]')
    
    @register_line_magic
    def loadModel( line ):
        model_file = model_chooser()
        loadModel( model_file )
        print '{} is loaded.'.format( model_file )
Ejemplo n.º 4
0
    prefix = event.line.split("'")[-1]
    prefix = prefix.split('"')[-1]
    return [id for id in session.getModelEntityList() if id.startswith(prefix)]


aSimulator = ecell.emc.Simulator()
aSimulator.setDMSearchPath(
    aSimulator.DM_SEARCH_PATH_SEPARATOR.join(ecell.config.dm_path) +
    ":{cwd}/Process:{cwd}:..:../..".format(cwd=os.getcwd()))
# aSimulator.setDMSearchPath( aSimulator.getDMSearchPath + ":.:./Process:..:../.." )
aSession = Session(aSimulator)

from IPython import get_ipython

ipython = get_ipython()

ipython.push(createScriptContext(aSession, {}))


def FullID_completer(self, event):
    # Completer for createLoggerStub
    return FullID_matcher(event, aSession)


ipython.set_hook('complete_command',
                 FullID_completer,
                 re_key=r'.*createEntityStub\(\s*[\'\"]')
ipython.set_hook('complete_command',
                 FullID_completer,
                 re_key=r'.*createLoggerStub\(\s*[\'\"]')