Page Contents

This Page

enaml.core

The enaml.core package contains all of Enaml’s core language functionality.

abstract_expressions Module

class enaml.core.abstract_expressions.AbstractExpression[source]

Bases: object

An abstract interface definition for creating expressions.

Expressions are registered with Declarative instances using the bind_expression method to provide computed attribute values.

__metaclass__

alias of ABCMeta

eval(obj, name)[source]

Evaluate and return the results of the expression.

Parameters:
  • obj (Declarative) – The declarative object which owns the expression.
  • name (str) – The attribute name on obj for which this expression is providing the value.
__weakref__

list of weak references to the object (if defined)

class enaml.core.abstract_expressions.AbstractListener[source]

Bases: object

An interface definition for creating attribute listeners.

Listeners are registered with Declarative instances using the bind_listener method to track changes to their attributes.

__metaclass__

alias of ABCMeta

value_changed(obj, name, old, new)[source]

Called when the attribute on the object has changed.

Parameters:
  • obj (Declarative) – The Declarative object which owns the attribute.
  • name (str) – The name of the attribute which changed.
  • old (object) – The old value of the attribute.
  • new (object) – The new value of the attribute.
__weakref__

list of weak references to the object (if defined)

code_tracing Module

class enaml.core.code_tracing.CodeTracer[source]

Bases: object

A base class for implementing code tracers.

This class defines the interface for a code tracer object, which is an object which can be passed as the first argument to a code object which has been transformed to enable tracing. Methods on the tracer are called with relevant arguments from the Python stack when that particular code segment is executing. The return value of a tracer method is ignored; exceptions are propagated.

load_attr(obj, attr)[source]

Called before the LOAD_ATTR opcode is executed.

Parameters:
  • obj (object) – The object which owns the attribute.
  • attr (str) – The attribute being loaded.
call_function(func, argtuple, argspec)[source]

Called before the CALL_FUNCTION opcode is executed.

Parameters:
  • func (object) – The object being called.
  • argtuple (tuple) – The argument tuple from the stack (see notes).
  • argspec (int) – The argument tuple specification.

Note

The argstuple contains both positional and keyword argument information. argspec is an int which specifies how to parse the information. The lower 16bits of argspec are significant. The lowest 8 bits are the number of positional arguments which are the first n items in argtuple. The second 8 bits are the number of keyword arguments which follow the positional args in argtuple and alternate name -> value. argtuple can be parsed into a conventional tuple and dict with the following:

nargs = argspec & 0xFF args = argtuple[:nargs] kwargs = dict(zip(argtuple[nargs::2], argtuple[nargs+1::2]))

binary_subscr(obj, idx)[source]

Called before the BINARY_SUBSCR opcode is executed.

Parameters:
  • obj (object) – The object being indexed.
  • idx (object) – The index.
get_iter(obj)[source]

Called before the GET_ITER opcode is executed.

Parameters:obj (object) – The object which should return an iterator.
__weakref__

list of weak references to the object (if defined)

class enaml.core.code_tracing.CodeInverter[source]

Bases: object

A base class for implementing code inverters.

This class defines the interface for a code inverter object, which is an object which can be passed as the first argument to a code object which has been transformed to enable inversion. The methods on the inverter are called with relevant arguments from the Python stack when that particular code segment is executing. The return values of a tracer method is ignored; exceptions are propagated.

The default behavior of an inverter is to raise. Implementations must provide their own code in order to enable inversion.

fail()[source]

Called by handlers to raise an inversion exception.

load_name(name, value)[source]

Called before the LOAD_NAME opcode is executed.

This method should perform a STORE_NAME operation.

Parameters:
  • name (str) – The name being loaded.
  • value (object) – The value to store.
load_attr(obj, attr, value)[source]

Called before the LOAD_ATTR opcode is executed.

This method should perform a STORE_ATTR operation.

Parameters:
  • obj (object) – The object which owns the attribute.
  • attr (str) – The attribute being loaded.
  • value (object) – The value to store
call_function(func, argtuple, argspec, value)[source]

Called before the CALL_FUNCTION opcode is executed.

This method should perform an appropriate store operation.

Parameters:
  • func (object) – The object being called.
  • argtuple (tuple) – The argument tuple from the stack (see Notes).
  • argspec (int) – The argument tuple specification.
  • value (object) – The value to store.

Note

The semantics of the arguments is identical to the method call_function on the CodeTracer type.

binary_subscr(obj, idx, value)[source]

Called before the BINARY_SUBSCR opcode is executed.

This method should perform a STORE_SUBSCR operation.

Parameters:
  • obj (object) – The object being indexed.
  • idx (object) – The index.
  • value (object) – The value to store.
__weakref__

list of weak references to the object (if defined)

enaml.core.code_tracing.inject_tracing(codelist)[source]

Inject tracing code into the given code list.

This will inject the bytecode operations required to trace the execution of the code using a CodeTracer object. The generated opcodes expect a fast local ‘_[tracer]’ to be available when the code is executed.

Parameters:codelist (list) – The list of byteplay code ops to modify.
Returns:result (list) – A new list of code ops which implement the desired behavior.
enaml.core.code_tracing.inject_inversion(codelist)[source]

Inject inversion code into the given code list.

This will inject the bytecode operations required to invert the execution of the code using a CodeInverter object. The generated opcodes expect the fast local ‘_[inverter]’ and ‘_[value]’ to be available when the code is executed.

Parameters:codelist (list) – The list of byteplay code ops to modify.
Returns:result (list) – A new list of code ops which implement the desired behavior.
Raises :
ValueError
The given code is not suitable for inversion.

compiler_helpers Module

declarative Module

class enaml.core.declarative.UserAttribute(base_type=<type 'object'>)[source]

Bases: enaml.core.trait_types.EnamlInstance

An EnamlInstance subclass which implements the attr keyword.

get(obj, name)[source]

The trait getter method.

This returns the value from the object’s dict, or raises an uninitialized error if the value doesn’t exist.

set(obj, name, value)[source]

The trait setter method.

This sets the value in the object’s dict if it is valid, and emits a change notification if the value has changed. The first time the value is set the change notification will carry None as the old value.

uninitialized_error(obj, name)[source]

Raise a DynamicAttributeError for an object and attr name.

class enaml.core.declarative.UserEvent(base_type=<type 'object'>)[source]

Bases: enaml.core.trait_types.EnamlEvent

An EnamlEvent subclass which implements the event keyword.

This subclass contains no additional logic. Its type is simply used to distinguish between events declared by the framework, and events declared by the user.

class enaml.core.declarative.Declarative(parent=None, **kwargs)[source]

Bases: enaml.core.object.Object

The most base class of the Enaml declarative objects.

This class provides the core functionality required of declarative Enaml types. It can be used directly in a declarative Enaml object tree to store and react to state changes. It has no concept of a visual representation; that functionality is added by subclasses.

self = None

A readonly property which returns the current instance of the component. This allows declarative Enaml expressions to access ‘self’ according to Enaml’s dynamic scoping rules.

__init__(parent=None, **kwargs)[source]

Initialize a declarative component.

Parameters:parent (Object or None, optional) – The Object instance which is the parent of this object, or None if the object has no parent. Defaults to None.
**kwargs
Additional keyword arguments needed for initialization.
operators = None

The operator context used to build out this instance. This is assigned during object instantiation. It should not be edited by user code.

bind_expression(name, expression)[source]

Bind an expression to the given attribute name.

This method can be called to bind a value-providing expression to the given attribute name. If the named attribute does not exist, an exception is raised.

Parameters:
  • name (string) – The name of the attribute on which to bind the expression.
  • expression (AbstractExpression) – A concrete implementation of AbstractExpression. This value is not type checked for performance reasons. It is assumed that the caller provides a correct value.
bind_listener(name, listener)[source]

A private method used by the Enaml execution engine.

This method is called by the Enaml operators to bind the given listener object to the given attribute name. If the attribute does not exist, an exception is raised. A strong reference to the listener object is kept internally.

Parameters:
  • name (string) – The name of the attribute on which to bind the listener.
  • listener (AbstractListener) – A concrete implementation of AbstractListener. This value is not type checked for performance reasons. It is assumed that the caller provides a correct value.
__implements__

alias of __NoInterface__

eval_expression(name)[source]

Evaluate a bound expression with the given name.

Parameters:name (str) – The name of the attribute with the bound expression.
Returns:result (object or NotImplemented) – The result of evaluating the expression, or NotImplemented if there is no expression bound to the given name.
refresh_expression(name)[source]

Refresh the value of a bound expression.

Parameters:name (str) – The attribute name to which the invalid expression is bound.
run_listeners(name, old, new)[source]

Run the listeners bound to the given attribute name.

Parameters:
  • name (str) – The name of the attribute with the bound listeners.
  • old (object) – The old value to pass to the listeners.
  • new (object) – The new value to pass to the listeners.

enaml_ast Module

Inheritance diagram of enaml.core.enaml_ast

class enaml.core.enaml_ast.ASTNode(lineno)[source]

Bases: object

The base Enaml AST node.

lineno = int

The line number in the source code that created this node.

__weakref__

list of weak references to the object (if defined)

class enaml.core.enaml_ast.Module(body, lineno)[source]

Bases: enaml.core.enaml_ast.ASTNode

An AST node representing an Enaml module.

doc = str

The module’s documentation string.

body = list

A list of ast nodes comprising the body of the module.

class enaml.core.enaml_ast.Python(py_ast, lineno)[source]

Bases: enaml.core.enaml_ast.ASTNode

An AST node representing a chunk of pure Python code.

py_ast = ast.AST

A Python ast node.

class enaml.core.enaml_ast.Declaration(name, base, identifier, doc, body, lineno)[source]

Bases: enaml.core.enaml_ast.ASTNode

An AST node representing an Enaml declaration.

name = str

The name of the declaration.

base = str

The name of the base type.

identifier = str

The local identifier to use for instances of the declaration.

doc = str

The documentation string for the declaration.

body = list

A list of AST nodes that comprise the body of the declaration.

class enaml.core.enaml_ast.Instantiation(name, identifier, body, lineno)[source]

Bases: enaml.core.enaml_ast.ASTNode

An AST node representing a declaration instantiation.

name = str

The name of declaration being instantiated.

identifier = str

The local identifier to use for the new instance.

body = list

A list of AST nodes which comprise the instantiation body.

class enaml.core.enaml_ast.AttributeDeclaration(name, type, default, is_event, lineno)[source]

Bases: enaml.core.enaml_ast.ASTNode

An AST node which represents an attribute declaration.

name = str

The name of the attribute being declared.

type = str

A string representing the type of the attribute, or None if no type was given. If None the attribute can be of any type.

default = AttributeBinding or None

The default binding of the attribute, or None if no default is provided.

is_event = boolean

Whether or not this declaration represents an event. i.e. was declared with ‘event’ instead of ‘attr’.

class enaml.core.enaml_ast.AttributeBinding(name, binding, lineno)[source]

Bases: enaml.core.enaml_ast.ASTNode

An AST node which represents an expression attribute binding.

name = str

The name of the attribute being bound.

binding = BoundExpression

The BoundExpression ast node which represents the binding.

class enaml.core.enaml_ast.BoundExpression(op, expr, lineno)[source]

Bases: enaml.core.enaml_ast.ASTNode

An ast node which represents a bound expression.

op = str

The name of the operator that will perform the binding.

expr = Python

A Python ast node that reprents the bound expression.

enaml_compiler Module

enaml.core.enaml_compiler.update_firstlineno(code, firstlineno)[source]

Returns a new code object with an updated first line number.

enaml.core.enaml_compiler.replace_global_loads(codelist, explicit=None)[source]

A code transformer which rewrites LOAD_GLOBAL opcodes.

This transform will replace the LOAD_GLOBAL opcodes with LOAD_NAME opcodes. The operation is performed in-place.

Parameters:
  • codelist (list) – The list of byteplay code ops to modify.
  • explicit (set or None) – The set of global names declared explicitly and which should remain untransformed.
enaml.core.enaml_compiler.optimize_locals(codelist)[source]

Optimize the given code object for fast locals access.

All STORE_NAME opcodes will be replaced with STORE_FAST. Names which are stored and then loaded via LOAD_NAME are rewritten to LOAD_FAST and DELETE_NAME is rewritten to DELETE_FAST. This transformation is applied in-place.

Parameters:codelist (list) – The list of byteplay code ops to modify.
enaml.core.enaml_compiler.compile_simple(py_ast, filename)[source]

Compile an ast into a code object implementing operator =.

Parameters:
  • py_ast (ast.Expression) – A Python ast Expression node.
  • filename (str) – The filename which generated the expression.
Returns:

result (types.CodeType) – A Python code object which implements the desired behavior.

enaml.core.enaml_compiler.compile_notify(py_ast, filename)[source]

Compile an ast into a code object implementing operator ::.

Parameters:
  • py_ast (ast.Module) – A Python ast Module node.
  • filename (str) – The filename which generated the expression.
Returns:

result (types.CodeType) – A Python code object which implements the desired behavior.

enaml.core.enaml_compiler.compile_subscribe(py_ast, filename)[source]

Compile an ast into a code object implementing operator <<.

Parameters:
  • py_ast (ast.Expression) – A Python ast Expression node.
  • filename (str) – The filename which generated the expression.
Returns:

result (types.CodeType) – A Python code object which implements the desired behavior.

enaml.core.enaml_compiler.compile_update(py_ast, filename)[source]

Compile an ast into a code object implementing operator >>.

Parameters:
  • py_ast (ast.Expression) – A Python ast Expression node.
  • filename (str) – The filename which generated the expression.
Returns:

result (types.CodeType) – A Python code object which implements the desired behavior.

enaml.core.enaml_compiler.compile_delegate(py_ast, filename)[source]

Compile an ast into a code object implementing operator :=.

This will generate two code objects: one which is equivalent to operator << and another which is equivalent to >>.

Parameters:
  • py_ast (ast.Expression) – A Python ast Expression node.
  • filename (str) – The filename which generated the expression.
Returns:

result (tuple) – A 2-tuple of types.CodeType equivalent to operators << and >> respectively.

class enaml.core.enaml_compiler.DeclarationCompiler(filename)[source]

Bases: enaml.core.enaml_compiler._NodeVisitor

A visitor which compiles a Declaration node into a code object.

classmethod compile(node, filename)[source]

The main entry point of the DeclarationCompiler.

This compiler compiles the given Declaration node into a code object for a builder function.

Parameters:
  • node (Declaration) – The Declaration node to compiler.
  • filename (str) – The string filename to use for the generated code objects.
__init__(filename)[source]

Initialize a DeclarationCompiler.

Parameters:filename (str) – The filename string to use for the generated code object.
curr_name()[source]

Returns the current variable name on the stack.

visit_Declaration(node)[source]

Creates the bytecode ops for a declaration node.

This node visitor pulls the passed in root into a local var and stores it’s identifier if one is given. It also loads in the commonly used local variables f_globals, and eval_.

visit_AttributeDeclaration(node)[source]

Creates the bytecode ops for an attribute declaration.

The attributes will have already been added to the subclass, so this visitor just dispatches to any default bindings which may exist on the attribute declaration, since the binding happens at instantiation time via operators.

visit_AttributeBinding(node)[source]

Creates the bytecode ops for an attribute binding.

This visitor handles loading and calling the appropriate operator.

visit_Instantiation(node)[source]

Create the bytecode ops for a component instantiation.

This visitor handles calling another derived component and storing its identifier, if given.

class enaml.core.enaml_compiler.EnamlCompiler(filename)[source]

Bases: enaml.core.enaml_compiler._NodeVisitor

A visitor that will compile an enaml module ast node.

The entry point is the compile classmethod which will compile the ast into an appropriate python code object for a module.

classmethod compile(module_ast, filename)[source]

The main entry point of the compiler.

Parameters:
  • module_ast (Instance(enaml_ast.Module)) – The enaml module ast node that should be compiled.
  • filename (str) – The string filename of the module ast being compiled.
__init__(filename)[source]

Initialize an EnamlCompiler.

Parameters:filename (str) – The string filename of the module ast being compiled.
visit_Module(node)[source]

The Module node visitor method.

This visitor dispatches to all of the body nodes of the module.

visit_Python(node)[source]

The Python node visitor method.

This visitor adds a chunk of raw Python into the module.

visit_Declaration(node)[source]

The Declaration node visitor.

This generates the bytecode ops whic create a new type for the enamldef and then adds the user defined attributes and events. It also dispatches to the DeclarationCompiler which will create the builder function for the new type.

visit_AttributeDeclaration(node)[source]

Creates the bytecode ops for an attribute declaration.

This will add the ops to add the user attrs and events to the new type.

enaml_def Module

class enaml.core.enaml_def.EnamlDef[source]

Bases: traits.has_traits.MetaHasTraits

The type of an enamldef.

This is a metaclass used to create types for the ‘enamldef’ keyword. Aside from a redefined __repr__ method, this type contains no logic. It exists to allow users to distinguish between normal classes and those which have be created by an enamldef keyword.

All of the logic for handling the builder functions created by the Enaml compiler is included on the base Declarative class.

expressions Module

Inheritance diagram of enaml.core.expressions.AbstractExpression, enaml.core.expressions.SimpleExpression, enaml.core.expressions.NotificationExpression, enaml.core.expressions.UpdateExpression, enaml.core.expressions.SubscriptionExpression, enaml.core.expressions.DelegationExpression

class enaml.core.expressions.TraitsTracer[source]

Bases: enaml.core.code_tracing.CodeTracer

A CodeTracer for tracing expressions which use Traits.

This tracer maintains a running set of traced_items which are the (obj, name) pairs of traits items discovered during tracing.

__init__()[source]

Initialize a TraitsTracer.

dynamic_load(obj, attr, value)[source]

Called when an object attribute is dynamically loaded.

This will trace the object if it is a HasTraits instance. See also: AbstractScopeListener.dynamic_load.

load_attr(obj, attr)[source]

Called before the LOAD_ATTR opcode is executed.

This will trace the object if it is a HasTraits instance. See also: CodeTracer.dynamic_load.

call_function(func, argtuple, argspec)[source]

Called before the CALL_FUNCTION opcode is executed.

This will trace the func is the builtin getattr and the object is a HasTraits instance. See also: CodeTracer.call_function

binary_subscr(obj, idx)[source]

Called before the BINARY_SUBSCR opcode is executed.

This will trace the object if it is a TraitListObject or a TraitDictObject. See also: CodeTracer.get_iter.

get_iter(obj)[source]

Called before the GET_ITER opcode is executed.

This will trace the object if it is a TraitListObject See also: CodeTracer.get_iter.

class enaml.core.expressions.StandardInverter(nonlocals)[source]

Bases: enaml.core.code_tracing.CodeInverter

The standard code inverter for Enaml expressions.

__init__(nonlocals)[source]

Initialize a StandardInverter.

Parameters:nonlocals (Nonlocals) – The nonlocal scope for the executing expression.
load_name(name, value)[source]

Called before the LOAD_NAME opcode is executed.

This method performs STORE_NAME by storing to the nonlocals. See also: CodeInverter.load_name.

load_attr(obj, attr, value)[source]

Called before the LOAD_ATTR opcode is executed.

This method performs STORE_ATTR via the builtin setattr. See also: CodeInverter.load_attr.

call_function(func, argtuple, argspec, value)[source]

Called before the CALL_FUNCTION opcode is executed.

This method inverts a call to the builtin getattr into a call to the builtin setattr. All other calls will raise. See also: CodeInverter.call_function.

binary_subscr(obj, idx, value)[source]

Called before the BINARY_SUBSCR opcode is executed.

This method performs a STORE_SUBSCR operation through standard setitem semantics. See also: CodeInverter.binary_subscr.

class enaml.core.expressions.BaseExpression(func, f_locals)[source]

Bases: object

The base class of the standard Enaml expression classes.

__init__(func, f_locals)[source]

Initialize a BaseExpression.

Parameters:
  • func (types.FunctionType) – A function created by the Enaml compiler with bytecode that has been patched to support the semantics required of the expression.
  • f_locals (dict) – The dictionary of local identifiers for the function.
class enaml.core.expressions.SimpleExpression(func, f_locals)[source]

Bases: enaml.core.expressions.BaseExpression

An implementation of AbstractExpression for the = operator.

eval(owner, name)[source]

Evaluate and return the expression value.

class enaml.core.expressions.NotificationEvent

Bases: tuple

NotificationEvent(obj, name, old, new)

__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

static __new__(_cls, obj, name, old, new)

Create new instance of NotificationEvent(obj, name, old, new)

__repr__()

Return a nicely formatted representation string

name

Alias for field number 1

new

Alias for field number 3

obj

Alias for field number 0

old

Alias for field number 2

class enaml.core.expressions.NotificationExpression(func, f_locals)[source]

Bases: enaml.core.expressions.BaseExpression

An implementation of AbstractListener for the :: operator.

value_changed(owner, name, old, new)[source]

Called when the attribute on the owner has changed.

class enaml.core.expressions.UpdateExpression(func, f_locals)[source]

Bases: enaml.core.expressions.BaseExpression

An implementation of AbstractListener for the >> operator.

value_changed(owner, name, old, new)[source]

Called when the attribute on the owner has changed.

class enaml.core.expressions.SubscriptionNotifier(owner, name, keyval)[source]

Bases: object

A simple object used for attaching notification handlers.

__init__(owner, name, keyval)[source]

Initialize a SubscriptionNotifier.

Parameters:
  • owner (Declarative) – The declarative object which owns the expression.
  • name (str) – The name to which the expression is bound.
  • keyval (object) – An object to use for testing equivalency of notifiers.
notify()[source]

Notify that the expression is invalid.

__weakref__

list of weak references to the object (if defined)

class enaml.core.expressions.SubscriptionExpression(func, f_locals)[source]

Bases: enaml.core.expressions.BaseExpression

An implementation of AbstractExpression for the << operator.

__init__(func, f_locals)[source]

Initialize a SubscriptionExpression.

eval(owner, name)[source]

Evaluate and return the expression value.

class enaml.core.expressions.DelegationExpression(func, f_locals)[source]

Bases: enaml.core.expressions.SubscriptionExpression

An expression and listener implementation for the := operator.

value_changed(owner, name, old, new)[source]

Called when the attribute on the owner has changed.

funchelper Module

enaml.core.funchelper.call_func(func, args, kwargs, f_locals=None)[source]

Call a function which has been modified by the Enaml compiler to support tracing and dynamic scoping.

Parameters:
  • func (types.FunctionType) – The Python function to call.
  • args (tuple) – The tuple of arguments to pass to the function.
  • kwargs (dict) – The dictionary of keywords to pass to the function.
  • f_locals (mapping, optional) – An optional locals mapping to use with the function.
Returns:

result (object) – The result of calling the function.

import_hooks Module

class enaml.core.import_hooks.EnamlFileInfo

Bases: tuple

EnamlFileInfo(src_path, cache_path, cache_dir)

__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

static __new__(_cls, src_path, cache_path, cache_dir)

Create new instance of EnamlFileInfo(src_path, cache_path, cache_dir)

__repr__()

Return a nicely formatted representation string

cache_dir

Alias for field number 2

cache_path

Alias for field number 1

src_path

Alias for field number 0

enaml.core.import_hooks.make_file_info(src_path)[source]

Create an EnamlFileInfo object for the given src_path.

Parameters:src_path (string) – The full path to the .enaml file.
Returns:result (FileInfo) – A properly populated EnamlFileInfo object.
class enaml.core.import_hooks.AbstractEnamlImporter[source]

Bases: object

An abstract base class which defines the api required to implement an Enaml importer.

__metaclass__

alias of ABCMeta

classmethod install()[source]

Appends this importer into sys.meta_path.

classmethod uninstall()[source]

Removes this importer from sys.meta_path.

classmethod find_module(fullname, path=None)[source]

Finds the given Enaml module and returns an importer, or None if the module is not found.

load_module(fullname)[source]

Loads and returns the Python module for the given enaml path. If a module already exisist in sys.path, the existing module is reused, otherwise a new one is created.

classmethod locate_module(fullname, path=None)[source]

Searches for the given Enaml module and returns an instance of AbstractEnamlImporter on success.

Paramters

fullname : string
The fully qualified name of the module.
path : string or None
The subpackage __path__ for submodules and subpackages or None if a top-level module.
Returns:result (Instance(AbstractEnamlImporter) or None) – If the Enaml module is located an instance of the importer that will perform the rest of the operations is returned. Otherwise, returns None.
get_code()[source]

Loads and returns the code object for the Enaml module and the full path to the module for use as the __file__ attribute of the module.

Returns:result ((code, path)) – The Python code object for the .enaml module, and the full path to the module as a string.
__weakref__

list of weak references to the object (if defined)

class enaml.core.import_hooks.EnamlImporter(file_info)[source]

Bases: enaml.core.import_hooks.AbstractEnamlImporter

The standard Enaml importer which can import Enaml modules from standard locations on the python path and compile them appropriately to .enamlc files.

This importer adopts the Python 3 conventions and scheme for creating the cached files and setting the __file__ attribute on the module. See this discussion thread for more info: http://www.mail-archive.com/python-dev@python.org/msg45203.html

classmethod locate_module(fullname, path=None)[source]

Searches for the given Enaml module and returns an instance of this class on success.

Paramters

fullname : string
The fully qualified name of the module.
path : list or None
The subpackage __path__ for submodules and subpackages or None if a top-level module.
Returns:results (Instance(AbstractEnamlImporter) or None) – If the Enaml module is located an instance of the importer that will perform the rest of the operations is returned. Otherwise, returns None.
__init__(file_info)[source]

Initialize an importer object.

Parameters:file_info (EnamlFileInfo) – An instance of EnamlFileInfo.
get_code()[source]

Loads and returns the code object for the Enaml module and the full path to the module for use as the __file__ attribute of the module.

Returns:result ((code, path)) – The Python code object for the .enaml module, and the full path to the module as a string.
class enaml.core.import_hooks.imports[source]

Bases: object

A context manager that hooks/unhooks the enaml meta path importer for the duration of the block. The helps user avoid unintended consequences of a having a meta path importer slow down all of their other imports.

classmethod get_importers()[source]

Returns a tuple of currently active importers in use for the framework.

classmethod add_importer(importer)[source]

Add an importer to the list of importers for use with the framework. It must be a subclass of AbstractEnamlImporter. The most recently appended importer is used first. If the importer has already been added, this is a no-op. To move an importer up in precedence, remove it and add it again.

classmethod remove_importer(importer)[source]

Removes the importer from the list of active importers. If the importer is not in the list, this is a no-op.

__init__()[source]

Initializes an Enaml import context.

__enter__()[source]

Installs the current importer upon entering the context.

__exit__(*args, **kwargs)[source]

Uninstalls the current importer when leaving the context.

__weakref__

list of weak references to the object (if defined)

include Module

class enaml.core.include.Include(parent=None, **kwargs)[source]

Bases: enaml.core.declarative.Declarative

An object which dynamically inserts children into its parent.

The Include object is used to cleanly and easily insert objects into the children of its parent. Object instances assigned to the objects list of the Include will be parented with the parent of the Include. The parent of an Include should be an instance of Messenger; if this condition does not hold, the behavior will be undefined.

objects = None

The list of objects belonging to this Include. Objects in this list will be automatically parented with the Include’s parent.

destroy_old = None

A boolean flag indicating whether to destroy the old objects that are removed from the parent. The default is True.

init_objects()[source]

A method called by a parent widget to init the Include.

This method must be called by objects to initialize the objects in an Include. It should be called before the parent initializes its children. This method should never be called by user code.

parent_event(event)[source]

Handle a ParentEvent for the Include.

If the object state is active the current include objects will be reparented to the new parent.

__implements__

alias of __NoInterface__

lexer Module

class enaml.core.lexer.EnamlLexer(filename='Enaml')[source]

Bases: object

messenger Module

class enaml.core.messenger.Messenger(parent=None, **kwargs)[source]

Bases: enaml.core.declarative.Declarative

A base class for creating messaging-enabled Enaml objects.

This is a Declarative subclass which provides convenient APIs for sharing state between a server-side Enaml object and a client-side implementation of that object. It also enables support for the Include object type.

loopback_guard = None

A loopback guard which can be used to prevent a notification cycle when setting attributes from within an action handler.

pre_initialize()[source]

A reimplemented initialization method.

This method will setup any Include children so that they may prepare their objects before the proper initialization pass.

post_initialize()[source]

A reimplemented post initialization method.

This method calls the bind method after calling the superclass class version.

bind()[source]

Called during initialization pass to bind change handlers.

This method is called at the end of widget initialization to provide a subclass the opportunity to setup any required change notification handlers for publishing their state to the client.

snapshot()[source]

Get a dictionary representation of the widget tree.

This method can be called to get a dictionary representation of the current state of the widget tree which can be used by client side implementation to construct their own implementation tree.

Returns:result (dict) – A serializable dictionary representation of the widget tree from this widget down.
snap_children()[source]

Get an iterable of children to include in the snapshot.

The default implementation returns the list of children which are instances of Messenger. Subclasses may reimplement this method if more control is needed.

Returns:result (list) – The list of children which are instances of Messenger.
class_name()[source]

Get the name of the class for this instance.

Returns:result (str) – The name of the class of this instance.
base_names()[source]

Get the list of base class names for this instance.

Returns:result (list) – The list of string names for the base classes of this instance. The list starts with the parent class of this instance and terminates with Object.
set_guarded(**attrs)[source]

Set attribute values from within a loopback guard.

This is a convenience method provided for subclasses to set the values of attributes from within a loopback guard. This prevents the change from being published back to client and reduces the chances of getting hung in a feedback loop.

**attrs
The attributes to set on the object from within a loopback guard context.
publish_attributes(*attrs)[source]

A convenience method provided for subclasses to publish attribute changes as actions to the client.

The action name is created by prefixing ‘set_‘ to the name of the changed attribute. This method is suitable for most cases of simple attribute publishing. More complex cases will need to implement their own dispatching handlers. The handler for the changes will only send the action message if the attribute name is not held by the loopback guard.

*attrs
The string names of the attributes to publish to the client. The values of these attributes should be JSON serializable. More complex values should use their own dispatch handlers.
__implements__

alias of __NoInterface__

children_event(event)[source]

Handle a ChildrenEvent for the widget.

If the widget state is ‘active’, a children_changed action will be sent to the client widget. The action is sent before the superclass’ handler is called, and will therefore precede the trait change notification.

object Module

enaml.core.object.dispatch_action(obj, name, *args)

The dispatch function for action dispatching.

class enaml.core.object.ChildrenEvent

Bases: tuple

A namedtuple which contains information about a child change event. The old slot will be the ordered list of old children. The new slot will be the ordered list of new children.

__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

static __new__(_cls, old, new)

Create new instance of ChildrenEvent(old, new)

__repr__()

Return a nicely formatted representation string

new

Alias for field number 1

old

Alias for field number 0

class enaml.core.object.ParentEvent

Bases: tuple

A namedtuple which contains information about a parent change event. The old slot will be the old parent and the new slot will be the new parent.

__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

static __new__(_cls, old, new)

Create new instance of ParentEvent(old, new)

__repr__()

Return a nicely formatted representation string

new

Alias for field number 1

old

Alias for field number 0

enaml.core.object.object_id_generator = <generator object id_generator at 0x03EE14B8>

The identifier generator for object instances.

class enaml.core.object.ChildrenEventContext(parent)[source]

Bases: object

A context manager which will emit a child event on an Object.

This context manager will automatically emit the child event on an Object when the context is exited. This context manager can also be safetly nested; only the top-level context for a given object will emit the child event, effectively collapsing all transient state.

__init__(parent)[source]

Initialize a ChildrenEventContext.

Parameters:parent (Object or None) – The Object on which to emit a child event on context exit. To make it easier for reparenting operations, the parent can be None.
__enter__()[source]

Enter the children event context.

This method will snap the current child state of the parent and use it to diff the state on context exit.

__exit__(exc_type, exc_value, traceback)[source]

Exit the children event context.

If this context manager is the top-level manager for the parent object and no exception occured in the context, then a child event will be emitted on the parent. Any exception raised during the context is propagated.

__weakref__

list of weak references to the object (if defined)

class enaml.core.object.Object(parent=None, **kwargs)[source]

Bases: traits.has_traits.HasStrictTraits

The most base class of the Enaml object hierarchy.

An Enaml Object provides supports parent-children relationships and provides facilities for initializing, navigating, searching, and destroying the tree. It also contains methods for sending messages between objects when the object is part of a session.

name = None

An optional name to give to this object to assist in finding it in the tree (see . the ‘find’ method. Note that there is no guarantee of uniqueness for an object name. It is left to the developer to choose an appropriate name.

parent = None

A read-only property which returns the object’s parent. This will be an instance Object or None if there is no parent. A strong reference is kept to the parent object.

children = None

A read-only property which returns the objects children. This will be an iterable of Object instances. A strong reference is kept to all child objects.

initialized = None

An event fired when an the oject has been initialized. It is emitted once during an object’s lifetime, when the object is initialized by a Session.

activated = None

An event fired when an object has been activated. It is emitted once during an object’s lifetime, when the object is activated by a Session.

destroyed = None

An event fired when an object is being destroyed. This event is fired once during the object lifetime, just before the object is removed from the tree structure.

session = None

A read-only property which returns the object’s session. This will be an instance of Session or None if there is no session. A strong reference is kept to the session object. This value should not be manipulated by user code.

object_id = None

A read-only value which returns the object’s identifier. This will be computed the first time it is requested. The default value is guaranteed to be unique for the current process. The initial value may be supplied by user code if more control is required, with proper care that the value is a unique string.

state = None

The current state of the object in terms of its lifetime within a session. This value should not be manipulated by user code.

is_inactive = None

A read-only property which is True if the object is inactive.

is_initializing = None

A read-only property which is True if the object is initializing.

is_initialized = None

A read-only property which is True if the object is initialized.

is_activating = None

A read-only property which is True if the object is activating.

is_active = None

A read-only property which is True if the object is active.

is_destroying = None

A read-only property which is True if the object is destroying.

is_destroyed = None

A read-only property which is True if the object is destroyed.

__init__(parent=None, **kwargs)[source]

Initialize an Object.

Parameters:parent (Object or None, optional) – The Object instance which is the parent of this object, or None if the object has no parent. Defaults to None.
**kwargs
Additional keyword arguments to apply to the object after the parent has been set.
initialize()[source]

Called by a Session to initialize the object tree.

This method is called by a Session object to allow the object tree to perform initialization before the object is activated for messaging.

pre_initialize()[source]

Called during the initialization pass before any children are initialized.

The object state during this call will be ‘initializing’.

post_initialize()[source]

Called during the initialization pass after all children have been initialized.

The object state during this call will be ‘initialized’. The default implementation of this method emits the initialized event.

activate(session)[source]

Called by a Session to activate the object tree.

This method is called by a Session object to activate the object tree for messaging.

Parameters:session (Session) – The session to use for messaging with this object tree.
pre_activate(session)[source]

Called during the activation pass before any children are activated.

The object state during this call will be ‘activating’.

Parameters:session (Session) – The session to use for messaging with this object tree.
post_activate(session)[source]

Called during the activation pass after all children are activated.

The object state during this call will be ‘active’. The default implementation emits the activated event.

Parameters:session (Session) – The session to use for messaging with this object tree.
destroy()[source]

Destroy this object and all of its children recursively.

This will emit the destroyed event before any change to the object tree is made. After this returns, the object should be considered invalid and should no longer be used.

pre_destroy()[source]

Called during the destruction pass before any children are destroyed.

The object state during this call will be ‘destroying’. The default implementation emits the destroyed event.

post_destroy()[source]

Called during the destruction pass after all children are destroyed.

The object state during this call will be ‘destroyed’. This allows subclasses to perform cleanup once the object has been fully removed from the hierarchy.

set_parent(parent)[source]

Set the parent for this object.

If the parent is not None, the child will be appended to the end of the parent’s children. If the parent is already the parent of this object, then this method is a no-op. If this object already has a parent, then it will be properly reparented.

Parameters:parent (Object or None) – The Object instance to use for the parent, or None if this object should be unparented.

Note

It is the responsibility of the caller to intialize and activate the object if it is reparented dynamically at runtime and should be involved with a session.

insert_children(before, insert)[source]

Insert children into this object at the given location.

The children will be automatically parented and inserted into the object’s children. If any children are already children of this object, then they will be moved appropriately.

Parameters:
  • before (Object or None) – A child object to use as the marker for inserting the new children. The new children will be inserted directly before this marker. If the Object is None or not a child, then the new children will be added to the end of the children.
  • insert (iterable) – An iterable of Object children to insert into this object.

Note

It is the responsibility of the caller to intialize and activate the object if it is reparented dynamically at runtime and should be involved with a session.

parent_event(event)[source]

Handle a ParentEvent posted to this object.

This event handler is called when the parent on the object has changed, but before the children of the new parent have been updated. Sublasses may reimplement this method as required. The default implementation emits the trait change notification, so subclasses which rely on that notification must be sure to call super(...) when reimplmenting this method.

Parameters:event (ParentEvent) – The event for the parent change of this object.
children_event(event)[source]

Handle a ChildrenEvent posted to this object.

This event handler is called by a ChildrenEventContext when the last nested context is exited. The default implementation emits the trait change notification, so subclasses which rely on that notification must be sure to call super(...) when reimplmenting this method.

Parameters:event (ChildrenEvent) – The event for the children change of this object.
send_action(action, content)[source]

Send an action to the client of this object.

The action will only be sent if the current state of the object is active. Subclasses may reimplement this method if more control is needed.

Parameters:
  • action (str) – The name of the action which the client should perform.
  • content (dict) – The content data for the action.
receive_action(action, content)[source]

Receive an action from the client of this object.

The default implementation will dynamically dispatch the action to specially named handlers if the current state of the object is ‘active’. Subclasses may reimplement this method if more control is needed.

Parameters:
  • action (str) – The name of the action to perform.
  • content (dict) – The content data for the action.
traverse(depth_first=False)[source]

Yield all of the objects in the tree, from this object down.

Parameters:depth_first (bool, optional) – If True, yield the nodes in depth first order. If False, yield the nodes in breadth first order. Defaults to False.
traverse_ancestors(root=None)[source]

Yield all of the objects in the tree, from this object up.

Parameters:root (Object, optional) – The object at which to stop traversal. Defaults to None.
find(name, regex=False)[source]

Find the first object in the subtree with the given name.

This method will traverse the tree of objects, breadth first, from this object downward, looking for an object with the given name. The first object with the given name is returned, or None if no object is found with the given name.

Parameters:
  • name (string) – The name of the object for which to search.
  • regex (bool, optional) – Whether the given name is a regex string which should be matched against the names of children instead of tested for equality. Defaults to False.
Returns:

result (Object or None) – The first object found with the given name, or None if no object is found with the given name.

find_all(name, regex=False)[source]

Find all objects in the subtree with the given name.

This method will traverse the tree of objects, breadth first, from this object downward, looking for a objects with the given name. All of the objects with the given name are returned as a list.

Parameters:
  • name (string) – The name of the objects for which to search.
  • regex (bool, optional) – Whether the given name is a regex string which should be matched against the names of objects instead of testing for equality. Defaults to False.
Returns:

result (list of Object) – The list of objects found with the given name, or an empty list if no objects are found with the given name.

__implements__

alias of __NoInterface__

set = None

The HasTraits class defines a class attribute ‘set’ which is a deprecated alias for the ‘trait_set’ method. The problem is that having that as an attribute interferes with the ability of Enaml expressions to resolve the builtin ‘set’, since dynamic scoping takes precedence over builtins. This resets those ill-effects.

add_notifier(name, notifier)[source]

Add a notifier to a trait on the object.

This is different from on_trait_change in that it allows the developer to provide the notifier object directly. This allows the possibility of more efficient notifier patterns.

operator_context Module

class enaml.core.operator_context.OperatorContext[source]

Bases: dict

The Enaml operator context which provides the binding operators for Enaml components and a means by which developers can author custom operators.

The OperatorContext is a dict subclass which is used by the Enaml runtime to lookup the operator functions required to bind an expression to an attribute of a component.

static active_context()[source]

A staticmethod that returns the currently active operator context, or the default context if there is not active context.

static default_context()[source]

A staticmethod that returns the default operator context, creating one if necessary.

__enter__()[source]

A context manager method that pushes this context onto the active context stack.

__exit__(exc_type, exc_value, traceback)[source]

A context manager method that pops this context from the active context stack.

__weakref__

list of weak references to the object (if defined)

operators Module

The default Enaml operators.

The operator functions are called by the Enaml runtime to implement the expression binding semantics of the Enaml operators. The functions are passed a number of arguments in order to perform their work:

Parameters

obj : Declarative
The Declarative object which owns the expression which is being bound.
name : string
The name of the attribute on the object which is being bound.
func : types.FunctionType
A function with bytecode that has been patched by the Enaml compiler for semantics specific to the operator. The docs for each operator given a more complete description of this function, since it varies for each operator.
identifiers : dict
The dictionary of identifiers available to the expression. This dict is shared amongst all expressions within a given lexical scope. It should therefore not be modified or copied since identifiers may continue to be added to this dict as runtime execution continues.
enaml.core.operators.op_simple(obj, name, func, identifiers)[source]

The default Enaml operator for = expressions.

This operator binds an instance of SimpleExpression to the attribute on the object. The function takes no arguments and returns the value of the expression. It is patched for dynamic scoping and it should be invoked with funchelper.call_func(...).

enaml.core.operators.op_notify(obj, name, func, identifiers)[source]

The default Enaml operator for :: expressions.

This operator binds an instance of NotificationExpression to the attribute on the object. The function takes no arguments and will return None. It is patched for dynamic scoping and it should be invoked with funchelper.call_func(...).

enaml.core.operators.op_update(obj, name, func, identifiers)[source]

The default Enaml operator for >> expressions.

This operator binds an instance of UpdateExpression to the attribute on the object. The function takes two arguments: a code inverter and the new value of the attribute, and returns None. It is patched for dynamic scoping and code inversion and it should be invoked with funchelper.call_func(...).

enaml.core.operators.op_subscribe(obj, name, func, identifiers)[source]

The default Enaml operator for << expressions.

This operator binds an instance of SubscriptionExpression to the attribute on the object. The function takes one argument: a code tracer, and returns the value of the expression. It is patched for dynamic scoping and code tracing and it should be invoked with funchelper.call_func(...).

enaml.core.operators.op_delegate(obj, name, func, identifiers)[source]

The default Enaml operator for := expressions.

This operator binds an instance of DelegationExpression to the attribute on the object. The semantics of the function are the same as that of op_subscribe. The function also has an attribute named _update which is a function implementing op_update semantics. Both functions should be invoked with funchelper.call_func(...). In this fashion, op_delegate is the combination of op_subscribe and op_update.

parser Module

class enaml.core.parser.FakeToken(lexer, lineno)[source]

Bases: object

A fake token used to store the lexer before calling the syntax error functions.

__weakref__

list of weak references to the object (if defined)

enaml.core.parser.translate_operator(op)[source]

Converts a symbolic operator into a string of the form __operator_<name>__ where <name> is result of translating the symbolic operator using the operator_table.

enaml.core.parser.set_context(node, ctx, p)[source]

Recursively sets the context of the node to the given context which should be Store or Del. If the node is not one of the allowed types for the context, an erro is raised with an appropriate message.

enaml.core.parser.ast_for_testlist(testlist)[source]

If the testlist is a list, returns an ast.Tuple with a Load context, otherwise returns the orginal node.

enaml.core.parser.validate_invertable(node, lineno, p)[source]

Validates that its possible for the compiler to generated inversion code for the given ast node.

Currently, code is invertable if the expression terminates with a node of the following types: Name, Attribute, Call, Subscript.

Parameters:
  • node (ast.AST) – The ast expression node to validate.
  • lineno (int) – The line number of the declaration.
  • p (Yacc Production) – The Ply object passed to the parser rule. This is used to extract the filename for syntax error reporting.
enaml.core.parser.build_attr_declaration(kw, name, attr_type, default, lineno, p)[source]

Builds an ast node for an attr or event declaration.

Parameters:
  • kw (string) – The keyword used in the declaration. A syntax error is raised if this is not ‘attr’ or ‘event’.
  • name (string) – The name of the attribute or event being declared.
  • attr_type (str or None) – The type being declared, or None if not using a type.
  • default (AttributeBinding or None) – The default attribute binding or None if not supply the default.
  • lineno (int) – The line number of the declaration.
  • p (Yacc Production) – The Ply object passed to the parser rule. This is used to extract the filename for syntax error reporting.
Returns:

result (AttributeDeclaration) – The Enaml AttributeDeclaration ast node.

class enaml.core.parser.CommaSeparatedList(values=None)[source]

Bases: object

A parsing helper to delineate a comma separated list.

__weakref__

list of weak references to the object (if defined)

class enaml.core.parser.GeneratorInfo(elt=None, generators=None)[source]

Bases: object

A parsing helper to delineate a generator body.

__weakref__

list of weak references to the object (if defined)

class enaml.core.parser.Arguments(args=None, keywords=None, starargs=None, kwargs=None)[source]

Bases: object

A parsing helper object to delineate call arguments.

__weakref__

list of weak references to the object (if defined)

enaml.core.parser.p_enaml1(p)[source]

enaml : enaml_module NEWLINE ENDMARKER | enaml_module ENDMARKER

enaml.core.parser.p_enaml2(p)[source]

enaml : NEWLINE ENDMARKER | ENDMARKER

enaml.core.parser.p_enaml_module(p)[source]

enaml_module : enaml_module_body

enaml.core.parser.p_enaml_module_body1(p)[source]

enaml_module_body : enaml_module_body enaml_module_item

enaml.core.parser.p_enaml_module_body2(p)[source]

enaml_module_body : enaml_module_item

enaml.core.parser.p_enaml_module_item2(p)[source]

enaml_module_item : declaration

enaml.core.parser.p_enaml_module_item1(p)[source]

enaml_module_item : stmt

enaml.core.parser.p_declaration1(p)[source]

declaration : ENAMLDEF NAME LPAR NAME RPAR COLON declaration_body

enaml.core.parser.p_declaration2(p)[source]

declaration : ENAMLDEF NAME LPAR NAME RPAR COLON PASS NEWLINE

enaml.core.parser.p_declaration3(p)[source]

declaration : ENAMLDEF NAME LPAR NAME RPAR COLON NAME COLON declaration_body

enaml.core.parser.p_declaration4(p)[source]

declaration : ENAMLDEF NAME LPAR NAME RPAR COLON NAME COLON PASS NEWLINE

enaml.core.parser.p_declaration_body1(p)[source]

declaration_body : NEWLINE INDENT declaration_body_items DEDENT

enaml.core.parser.p_declaration_body2(p)[source]

declaration_body : NEWLINE INDENT identifier DEDENT

enaml.core.parser.p_declaration_body3(p)[source]

declaration_body : NEWLINE INDENT identifier declaration_body_items DEDENT

enaml.core.parser.p_declaration_body4(p)[source]

declaration_body : NEWLINE INDENT STRING NEWLINE declaration_body_items DEDENT

enaml.core.parser.p_declaration_body5(p)[source]

declaration_body : NEWLINE INDENT STRING NEWLINE identifier DEDENT

enaml.core.parser.p_declaration_body6(p)[source]

declaration_body : NEWLINE INDENT STRING NEWLINE identifier declaration_body_items DEDENT

enaml.core.parser.p_declaration_body_items1(p)[source]

declaration_body_items : declaration_body_item

enaml.core.parser.p_declaration_body_items2(p)[source]

declaration_body_items : declaration_body_items declaration_body_item

enaml.core.parser.p_declaration_body_item1(p)[source]

declaration_body_item : attribute_declaration

enaml.core.parser.p_declaration_body_item2(p)[source]

declaration_body_item : attribute_binding

enaml.core.parser.p_declaration_body_item3(p)[source]

declaration_body_item : instantiation

enaml.core.parser.p_declaration_body_item4(p)[source]

declaration_body_item : PASS NEWLINE

enaml.core.parser.p_attribute_declaration1(p)[source]

attribute_declaration : NAME NAME NEWLINE

enaml.core.parser.p_attribute_declaration2(p)[source]

attribute_declaration : NAME NAME COLON NAME NEWLINE

enaml.core.parser.p_attribute_declaration3(p)[source]

attribute_declaration : NAME NAME binding

enaml.core.parser.p_attribute_declaration4(p)[source]

attribute_declaration : NAME NAME COLON NAME binding

enaml.core.parser.p_identifier(p)[source]

identifier : NAME COLON NAME NEWLINE

enaml.core.parser.p_instantiation1(p)[source]

instantiation : NAME COLON instantiation_body

enaml.core.parser.p_instantiation2(p)[source]

instantiation : NAME COLON attribute_binding

enaml.core.parser.p_instantiation3(p)[source]

instantiation : NAME COLON PASS NEWLINE

enaml.core.parser.p_instantiation4(p)[source]

instantiation : NAME COLON NAME COLON instantiation_body

enaml.core.parser.p_instantiation5(p)[source]

instantiation : NAME COLON NAME COLON attribute_binding

enaml.core.parser.p_instantiation6(p)[source]

instantiation : NAME COLON NAME COLON PASS NEWLINE

enaml.core.parser.p_instantiation_body1(p)[source]

instantiation_body : NEWLINE INDENT instantiation_body_items DEDENT

enaml.core.parser.p_instantiation_body2(p)[source]

instantiation_body : NEWLINE INDENT identifier DEDENT

enaml.core.parser.p_instantiation_body3(p)[source]

instantiation_body : NEWLINE INDENT identifier instantiation_body_items DEDENT

enaml.core.parser.p_instantiation_body_items1(p)[source]

instantiation_body_items : instantiation_body_item

enaml.core.parser.p_instantiation_body_items2(p)[source]

instantiation_body_items : instantiation_body_items instantiation_body_item

enaml.core.parser.p_instantiation_body_item1(p)[source]

instantiation_body_item : instantiation

enaml.core.parser.p_instantiation_body_item2(p)[source]

instantiation_body_item : attribute_binding

enaml.core.parser.p_instantiation_body_item3(p)[source]

instantiation_body_item : PASS NEWLINE

enaml.core.parser.p_attribute_binding(p)[source]

attribute_binding : NAME binding

enaml.core.parser.p_binding1(p)[source]

binding : EQUAL test NEWLINE | LEFTSHIFT test NEWLINE

enaml.core.parser.p_binding2(p)[source]

binding : COLONEQUAL test NEWLINE | RIGHTSHIFT test NEWLINE

enaml.core.parser.p_binding3(p)[source]

binding : DOUBLECOLON suite

enaml.core.parser.p_suite1(p)[source]

suite : simple_stmt

enaml.core.parser.p_suite2(p)[source]

suite : NEWLINE INDENT stmt_list DEDENT

enaml.core.parser.p_stmt_list1(p)[source]

stmt_list : stmt stmt_list

enaml.core.parser.p_stmt_list2(p)[source]

stmt_list : stmt

enaml.core.parser.p_stmt(p)[source]

stmt : simple_stmt | compound_stmt

enaml.core.parser.p_simple_stmt1(p)[source]

simple_stmt : small_stmt NEWLINE

enaml.core.parser.p_simple_stmt2(p)[source]

simple_stmt : small_stmt_list NEWLINE

enaml.core.parser.p_small_stmt_list1(p)[source]

small_stmt_list : small_stmt SEMI

enaml.core.parser.p_small_stmt_list2(p)[source]

small_stmt_list : small_stmt small_stmt_list_list

enaml.core.parser.p_small_stmt_list3(p)[source]

small_stmt_list : small_stmt small_stmt_list_list SEMI

enaml.core.parser.p_small_stmt_list_list1(p)[source]

small_stmt_list_list : SEMI small_stmt

enaml.core.parser.p_small_stmt_list_list2(p)[source]

small_stmt_list_list : small_stmt_list_list SEMI small_stmt

enaml.core.parser.p_small_stmt1(p)[source]

small_stmt : expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | exec_stmt | assert_stmt

enaml.core.parser.p_print_stmt1(p)[source]

print_stmt : PRINT

enaml.core.parser.p_print_stmt2(p)[source]

print_stmt : PRINT test

enaml.core.parser.p_print_stmt3(p)[source]

print_stmt : PRINT print_list

enaml.core.parser.p_print_stmt4(p)[source]

print_stmt : PRINT RIGHTSHIFT test

enaml.core.parser.p_print_stmt5(p)[source]

print_stmt : PRINT RIGHTSHIFT test COMMA test

enaml.core.parser.p_print_stmt6(p)[source]

print_stmt : PRINT RIGHTSHIFT test COMMA print_list

enaml.core.parser.p_print_list1(p)[source]

print_list : test COMMA

enaml.core.parser.p_print_list2(p)[source]

print_list : test print_list_list

enaml.core.parser.p_print_list3(p)[source]

print_list : test print_list_list COMMA

enaml.core.parser.p_print_list_list1(p)[source]

print_list_list : COMMA test

enaml.core.parser.p_print_list_list2(p)[source]

print_list_list : print_list_list COMMA test

enaml.core.parser.p_del_stmt(p)[source]

del_stmt : DEL exprlist

enaml.core.parser.p_pass_stmt(p)[source]

pass_stmt : PASS

enaml.core.parser.p_flow_stmt(p)[source]

flow_stmt : break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt

enaml.core.parser.p_break_stmt(p)[source]

break_stmt : BREAK

enaml.core.parser.p_continue_stmt(p)[source]

continue_stmt : CONTINUE

enaml.core.parser.p_return_stmt1(p)[source]

return_stmt : RETURN

enaml.core.parser.p_return_stmt2(p)[source]

return_stmt : RETURN testlist

enaml.core.parser.p_raise_stmt1(p)[source]

raise_stmt : RAISE

enaml.core.parser.p_raise_stmt2(p)[source]

raise_stmt : RAISE test

enaml.core.parser.p_raise_stmt3(p)[source]

raise_stmt : RAISE test COMMA test

enaml.core.parser.p_raise_stmt4(p)[source]

raise_stmt : RAISE test COMMA test COMMA test

enaml.core.parser.p_yield_stmt(p)[source]

yield_stmt : yield_expr

enaml.core.parser.p_yield_expr1(p)[source]

yield_expr : YIELD

enaml.core.parser.p_yield_expr2(p)[source]

yield_expr : YIELD testlist

enaml.core.parser.p_global_stmt1(p)[source]

global_stmt : GLOBAL NAME

enaml.core.parser.p_global_stmt2(p)[source]

global_stmt : GLOBAL NAME globals_list

enaml.core.parser.p_globals_list1(p)[source]

globals_list : COMMA NAME globals_list

enaml.core.parser.p_globals_list2(p)[source]

globals_list : COMMA NAME

enaml.core.parser.p_exec_stmt1(p)[source]

exec_stmt : EXEC expr

enaml.core.parser.p_exec_stmt2(p)[source]

exec_stmt : EXEC expr IN test

enaml.core.parser.p_exec_stmt3(p)[source]

exec_stmt : EXEC expr IN test COMMA test

enaml.core.parser.p_assert_stmt1(p)[source]

assert_stmt : ASSERT test

enaml.core.parser.p_assert_stmt2(p)[source]

assert_stmt : ASSERT test COMMA test

enaml.core.parser.p_expr_stmt1(p)[source]

expr_stmt : testlist

enaml.core.parser.p_expr_stmt2(p)[source]

expr_stmt : testlist augassign testlist | testlist augassign yield_expr

enaml.core.parser.p_expr_stmt3(p)[source]

expr_stmt : testlist equal_list

enaml.core.parser.p_augassign(p)[source]

augassign : AMPEREQUAL | CIRCUMFLEXEQUAL | DOUBLESLASHEQUAL | DOUBLESTAREQUAL | LEFTSHIFTEQUAL | MINUSEQUAL | PERCENTEQUAL | PLUSEQUAL | RIGHTSHIFTEQUAL | SLASHEQUAL | STAREQUAL | VBAREQUAL

enaml.core.parser.p_equal_list1(p)[source]

equal_list : EQUAL testlist | EQUAL yield_expr

enaml.core.parser.p_equal_list2(p)[source]

equal_list : EQUAL testlist equal_list | EQUAL yield_expr equal_list

enaml.core.parser.p_testlist1(p)[source]

testlist : test

enaml.core.parser.p_testlist2(p)[source]

testlist : test COMMA

enaml.core.parser.p_testlist3(p)[source]

testlist : test testlist_list

enaml.core.parser.p_testlist4(p)[source]

testlist : test testlist_list COMMA

enaml.core.parser.p_testlist_list1(p)[source]

testlist_list : COMMA test

enaml.core.parser.p_testlist_list2(p)[source]

testlist_list : testlist_list COMMA test

enaml.core.parser.p_compound_stmt(p)[source]

compound_stmt : if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated

enaml.core.parser.p_if_stmt1(p)[source]

if_stmt : IF test COLON suite

enaml.core.parser.p_if_stmt2(p)[source]

if_stmt : IF test COLON suite elif_stmts

enaml.core.parser.p_if_stmt3(p)[source]

if_stmt : IF test COLON suite else_stmt

enaml.core.parser.p_if_stmt4(p)[source]

if_stmt : IF test COLON suite elif_stmts else_stmt

enaml.core.parser.p_elif_stmts1(p)[source]

elif_stmts : elif_stmts elif_stmt

enaml.core.parser.p_elif_stmts2(p)[source]

elif_stmts : elif_stmt

enaml.core.parser.p_elif_stmt(p)[source]

elif_stmt : ELIF test COLON suite

enaml.core.parser.p_else_stmt(p)[source]

else_stmt : ELSE COLON suite

enaml.core.parser.p_while_stmt1(p)[source]

while_stmt : WHILE test COLON suite

enaml.core.parser.p_while_stmt2(p)[source]

while_stmt : WHILE test COLON suite ELSE COLON suite

enaml.core.parser.p_for_stmt1(p)[source]

for_stmt : FOR exprlist IN testlist COLON suite

enaml.core.parser.p_for_stmt2(p)[source]

for_stmt : FOR exprlist IN testlist COLON suite ELSE COLON suite

enaml.core.parser.p_try_stmt1(p)[source]

try_stmt : TRY COLON suite FINALLY COLON suite

enaml.core.parser.p_try_stmt2(p)[source]

try_stmt : TRY COLON suite except_clauses

enaml.core.parser.p_try_stmt3(p)[source]

try_stmt : TRY COLON suite except_clauses ELSE COLON suite

enaml.core.parser.p_try_stmt4(p)[source]

try_stmt : TRY COLON suite except_clauses FINALLY COLON suite

enaml.core.parser.p_try_stmt5(p)[source]

try_stmt : TRY COLON suite except_clauses ELSE COLON suite FINALLY COLON suite

enaml.core.parser.p_except_clauses1(p)[source]

except_clauses : except_clause except_clauses

enaml.core.parser.p_except_clauses2(p)[source]

except_clauses : except_clause

enaml.core.parser.p_except_clause1(p)[source]

except_clause : EXCEPT COLON suite

enaml.core.parser.p_except_clause2(p)[source]

except_clause : EXCEPT test COLON suite

enaml.core.parser.p_except_clause3(p)[source]

except_clause : EXCEPT test AS test COLON suite | EXCEPT test COMMA test COLON suite

enaml.core.parser.p_with_stmt1(p)[source]

with_stmt : WITH with_item COLON suite

enaml.core.parser.p_with_stmt2(p)[source]

with_stmt : WITH with_item with_item_list COLON suite

enaml.core.parser.p_with_item1(p)[source]

with_item : test

enaml.core.parser.p_with_item2(p)[source]

with_item : test AS expr

enaml.core.parser.p_with_item_list1(p)[source]

with_item_list : COMMA with_item with_item_list

enaml.core.parser.p_with_item_list2(p)[source]

with_item_list : COMMA with_item

enaml.core.parser.p_funcdef(p)[source]

funcdef : DEF NAME parameters COLON suite

enaml.core.parser.p_parameters1(p)[source]

parameters : LPAR RPAR

enaml.core.parser.p_parameters2(p)[source]

parameters : LPAR varargslist RPAR

enaml.core.parser.p_classdef1(p)[source]

classdef : CLASS NAME COLON suite

enaml.core.parser.p_classdef2(p)[source]

classdef : CLASS NAME LPAR RPAR COLON suite

enaml.core.parser.p_classdef3(p)[source]

classdef : CLASS NAME LPAR testlist RPAR COLON suite

enaml.core.parser.p_decorated(p)[source]

decorated : decorators funcdef | decorators classdef

enaml.core.parser.p_decorators1(p)[source]

decorators : decorator decorators

enaml.core.parser.p_decorators2(p)[source]

decorators : decorator

enaml.core.parser.p_decorator1(p)[source]

decorator : AT dotted_name NEWLINE

enaml.core.parser.p_decorator2(p)[source]

decorator : AT dotted_name LPAR RPAR NEWLINE

enaml.core.parser.p_decorator3(p)[source]

decorator : AT dotted_name LPAR arglist RPAR NEWLINE

enaml.core.parser.p_import_stmt1(p)[source]

import_stmt : import_name

enaml.core.parser.p_import_stmt2(p)[source]

import_stmt : import_from

enaml.core.parser.p_import_name(p)[source]

import_name : IMPORT dotted_as_names

enaml.core.parser.p_import_from1(p)[source]

import_from : FROM dotted_name IMPORT STAR

enaml.core.parser.p_import_from2(p)[source]

import_from : FROM dotted_name IMPORT import_as_names

enaml.core.parser.p_import_from3(p)[source]

import_from : FROM dotted_name IMPORT LPAR import_as_names RPAR

enaml.core.parser.p_import_from4(p)[source]

import_from : FROM import_from_dots dotted_name IMPORT STAR

enaml.core.parser.p_import_from5(p)[source]

import_from : FROM import_from_dots dotted_name IMPORT import_as_name

enaml.core.parser.p_import_from6(p)[source]

import_from : FROM import_from_dots dotted_name IMPORT LPAR import_as_names RPAR

enaml.core.parser.p_import_from7(p)[source]

import_from : FROM import_from_dots IMPORT STAR

enaml.core.parser.p_import_from8(p)[source]

import_from : FROM import_from_dots IMPORT import_as_names

enaml.core.parser.p_import_from9(p)[source]

import_from : FROM import_from_dots IMPORT LPAR import_as_names RPAR

enaml.core.parser.p_import_from_dots1(p)[source]

import_from_dots : DOT

enaml.core.parser.p_import_from_dots2(p)[source]

import_from_dots : import_from_dots DOT

enaml.core.parser.p_import_as_name1(p)[source]

import_as_name : NAME

enaml.core.parser.p_import_as_name2(p)[source]

import_as_name : NAME AS NAME

enaml.core.parser.p_dotted_as_name1(p)[source]

dotted_as_name : dotted_name

enaml.core.parser.p_dotted_as_name2(p)[source]

dotted_as_name : dotted_name AS NAME

enaml.core.parser.p_import_as_names1(p)[source]

import_as_names : import_as_name

enaml.core.parser.p_import_as_names2(p)[source]

import_as_names : import_as_name COMMA

enaml.core.parser.p_import_as_names3(p)[source]

import_as_names : import_as_name import_as_names_list

enaml.core.parser.p_import_as_names4(p)[source]

import_as_names : import_as_name import_as_names_list COMMA

enaml.core.parser.p_import_as_names_list1(p)[source]

import_as_names_list : COMMA import_as_name

enaml.core.parser.p_import_as_names_list2(p)[source]

import_as_names_list : import_as_names_list COMMA import_as_name

enaml.core.parser.p_dotted_as_names1(p)[source]

dotted_as_names : dotted_as_name

enaml.core.parser.p_dotted_as_names2(p)[source]

dotted_as_names : dotted_as_name dotted_as_names_list

enaml.core.parser.p_dotted_as_names_list1(p)[source]

dotted_as_names_list : COMMA dotted_as_name

enaml.core.parser.p_dotted_as_names_star_list2(p)[source]

dotted_as_names_list : dotted_as_names_list COMMA dotted_as_name

enaml.core.parser.p_dotted_name1(p)[source]

dotted_name : NAME

enaml.core.parser.p_dotted_name2(p)[source]

dotted_name : NAME dotted_name_list

enaml.core.parser.p_dotted_name_list1(p)[source]

dotted_name_list : DOT NAME

enaml.core.parser.p_dotted_name_list2(p)[source]

dotted_name_list : dotted_name_list DOT NAME

enaml.core.parser.p_test1(p)[source]

test : or_test

enaml.core.parser.p_test2(p)[source]

test : or_test IF or_test ELSE test

enaml.core.parser.p_test3(p)[source]

test : lambdef

enaml.core.parser.p_or_test1(p)[source]

or_test : and_test

enaml.core.parser.p_or_test2(p)[source]

or_test : and_test or_test_list

enaml.core.parser.p_or_test_list1(p)[source]

or_test_list : OR and_test

enaml.core.parser.p_or_test_list2(p)[source]

or_test_list : or_test_list OR and_test

enaml.core.parser.p_and_test1(p)[source]

and_test : not_test

enaml.core.parser.p_and_test2(p)[source]

and_test : not_test and_test_list

enaml.core.parser.p_and_test_list1(p)[source]

and_test_list : AND not_test

enaml.core.parser.p_and_test_list2(p)[source]

and_test_list : and_test_list AND not_test

enaml.core.parser.p_not_test(p)[source]

not_test : comparison

enaml.core.parser.p_not_test2(p)[source]

not_test : NOT not_test

enaml.core.parser.p_comparison1(p)[source]

comparison : expr

enaml.core.parser.p_comparison2(p)[source]

comparison : expr comparison_list

enaml.core.parser.p_comparison_list1(p)[source]

comparison_list : comp_op expr

enaml.core.parser.p_comparison_list2(p)[source]

comparison_list : comparison_list comp_op expr

enaml.core.parser.p_comp_op1(p)[source]

comp_op : LESS

enaml.core.parser.p_comp_op2(p)[source]

comp_op : GREATER

enaml.core.parser.p_comp_op3(p)[source]

comp_op : EQEQUAL

enaml.core.parser.p_comp_op4(p)[source]

comp_op : GREATEREQUAL

enaml.core.parser.p_comp_op5(p)[source]

comp_op : LESSEQUAL

enaml.core.parser.p_comp_op6(p)[source]

comp_op : NOTEQUAL

enaml.core.parser.p_comp_op7(p)[source]

comp_op : IN

enaml.core.parser.p_comp_op8(p)[source]

comp_op : NOT IN

enaml.core.parser.p_comp_op9(p)[source]

comp_op : IS

enaml.core.parser.p_comp_op10(p)[source]

comp_op : IS NOT

enaml.core.parser.p_expr1(p)[source]

expr : xor_expr

enaml.core.parser.p_expr2(p)[source]

expr : xor_expr expr_list

enaml.core.parser.p_expr_list1(p)[source]

expr_list : VBAR xor_expr

enaml.core.parser.p_expr_list2(p)[source]

expr_list : expr_list VBAR xor_expr

enaml.core.parser.p_xor_expr1(p)[source]

xor_expr : and_expr

enaml.core.parser.p_xor_expr2(p)[source]

xor_expr : and_expr xor_expr_list

enaml.core.parser.p_xor_expr_list1(p)[source]

xor_expr_list : CIRCUMFLEX and_expr

enaml.core.parser.p_xor_expr_list2(p)[source]

xor_expr_list : xor_expr_list CIRCUMFLEX and_expr

enaml.core.parser.p_and_expr1(p)[source]

and_expr : shift_expr

enaml.core.parser.p_and_expr2(p)[source]

and_expr : shift_expr and_expr_list

enaml.core.parser.p_and_expr_list1(p)[source]

and_expr_list : AMPER shift_expr

enaml.core.parser.p_and_expr_list2(p)[source]

and_expr_list : and_expr_list AMPER shift_expr

enaml.core.parser.p_shift_expr1(p)[source]

shift_expr : arith_expr

enaml.core.parser.p_shift_expr2(p)[source]

shift_expr : arith_expr shift_list

enaml.core.parser.p_shift_list1(p)[source]

shift_list : shift_op

enaml.core.parser.p_shift_list2(p)[source]

shift_list : shift_list shift_op

enaml.core.parser.p_shift_op1(p)[source]

shift_op : LEFTSHIFT arith_expr

enaml.core.parser.p_shift_op2(p)[source]

shift_op : RIGHTSHIFT arith_expr

enaml.core.parser.p_arith_expr1(p)[source]

arith_expr : term

enaml.core.parser.p_arith_expr2(p)[source]

arith_expr : term arith_expr_list

enaml.core.parser.p_arith_expr_list1(p)[source]

arith_expr_list : arith_op

enaml.core.parser.p_arith_expr_list2(p)[source]

arith_expr_list : arith_expr_list arith_op

enaml.core.parser.p_arith_op1(p)[source]

arith_op : PLUS term

enaml.core.parser.p_arith_op2(p)[source]

arith_op : MINUS term

enaml.core.parser.p_term1(p)[source]

term : factor

enaml.core.parser.p_term2(p)[source]

term : factor term_list

enaml.core.parser.p_term_list1(p)[source]

term_list : term_op

enaml.core.parser.p_term_list2(p)[source]

term_list : term_list term_op

enaml.core.parser.p_term_op1(p)[source]

term_op : STAR factor

enaml.core.parser.p_term_op2(p)[source]

term_op : SLASH factor

enaml.core.parser.p_term_op3(p)[source]

term_op : PERCENT factor

enaml.core.parser.p_term_op4(p)[source]

term_op : DOUBLESLASH factor

enaml.core.parser.p_factor1(p)[source]

factor : power

enaml.core.parser.p_factor2(p)[source]

factor : PLUS factor

enaml.core.parser.p_factor3(p)[source]

factor : MINUS factor

enaml.core.parser.p_factor4(p)[source]

factor : TILDE factor

enaml.core.parser.p_power1(p)[source]

power : atom

enaml.core.parser.p_power2(p)[source]

power : atom DOUBLESTAR factor

enaml.core.parser.p_power3(p)[source]

power : atom power_list

enaml.core.parser.p_power4(p)[source]

power : atom power_list DOUBLESTAR factor

enaml.core.parser.p_power_list1(p)[source]

power_list : trailer

enaml.core.parser.p_power_list2(p)[source]

power_list : power_list trailer

enaml.core.parser.p_atom1(p)[source]

atom : LPAR RPAR

enaml.core.parser.p_atom2(p)[source]

atom : LPAR yield_expr RPAR

enaml.core.parser.p_atom3(p)[source]

atom : LPAR testlist_comp RPAR

enaml.core.parser.p_atom4(p)[source]

atom : LSQB RSQB

enaml.core.parser.p_atom5(p)[source]

atom : LSQB listmaker RSQB

enaml.core.parser.p_atom6(p)[source]

atom : LBRACE RBRACE

enaml.core.parser.p_atom7(p)[source]

atom : LBRACE dictorsetmaker RBRACE

enaml.core.parser.p_atom8(p)[source]

atom : NAME

enaml.core.parser.p_atom9(p)[source]

atom : NUMBER

enaml.core.parser.p_atom10(p)[source]

atom : atom_string_list

enaml.core.parser.p_atom_string_list1(p)[source]

atom_string_list : STRING

enaml.core.parser.p_atom_string_list2(p)[source]

atom_string_list : atom_string_list STRING

enaml.core.parser.p_listmaker1(p)[source]

listmaker : test list_for

enaml.core.parser.p_listmaker2(p)[source]

listmaker : test

enaml.core.parser.p_listmaker3(p)[source]

listmaker : test COMMA

enaml.core.parser.p_listmaker4(p)[source]

listmaker : test listmaker_list

enaml.core.parser.p_listmaker5(p)[source]

listmaker : test listmaker_list COMMA

enaml.core.parser.p_listmaker_list1(p)[source]

listmaker_list : COMMA test

enaml.core.parser.p_listmaker_list2(p)[source]

listmaker_list : listmaker_list COMMA test

enaml.core.parser.p_testlist_comp1(p)[source]

testlist_comp : test comp_for

enaml.core.parser.p_testlist_comp2(p)[source]

testlist_comp : test

enaml.core.parser.p_testlist_comp3(p)[source]

testlist_comp : test COMMA

enaml.core.parser.p_testlist_comp4(p)[source]

testlist_comp : test testlist_comp_list

enaml.core.parser.p_testlist_comp5(p)[source]

testlist_comp : test testlist_comp_list COMMA

enaml.core.parser.p_testlist_comp_list1(p)[source]

testlist_comp_list : COMMA test

enaml.core.parser.p_testlist_comp_list2(p)[source]

testlist_comp_list : testlist_comp_list COMMA test

enaml.core.parser.p_trailer1(p)[source]

trailer : LPAR RPAR

enaml.core.parser.p_trailer2(p)[source]

trailer : LPAR arglist RPAR

enaml.core.parser.p_trailer3(p)[source]

trailer : LSQB subscriptlist RSQB

enaml.core.parser.p_trailer4(p)[source]

trailer : DOT NAME

enaml.core.parser.p_subscriptlist1(p)[source]

subscriptlist : subscript

enaml.core.parser.p_subscriptlist2(p)[source]

subscriptlist : subscript COMMA

enaml.core.parser.p_subscriptlist3(p)[source]

subscriptlist : subscript subscriptlist_list

enaml.core.parser.p_subscriptlist4(p)[source]

subscriptlist : subscript subscriptlist_list COMMA

enaml.core.parser.p_subscriptlist_list1(p)[source]

subscriptlist_list : COMMA subscript

enaml.core.parser.p_subscript_list2(p)[source]

subscriptlist_list : subscriptlist_list COMMA subscript

enaml.core.parser.p_subscript1(p)[source]

subscript : ELLIPSIS

enaml.core.parser.p_subcript2(p)[source]

subscript : test

enaml.core.parser.p_subscript3(p)[source]

subscript : COLON

enaml.core.parser.p_subscript4(p)[source]

subscript : DOUBLECOLON

enaml.core.parser.p_subscript5(p)[source]

subscript : test COLON

enaml.core.parser.p_subscrip6(p)[source]

subscript : test DOUBLECOLON

enaml.core.parser.p_subscript7(p)[source]

subscript : COLON test

enaml.core.parser.p_subscript8(p)[source]

subscript : COLON test COLON

enaml.core.parser.p_subscript9(p)[source]

subscript : DOUBLECOLON test

enaml.core.parser.p_subscript10(p)[source]

subscript : test COLON test

enaml.core.parser.p_subscript11(p)[source]

subscript : test COLON test COLON

enaml.core.parser.p_subscript12(p)[source]

subscript : COLON test COLON test

enaml.core.parser.p_subscript13(p)[source]

subscript : test COLON test COLON test

enaml.core.parser.p_subscript14(p)[source]

subscript : test DOUBLECOLON test

enaml.core.parser.p_exprlist1(p)[source]

exprlist : expr

enaml.core.parser.p_exprlist2(p)[source]

exprlist : expr COMMA

enaml.core.parser.p_exprlist3(p)[source]

exprlist : expr exprlist_list

enaml.core.parser.p_exprlist4(p)[source]

exprlist : expr exprlist_list COMMA

enaml.core.parser.p_exprlist_list1(p)[source]

exprlist_list : COMMA expr

enaml.core.parser.p_exprlist_list2(p)[source]

exprlist_list : exprlist_list COMMA expr

enaml.core.parser.p_dictorsetmaker1(p)[source]

dictorsetmaker : test COLON test comp_for

enaml.core.parser.p_dictorsetmaker2(p)[source]

dictorsetmaker : test COLON test

enaml.core.parser.p_dictorsetmaker3(p)[source]

dictorsetmaker : test COLON test COMMA

enaml.core.parser.p_dictorsetmaker4(p)[source]

dictorsetmaker : test COLON test dosm_colon_list

enaml.core.parser.p_dictorsetmaker5(p)[source]

dictorsetmaker : test COLON test dosm_colon_list COMMA

enaml.core.parser.p_dictorsetmaker6(p)[source]

dictorsetmaker : test comp_for

enaml.core.parser.p_dictorsetmaker7(p)[source]

dictorsetmaker : test COMMA

enaml.core.parser.p_dictorsetmaker8(p)[source]

dictorsetmaker : test dosm_comma_list

enaml.core.parser.p_dictorsetmaker9(p)[source]

dictorsetmaker : test dosm_comma_list COMMA

enaml.core.parser.p_dosm_colon_list1(p)[source]

dosm_colon_list : COMMA test COLON test

enaml.core.parser.p_dosm_colon_list2(p)[source]

dosm_colon_list : dosm_colon_list COMMA test COLON test

enaml.core.parser.p_dosm_comma_list1(p)[source]

dosm_comma_list : COMMA test

enaml.core.parser.p_dosm_comma_list2(p)[source]

dosm_comma_list : dosm_comma_list COMMA test

enaml.core.parser.p_arglist1(p)[source]

arglist : argument

enaml.core.parser.p_arglist2(p)[source]

arglist : argument COMMA

enaml.core.parser.p_arglist3(p)[source]

arglist : STAR test

enaml.core.parser.p_arglist4(p)[source]

arglist : STAR test COMMA DOUBLESTAR test

enaml.core.parser.p_arglist5(p)[source]

arglist : DOUBLESTAR test

enaml.core.parser.p_arglist6(p)[source]

arglist : arglist_list argument

enaml.core.parser.p_arglist7(p)[source]

arglist : arglist_list argument COMMA

enaml.core.parser.p_arglist8(p)[source]

arglist : arglist_list STAR test

enaml.core.parser.p_arglist9(p)[source]

arglist : arglist_list STAR test COMMA DOUBLESTAR test

enaml.core.parser.p_arglist10(p)[source]

arglist : arglist_list DOUBLESTAR test

enaml.core.parser.p_arglist11(p)[source]

arglist : STAR test COMMA argument

enaml.core.parser.p_arglist12(p)[source]

arglist : STAR test COMMA argument COMMA DOUBLESTAR test

enaml.core.parser.p_arglist13(p)[source]

arglist : STAR test COMMA arglist_list argument

enaml.core.parser.p_arglist14(p)[source]

arglist : STAR test COMMA arglist_list argument COMMA DOUBLESTAR test

enaml.core.parser.p_arglist_list1(p)[source]

arglist_list : argument COMMA

enaml.core.parser.p_arglist_list2(p)[source]

arglist_list : arglist_list argument COMMA

enaml.core.parser.p_argument1(p)[source]

argument : test

enaml.core.parser.p_argument2(p)[source]

argument : test comp_for

enaml.core.parser.p_argument3(p)[source]

argument : test EQUAL test

enaml.core.parser.p_list_for1(p)[source]

list_for : FOR exprlist IN testlist_safe

enaml.core.parser.p_list_for2(p)[source]

list_for : FOR exprlist IN testlist_safe list_iter

enaml.core.parser.p_list_iter1(p)[source]

list_iter : list_for

enaml.core.parser.p_list_iter2(p)[source]

list_iter : list_if

enaml.core.parser.p_list_if1(p)[source]

list_if : IF old_test

enaml.core.parser.p_list_if2(p)[source]

list_if : IF old_test list_iter

enaml.core.parser.p_comp_for1(p)[source]

comp_for : FOR exprlist IN or_test

enaml.core.parser.p_comp_for2(p)[source]

comp_for : FOR exprlist IN or_test comp_iter

enaml.core.parser.p_comp_iter1(p)[source]

comp_iter : comp_for

enaml.core.parser.p_comp_iter2(p)[source]

comp_iter : comp_if

enaml.core.parser.p_comp_if1(p)[source]

comp_if : IF old_test

enaml.core.parser.p_comp_if2(p)[source]

comp_if : IF old_test comp_iter

enaml.core.parser.p_testlist_safe1(p)[source]

testlist_safe : old_test

enaml.core.parser.p_testlist_safe2(p)[source]

testlist_safe : old_test testlist_safe_list

enaml.core.parser.p_testlist_safe3(p)[source]

testlist_safe : old_test testlist_safe_list COMMA

enaml.core.parser.p_testlist_safe_list1(p)[source]

testlist_safe_list : COMMA old_test

enaml.core.parser.p_testlist_safe_list2(p)[source]

testlist_safe_list : testlist_safe_list COMMA old_test

enaml.core.parser.p_old_test1(p)[source]

old_test : or_test

enaml.core.parser.p_old_test2(p)[source]

old_test : old_lambdef

enaml.core.parser.p_old_lambdef1(p)[source]

old_lambdef : LAMBDA COLON old_test

enaml.core.parser.p_old_lambdef2(p)[source]

old_lambdef : LAMBDA varargslist COLON old_test

enaml.core.parser.p_lambdef1(p)[source]

lambdef : LAMBDA COLON test

enaml.core.parser.p_lambdef2(p)[source]

lambdef : LAMBDA varargslist COLON test

enaml.core.parser.p_varargslist1(p)[source]

varargslist : fpdef COMMA STAR NAME

enaml.core.parser.p_varargslist2(p)[source]

varargslist : fpdef COMMA STAR NAME COMMA DOUBLESTAR NAME

enaml.core.parser.p_varargslist3(p)[source]

varargslist : fpdef COMMA DOUBLESTAR NAME

enaml.core.parser.p_varargslist4(p)[source]

varargslist : fpdef

enaml.core.parser.p_varargslist5(p)[source]

varargslist : fpdef COMMA

enaml.core.parser.p_varargslist6(p)[source]

varargslist : fpdef varargslist_list COMMA STAR NAME

enaml.core.parser.p_varargslist7(p)[source]

varargslist : fpdef varargslist_list COMMA STAR NAME COMMA DOUBLESTAR NAME

enaml.core.parser.p_varargslist8(p)[source]

varargslist : fpdef varargslist_list COMMA DOUBLESTAR NAME

enaml.core.parser.p_varargslist9(p)[source]

varargslist : fpdef varargslist_list

enaml.core.parser.p_varargslist10(p)[source]

varargslist : fpdef varargslist_list COMMA

enaml.core.parser.p_varargslist11(p)[source]

varargslist : fpdef EQUAL test COMMA STAR NAME

enaml.core.parser.p_varargslist12(p)[source]

varargslist : fpdef EQUAL test COMMA STAR NAME COMMA DOUBLESTAR NAME

enaml.core.parser.p_varargslist13(p)[source]

varargslist : fpdef EQUAL test COMMA DOUBLESTAR NAME

enaml.core.parser.p_varargslist14(p)[source]

varargslist : fpdef EQUAL test

enaml.core.parser.p_varargslist15(p)[source]

varargslist : fpdef EQUAL test COMMA

enaml.core.parser.p_varargslist16(p)[source]

varargslist : fpdef EQUAL test varargslist_list COMMA STAR NAME

enaml.core.parser.p_varargslist17(p)[source]

varargslist : fpdef EQUAL test varargslist_list COMMA STAR NAME COMMA DOUBLESTAR NAME

enaml.core.parser.p_varargslist18(p)[source]

varargslist : fpdef EQUAL test varargslist_list COMMA DOUBLESTAR NAME

enaml.core.parser.p_varargslist19(p)[source]

varargslist : fpdef EQUAL test varargslist_list

enaml.core.parser.p_varargslist20(p)[source]

varargslist : fpdef EQUAL test varargslist_list COMMA

enaml.core.parser.p_varargslist21(p)[source]

varargslist : STAR NAME

enaml.core.parser.p_varargslist22(p)[source]

varargslist : STAR NAME COMMA DOUBLESTAR NAME

enaml.core.parser.p_varargslist23(p)[source]

varargslist : DOUBLESTAR NAME

enaml.core.parser.p_varargslist_list1(p)[source]

varargslist_list : COMMA fpdef

enaml.core.parser.p_varargslist_list2(p)[source]

varargslist_list : COMMA fpdef EQUAL test

enaml.core.parser.p_varargslist_list3(p)[source]

varargslist_list : varargslist_list COMMA fpdef

enaml.core.parser.p_varargslist_list4(p)[source]

varargslist_list : varargslist_list COMMA fpdef EQUAL test

enaml.core.parser.p_fpdef1(p)[source]

fpdef : NAME

enaml.core.parser.p_fpdef2(p)[source]

fpdef : LPAR fplist RPAR

enaml.core.parser.p_fplist1(p)[source]

fplist : fpdef

enaml.core.parser.p_fplist2(p)[source]

fplist : fpdef COMMA

enaml.core.parser.p_fplist3(p)[source]

fplist : fpdef fplist_list

enaml.core.parser.p_fplist4(p)[source]

fplist : fpdef fplist_list COMMA

enaml.core.parser.p_fplist_list1(p)[source]

fplist_list : COMMA fpdef

enaml.core.parser.p_fplist_list2(p)[source]

fplist_list : fplist_list COMMA fpdef

trait_types Module

class enaml.core.trait_types.EnamlInstance(base_type=<type 'object'>)[source]

Bases: traits.trait_handlers.TraitType

A custom TraitType which serves as a simple isinstance(...) validator. This class serves as the base class for other custom trait types such as EnamlEvent.

static is_valid_type(obj)[source]

A static method which returns whether or not the given object can be used as the type in an isinstance(..., type) expression.

Paramters

obj : object
The object which should behave like a type for the purpose of an isinstance check. This means the object is type or defines an ‘__instancecheck__’ method.
Returns:result (bool) – True if the object is a type or defines a method named ‘__instancecheck__’, False otherwise.
__init__(base_type=<type 'object'>)[source]

Initialize an EnamlInstance.

Parameters:base_type (type-like object, optional) – An object that behaves like a type for the purposes of a call to isinstance. The staticmethod ‘is_valid_attr_type’ defined on this class can be used to test a type before creating an instance of this class. It is assumed that the given type passes that test. The default is object.
validate(obj, name, value)[source]

The validation handler for an EnamlInstace. It performs a simple isinstance(...) check using the attribute type provided to the constructor.

full_info(obj, name, value)[source]

Overridden parent class method to compute an appropriate info string for use in error messages.

class enaml.core.trait_types.EnamlEventDispatcher(trait, obj, name)[source]

Bases: object

A thin object which is used to dispatch a notification for an EnamlEvent. Instances of this class are callable with at most one argument, which will be the payload of the event. Instances of this dispatcher should not be held onto, since they maintain a strong reference to the underlying object.

__init__(trait, obj, name)[source]

Initialize an event dispatcher.

Parameters:
  • trait (Instance(TraitType)) – The trait type instance on which validate will be called with the event payload.
  • obj (Instance(HasTraits)) – The HasTraits object on which the event is being emitted.
  • name (string) – The name of the event being emitted.
__call__(payload=None)[source]

Dispatches the event with the given payload.

Paramters

payload : object, optional
The payload argument of the event. This object will be validated against the type declared for the event. The default payload is None.
__weakref__

list of weak references to the object (if defined)

class enaml.core.trait_types.EnamlEvent(base_type=<type 'object'>)[source]

Bases: enaml.core.trait_types.EnamlInstance

A custom EnamlInstance that is used to implement the event type in Enaml. An EnamlEvent is read-only, and returns a dispatcher which can be called to emit the event.

get(obj, name)[source]

The trait getter method. Returns an EnamlEventDispatcher instance which can be called to emit the event.

set(obj, name, value)[source]

The trait setter method. Fires off a EnamlEventDispatcher as if the event were called with the payload.

full_info(obj, name, value)[source]

Overridden parent class method to compute an appropriate info string for use in error messages.

class enaml.core.trait_types.Bounded(value=None, low=None, high=None, **metadata)[source]

Bases: traits.trait_handlers.TraitType

Generic Bounded Trait class.

The class defines a generic Trait where the value is validated on assigment to fall between low and high (static or dynamic) bounds.

__init__(value=None, low=None, high=None, **metadata)[source]
Parameters:
  • value – The default value. It can be a python object or a Trait.
  • low – The lower bound of the Trait.
  • high – The upper bound of the Trait.
validate_with_trait(obj, name, value)[source]

Validate the trait value.

Validation takes place in two steps: #. The input value is validated based on the expected Trait type. #. The value it is between the static (or dynamic) bounds.

validate_bounds(obj, name, value)[source]

Validate that the value is in range.

Note

Any exceptions that may take place are converted to TraitErrors.

get_bounds(obj)[source]

Get the lower and upper bounds of the Trait.

class enaml.core.trait_types.CoercingInstance(klass=None, factory=None, args=None, kw=None, allow_none=True, adapt=None, module=None, **metadata)[source]

Bases: traits.trait_types.BaseInstance

A BaseInstance subclass which attempts to coerce a value by calling the class constructor and passing the new value into the original validate method.

validate(obj, name, value)[source]

Attempts to coerce the given value to an appropriate type by calling the underlying class constructor. The coerced value is then sent to the superclass’ validate method.