Table of Contents

Class: Interpreter em.py

An interpreter can process chunks of EmPy code.

Methods   
__del__
__init__
__repr__
addFilter
addHook
areHooksEnabled
assign
atExit
atomic
binary
clause
clearGlobals
clearHooks
close
context
createDiversion
declare
defined
deregister
deregisterCallback
dictionary
disableHooks
enableHooks
escape
evaluate
execute
expand
fail
file
finalize
fixGlobals
flatten
flush
functional
getAllDiversions
getCallback
getCurrentDiversion
getFilter
getGlobals
getHooks
getPrefix
handle
identify
import_
include
interact
invoke
invokeCallback
invokeHook
literal
meta
multi
ok
parse
playAllDiversions
playDiversion
pop
popContext
process
purgeAllDiversions
purgeDiversion
push
pushContext
quote
ready
register
registerCallback
removeHook
replayAllDiversions
replayDiversion
reset
resetFilter
restoreGlobals
retrieveDiversion
run
safe
saveGlobals
serialize
setContextLine
setContextName
setFilter
setFilterChain
setGlobals
setPrefix
shutdown
significate
single
startDiversion
stopDiverting
stream
string
tokenize
unfixGlobals
updateGlobals
wrap
write
writelines
  __del__ 
__del__ ( self )

  __init__ 
__init__ (
        self,
        output=None,
        globals=None,
        arguments=None,
        config=None,
        filespec=None,
        )

  __repr__ 
__repr__ ( self )

  addFilter 
addFilter ( self,  filter )

Attach a single filter to the end of the current filter chain.

  addHook 
addHook (
        self,
        hook,
        prepend=False,
        )

Add a new hook; optionally insert it rather than appending it.

  areHooksEnabled 
areHooksEnabled ( self )

Return whether or not hooks are presently enabled.

  assign 
assign (
        self,
        name,
        value,
        locals=None,
        )

Do a potentially complex (including tuple unpacking) assignment.

  atExit 
atExit ( self,  callable )

Register a function to be called at exit.

  atomic 
atomic (
        self,
        name,
        value,
        locals=None,
        )

Do an atomic assignment.

  binary 
binary (
        self,
        file,
        name='<binary>',
        chunkSize=0,
        locals=None,
        )

Parse the entire contents of a file-like object, in chunks.

  clause 
clause (
        self,
        catch,
        locals=None,
        )

Given the string representation of an except clause, turn it into a 2-tuple consisting of the class name, and either a variable name or None.

  clearGlobals 
clearGlobals ( self )

Clear out the globals with a brand new dictionary.

  clearHooks 
clearHooks ( self )

Clear all hooks.

  close 
close ( self )

  context 
context ( self )

  createDiversion 
createDiversion ( self,  name )

Create a diversion (but do not divert to it) if it does not already exist.

  declare 
declare (
        self,
        name,
        type,
        keywords=None,
        locals=None,
        )

Declare a resource.

  defined 
defined (
        self,
        name,
        locals=None,
        )

Return a Boolean indicating whether or not the name is defined either in the locals or the globals.

  deregister 
deregister ( self,  hook )

Remove an already registered hook.

  deregisterCallback 
deregisterCallback ( self )

Remove any previously registered callback with this interpreter.

  dictionary 
dictionary (
        self,
        code,
        locals=None,
        )

Given a string represent a keyword argument list, turn it into a dictionary.

  disableHooks 
disableHooks ( self )

Disable hooks.

  enableHooks 
enableHooks ( self )

Enable hooks.

  escape 
escape (
        self,
        data,
        more='',
        )

Escape a string so that nonprintable characters are replaced with compatible EmPy expansions.

  evaluate 
evaluate (
        self,
        expression,
        locals=None,
        )

Evaluate an expression.

  execute 
execute (
        self,
        statements,
        locals=None,
        )

Execute a statement.

  expand 
expand (
        self,
        data,
        locals=None,
        )

Do an explicit expansion on a subordinate stream.

  fail 
fail (
        self,
        error,
        fatal=False,
        )

Handle an actual error that occurred.

  file 
file (
        self,
        file,
        name='<file>',
        locals=None,
        )

Parse the entire contents of a file-like object, line by line.

  finalize 
finalize ( self )

Execute any remaining final routines.

  fixGlobals 
fixGlobals ( self )

Reset the globals, stamping in the pseudomodule.

Exceptions   
ConsistencyError, "interpreter globals collision"
  flatten 
flatten ( self,  keys=None )

Flatten the contents of the pseudo-module into the globals namespace.

  flush 
flush ( self )

  functional 
functional (
        self,
        code,
        tokensList,
        locals=None,
        )

Handle a functional expression like @f{x}. tokensList is a list of list of tokens.

  getAllDiversions 
getAllDiversions ( self )

Get the names of all existing diversions.

  getCallback 
getCallback ( self )

Get the callback registered with this interpreter, or None.

  getCurrentDiversion 
getCurrentDiversion ( self )

Get the name of the current diversion.

  getFilter 
getFilter ( self )

Get the current filter.

  getGlobals 
getGlobals ( self )

Retrieve the globals.

  getHooks 
getHooks ( self )

Get the current hooks.

  getPrefix 
getPrefix ( self )

Get the current prefix.

  handle 
handle ( self,  meta )

Handle a MetaError.

  identify 
identify ( self )

Identify the topmost context with a 2-tuple of the name and line number.

  import_ 
import_ (
        self,
        name,
        locals=None,
        )

Do an import.

  include 
include (
        self,
        filename,
        locals=None,
        )

Do an include pass on a file.

Exceptions   
TypeError, "include requires filename"
  interact 
interact ( self )

Perform interaction.

  invoke 
invoke (
        self,
        _name,
        **keywords,
        )

Invoke the hook(s) associated with the hook name, should they exist.

  invokeCallback 
invokeCallback ( self,  contents )

Invoke the callback.

Exceptions   
CustomError, "custom markup invoked with no defined callback"
  invokeHook 
invokeHook (
        self,
        _name,
        **keywords,
        )

Manually invoke a hook.

  literal 
literal ( self,  text )

Process a string literal.

  meta 
meta ( self,  exc=None )

Construct a MetaError for the interpreter's current state.

  multi 
multi (
        self,
        names,
        values,
        locals=None,
        )

Do a (potentially recursive) assignment.

Exceptions   
ValueError, "unpack tuple of wrong size"
  ok 
ok ( self )

Is the interpreter still active?

  parse 
parse (
        self,
        scanner,
        locals=None,
        )

Parse and run as much from this scanner as possible.

  playAllDiversions 
playAllDiversions ( self )

Play all existing diversions and then purge them.

  playDiversion 
playDiversion ( self,  name )

Play the given diversion and then purge it.

  pop 
pop ( self )

  popContext 
popContext ( self )

Pop the top context.

  process 
process ( self,  commands )

Handle some main-level processing of metacommands.

  purgeAllDiversions 
purgeAllDiversions ( self )

Purge all existing diversions.

  purgeDiversion 
purgeDiversion ( self,  name )

Eliminate the given diversion.

  push 
push ( self )

  pushContext 
pushContext (
        self,
        name='<unnamed>',
        line=0,
        )

Create a new context and push it.

  quote 
quote ( self,  data )

Quote the given string so that if it were expanded it would evaluate to the original.

  ready 
ready ( self )

Declare the interpreter ready for normal operations.

  register 
register (
        self,
        hook,
        prepend=False,
        )

Register the provided hook.

  registerCallback 
registerCallback ( self,  callback )

Register a custom markup callback with this interpreter.

  removeHook 
removeHook ( self,  hook )

Remove a preexisting hook.

  replayAllDiversions 
replayAllDiversions ( self )

Replay all existing diversions without purging them.

  replayDiversion 
replayDiversion ( self,  name )

Replay the diversion without purging it.

  reset 
reset ( self )

  resetFilter 
resetFilter ( self )

Reset the filter so that it does no filtering.

  restoreGlobals 
restoreGlobals ( self,  destructive=True )

Restore the most recently saved copy of the globals.

  retrieveDiversion 
retrieveDiversion ( self,  name )

Retrieve the diversion object associated with the name.

  run 
run (
        self,
        tokens,
        name='<run>',
        locals=None,
        )

Do an explicit expansion on a sequence of tokens.

  safe 
safe (
        self,
        scanner,
        final=False,
        locals=None,
        )

Do a protected parse. Catch transient parse errors; if final is true, then make a final pass with a terminator, otherwise ignore the transient parse error (more data is pending).

  saveGlobals 
saveGlobals ( self,  deep=True )

Save a copy of the globals off onto the history stack.

  serialize 
serialize (
        self,
        expression,
        locals=None,
        )

Do an expansion, involving evaluating an expression, then converting it to a string and writing that string to the output if the evaluation is not None.

  setContextLine 
setContextLine ( self,  line )

Set the name of the topmost context.

  setContextName 
setContextName ( self,  name )

Set the name of the topmost context.

  setFilter 
setFilter ( self,  filter )

Set the filter.

  setFilterChain 
setFilterChain ( self,  filters )

Set the filter.

  setGlobals 
setGlobals ( self,  globals )

Set the globals to the specified dictionary.

  setPrefix 
setPrefix ( self,  prefix )

Set the prefix.

Exceptions   
ValueError
  shutdown 
shutdown ( self )

Declare this interpreting session over; close the stream file object. This method is idempotent.

  significate 
significate (
        self,
        key,
        value=None,
        locals=None,
        )

Declare a significator.

  single 
single (
        self,
        source,
        locals=None,
        )

Execute an expression or statement, just as if it were entered into the Python interactive interpreter.

  startDiversion 
startDiversion ( self,  name )

Start diverting to the given diversion name.

  stopDiverting 
stopDiverting ( self )

Stop any diverting.

  stream 
stream ( self )

  string 
string (
        self,
        data,
        name='<string>',
        locals=None,
        )

Parse a string.

  tokenize 
tokenize ( self,  name )

Take an lvalue string and return a name or a (possibly recursive) list of names.

Exceptions   
ParseError, "unexpected assignment token: '%s'" % garbage
  unfixGlobals 
unfixGlobals ( self )

Remove the pseudomodule (if present) from the globals.

  updateGlobals 
updateGlobals ( self,  otherGlobals )

Merge another mapping object into this interpreter's globals.

  wrap 
wrap (
        self,
        callable,
        args,
        )

Wrap around an application of a callable and handle errors. Return whether no error occurred.

  write 
write ( self,  data )

  writelines 
writelines ( self,  stuff )


Table of Contents

This document was automatically generated on Thu Mar 20 21:05:01 2008 by HappyDoc version 2.1