An interpreter can process chunks of EmPy code.
Methods
|
|
|
|
__del__
|
__del__ ( self )
|
|
__init__
|
__init__ (
self,
output=None,
argv=None,
prefix=DEFAULT_PREFIX,
pseudo=None,
options=None,
globals=None,
hooks=None,
)
|
|
__repr__
|
__repr__ ( self )
|
|
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.
|
|
attachFilter
|
attachFilter ( self, shortcut )
Attach a single filter to the end of the current filter chain.
|
|
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.
|
|
clear
|
clear ( self )
Clear out the globals dictionary with a brand new one.
|
|
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.
|
|
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.
|
|
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.
|
|
fix
|
fix ( self )
Reset the globals, stamping in the pseudomodule.
|
|
flatten
|
flatten ( self, keys=None )
Flatten the contents of the pseudo-module into the globals
namespace.
|
|
flush
|
flush ( self )
|
|
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,
fileOrFilename,
locals=None,
)
Do an include pass on a file or filename.
|
|
installProxy
|
installProxy ( self )
Install a proxy if necessary.
|
|
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
|
|
Error, "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
|
|
TypeError, "unpack non-sequence"
ValueError, "unpack tuple of wrong size"
|
|
|
nullFilter
|
nullFilter ( self )
Install a filter that will consume all text.
|
|
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.
|
|
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.
|
|
restore
|
restore ( self, destructive=True )
Restore the topmost historic globals.
|
|
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.
|
|
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).
|
|
save
|
save ( self, deep=True )
|
|
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, shortcut )
Set the filter.
|
|
setGlobals
|
setGlobals ( self, globals )
Set the globals to the specified dictionary.
|
|
setPrefix
|
setPrefix ( self, prefix )
Set the prefix.
|
|
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
|
|
|
unfix
|
unfix ( self )
Remove the pseudomodule (if present) from the globals.
|
|
update
|
update ( self, other )
Update the current globals dictionary with another dictionary.
|
|
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 )
|