The enaml.core package contains all of Enaml’s core language functionality.
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.
alias of ABCMeta
Evaluate and return the results of the expression.
Parameters: |
|
---|
list of weak references to the object (if defined)
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.
alias of ABCMeta
Called when the attribute on the object has changed.
Parameters: |
---|
list of weak references to the object (if defined)
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.
Called before the CALL_FUNCTION opcode is executed.
Parameters: |
---|
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]))
Called before the GET_ITER opcode is executed.
Parameters: | obj (object) – The object which should return an iterator. |
---|
list of weak references to the object (if defined)
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.
Called before the LOAD_NAME opcode is executed.
This method should perform a STORE_NAME operation.
Parameters: |
---|
Called before the LOAD_ATTR opcode is executed.
This method should perform a STORE_ATTR operation.
Parameters: |
---|
Called before the CALL_FUNCTION opcode is executed.
This method should perform an appropriate store operation.
Parameters: |
---|
Note
The semantics of the arguments is identical to the method call_function on the CodeTracer type.
Called before the BINARY_SUBSCR opcode is executed.
This method should perform a STORE_SUBSCR operation.
Parameters: |
---|
list of weak references to the object (if defined)
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. |
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 : |
Bases: enaml.core.trait_types.EnamlInstance
An EnamlInstance subclass which implements the attr keyword.
The trait getter method.
This returns the value from the object’s dict, or raises an uninitialized error if the value doesn’t exist.
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.
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.
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.
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. |
---|
The operator context used to build out this instance. This is assigned during object instantiation. It should not be edited by user code.
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: |
|
---|
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: |
|
---|
alias of __NoInterface__
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. |
Bases: object
The base Enaml AST node.
The line number in the source code that created this node.
list of weak references to the object (if defined)
Bases: enaml.core.enaml_ast.ASTNode
An AST node representing an Enaml module.
The module’s documentation string.
A list of ast nodes comprising the body of the module.
Bases: enaml.core.enaml_ast.ASTNode
An AST node representing a chunk of pure Python code.
A Python ast node.
Bases: enaml.core.enaml_ast.ASTNode
An AST node representing an Enaml declaration.
The name of the declaration.
The name of the base type.
The local identifier to use for instances of the declaration.
The documentation string for the declaration.
A list of AST nodes that comprise the body of the declaration.
Bases: enaml.core.enaml_ast.ASTNode
An AST node representing a declaration instantiation.
The name of declaration being instantiated.
The local identifier to use for the new instance.
A list of AST nodes which comprise the instantiation body.
Bases: enaml.core.enaml_ast.ASTNode
An AST node which represents an attribute declaration.
The name of the attribute being declared.
A string representing the type of the attribute, or None if no type was given. If None the attribute can be of any type.
The default binding of the attribute, or None if no default is provided.
Whether or not this declaration represents an event. i.e. was declared with ‘event’ instead of ‘attr’.
Bases: enaml.core.enaml_ast.ASTNode
An AST node which represents an expression attribute binding.
The name of the attribute being bound.
The BoundExpression ast node which represents the binding.
Bases: enaml.core.enaml_ast.ASTNode
An ast node which represents a bound expression.
The name of the operator that will perform the binding.
A Python ast node that reprents the bound expression.
Returns a new code object with an updated first line number.
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: |
|
---|
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. |
---|
Compile an ast into a code object implementing operator =.
Parameters: |
|
---|---|
Returns: | result (types.CodeType) – A Python code object which implements the desired behavior. |
Compile an ast into a code object implementing operator ::.
Parameters: |
|
---|---|
Returns: | result (types.CodeType) – A Python code object which implements the desired behavior. |
Compile an ast into a code object implementing operator <<.
Parameters: |
|
---|---|
Returns: | result (types.CodeType) – A Python code object which implements the desired behavior. |
Compile an ast into a code object implementing operator >>.
Parameters: |
|
---|---|
Returns: | result (types.CodeType) – A Python code object which implements the desired behavior. |
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: |
|
---|---|
Returns: | result (tuple) – A 2-tuple of types.CodeType equivalent to operators << and >> respectively. |
Bases: enaml.core.enaml_compiler._NodeVisitor
A visitor which compiles a Declaration node into a code object.
The main entry point of the DeclarationCompiler.
This compiler compiles the given Declaration node into a code object for a builder function.
Parameters: |
|
---|
Initialize a DeclarationCompiler.
Parameters: | filename (str) – The filename string to use for the generated code object. |
---|
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_.
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.
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.
The main entry point of the compiler.
Parameters: |
|
---|
Initialize an EnamlCompiler.
Parameters: | filename (str) – The string filename of the module ast being compiled. |
---|
The Module node visitor method.
This visitor dispatches to all of the body nodes of the module.
The Python node visitor method.
This visitor adds a chunk of raw Python into the module.
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.
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.
Called when an object attribute is dynamically loaded.
This will trace the object if it is a HasTraits instance. See also: AbstractScopeListener.dynamic_load.
Called before the LOAD_ATTR opcode is executed.
This will trace the object if it is a HasTraits instance. See also: CodeTracer.dynamic_load.
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
Bases: enaml.core.code_tracing.CodeInverter
The standard code inverter for Enaml expressions.
Initialize a StandardInverter.
Parameters: | nonlocals (Nonlocals) – The nonlocal scope for the executing expression. |
---|
Called before the LOAD_NAME opcode is executed.
This method performs STORE_NAME by storing to the nonlocals. See also: CodeInverter.load_name.
Called before the LOAD_ATTR opcode is executed.
This method performs STORE_ATTR via the builtin setattr. See also: CodeInverter.load_attr.
Bases: object
The base class of the standard Enaml expression classes.
Initialize a BaseExpression.
Parameters: |
|
---|
Bases: enaml.core.expressions.BaseExpression
An implementation of AbstractExpression for the = operator.
Bases: tuple
NotificationEvent(obj, name, old, new)
Return self as a plain tuple. Used by copy and pickle.
Create new instance of NotificationEvent(obj, name, old, new)
Return a nicely formatted representation string
Alias for field number 1
Alias for field number 3
Alias for field number 0
Alias for field number 2
Bases: enaml.core.expressions.BaseExpression
An implementation of AbstractListener for the :: operator.
Bases: enaml.core.expressions.BaseExpression
An implementation of AbstractListener for the >> operator.
Bases: object
A simple object used for attaching notification handlers.
list of weak references to the object (if defined)
Bases: enaml.core.expressions.BaseExpression
An implementation of AbstractExpression for the << operator.
Bases: enaml.core.expressions.SubscriptionExpression
An expression and listener implementation for the := operator.
Call a function which has been modified by the Enaml compiler to support tracing and dynamic scoping.
Parameters: |
|
---|---|
Returns: | result (object) – The result of calling the function. |
Bases: tuple
EnamlFileInfo(src_path, cache_path, cache_dir)
Return self as a plain tuple. Used by copy and pickle.
Create new instance of EnamlFileInfo(src_path, cache_path, cache_dir)
Return a nicely formatted representation string
Alias for field number 2
Alias for field number 1
Alias for field number 0
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. |
Bases: object
An abstract base class which defines the api required to implement an Enaml importer.
alias of ABCMeta
Finds the given Enaml module and returns an importer, or None if the module is not found.
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.
Searches for the given Enaml module and returns an instance of AbstractEnamlImporter on success.
Paramters
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. |
---|
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. |
---|
list of weak references to the object (if defined)
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
Searches for the given Enaml module and returns an instance of this class on success.
Paramters
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. |
---|
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.
Returns a tuple of currently active importers in use for the framework.
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.
Removes the importer from the list of active importers. If the importer is not in the list, this is a no-op.
list of weak references to the object (if defined)
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.
The list of objects belonging to this Include. Objects in this list will be automatically parented with the Include’s parent.
A boolean flag indicating whether to destroy the old objects that are removed from the parent. The default is True.
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.
Handle a ParentEvent for the Include.
If the object state is active the current include objects will be reparented to the new parent.
alias of __NoInterface__
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.
A loopback guard which can be used to prevent a notification cycle when setting attributes from within an action handler.
A reimplemented initialization method.
This method will setup any Include children so that they may prepare their objects before the proper initialization pass.
A reimplemented post initialization method.
This method calls the bind method after calling the superclass class version.
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.
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. |
---|
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. |
---|
Get the name of the class for this instance.
Returns: | result (str) – The name of the class of this instance. |
---|
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 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.
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.
alias of __NoInterface__
The dispatch function for action dispatching.
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.
Return self as a plain tuple. Used by copy and pickle.
Create new instance of ChildrenEvent(old, new)
Return a nicely formatted representation string
Alias for field number 1
Alias for field number 0
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.
Return self as a plain tuple. Used by copy and pickle.
Create new instance of ParentEvent(old, new)
Return a nicely formatted representation string
Alias for field number 1
Alias for field number 0
The identifier generator for object instances.
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.
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 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 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.
list of weak references to the object (if defined)
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.
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.
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.
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.
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.
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.
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.
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.
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.
The current state of the object in terms of its lifetime within a session. This value should not be manipulated by user code.
A read-only property which is True if the object is inactive.
A read-only property which is True if the object is initializing.
A read-only property which is True if the object is initialized.
A read-only property which is True if the object is activating.
A read-only property which is True if the object is active.
A read-only property which is True if the object is destroying.
A read-only property which is True if the object is destroyed.
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. |
---|
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.
Called during the initialization pass before any children are initialized.
The object state during this call will be ‘initializing’.
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.
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. |
---|
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. |
---|
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 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.
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.
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 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 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: |
|
---|
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.
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. |
---|
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 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: |
---|
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: |
---|
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. |
---|
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 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: |
|
---|---|
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 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: |
|
---|---|
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. |
alias of __NoInterface__
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.
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.
A staticmethod that returns the currently active operator context, or the default context if there is not active context.
A staticmethod that returns the default operator context, creating one if necessary.
A context manager method that pushes this context onto the active context stack.
A context manager method that pops this context from the active context stack.
list of weak references to the object (if defined)
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:
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(...).
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(...).
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(...).
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(...).
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.
Bases: object
A fake token used to store the lexer before calling the syntax error functions.
list of weak references to the object (if defined)
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.
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.
If the testlist is a list, returns an ast.Tuple with a Load context, otherwise returns the orginal node.
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: |
---|
Builds an ast node for an attr or event declaration.
Parameters: |
|
---|---|
Returns: | result (AttributeDeclaration) – The Enaml AttributeDeclaration ast node. |
Bases: object
A parsing helper to delineate a comma separated list.
list of weak references to the object (if defined)
Bases: object
A parsing helper to delineate a generator body.
list of weak references to the object (if defined)
Bases: object
A parsing helper object to delineate call arguments.
list of weak references to the object (if defined)
enaml : enaml_module NEWLINE ENDMARKER | enaml_module ENDMARKER
enaml_module_body : enaml_module_body enaml_module_item
declaration : ENAMLDEF NAME LPAR NAME RPAR COLON declaration_body
declaration : ENAMLDEF NAME LPAR NAME RPAR COLON PASS NEWLINE
declaration : ENAMLDEF NAME LPAR NAME RPAR COLON NAME COLON declaration_body
declaration : ENAMLDEF NAME LPAR NAME RPAR COLON NAME COLON PASS NEWLINE
declaration_body : NEWLINE INDENT declaration_body_items DEDENT
declaration_body : NEWLINE INDENT identifier DEDENT
declaration_body : NEWLINE INDENT identifier declaration_body_items DEDENT
declaration_body : NEWLINE INDENT STRING NEWLINE declaration_body_items DEDENT
declaration_body : NEWLINE INDENT STRING NEWLINE identifier DEDENT
declaration_body : NEWLINE INDENT STRING NEWLINE identifier declaration_body_items DEDENT
declaration_body_items : declaration_body_item
declaration_body_items : declaration_body_items declaration_body_item
declaration_body_item : attribute_declaration
attribute_declaration : NAME NAME COLON NAME NEWLINE
attribute_declaration : NAME NAME COLON NAME binding
instantiation : NAME COLON NAME COLON instantiation_body
instantiation : NAME COLON NAME COLON attribute_binding
instantiation_body : NEWLINE INDENT instantiation_body_items DEDENT
instantiation_body : NEWLINE INDENT identifier DEDENT
instantiation_body : NEWLINE INDENT identifier instantiation_body_items DEDENT
instantiation_body_items : instantiation_body_item
instantiation_body_items : instantiation_body_items instantiation_body_item
instantiation_body_item : attribute_binding
binding : COLONEQUAL test NEWLINE | RIGHTSHIFT test NEWLINE
small_stmt_list : small_stmt small_stmt_list_list SEMI
small_stmt_list_list : small_stmt_list_list SEMI small_stmt
small_stmt : expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | exec_stmt | assert_stmt
flow_stmt : break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt
expr_stmt : testlist augassign testlist | testlist augassign yield_expr
augassign : AMPEREQUAL | CIRCUMFLEXEQUAL | DOUBLESLASHEQUAL | DOUBLESTAREQUAL | LEFTSHIFTEQUAL | MINUSEQUAL | PERCENTEQUAL | PLUSEQUAL | RIGHTSHIFTEQUAL | SLASHEQUAL | STAREQUAL | VBAREQUAL
equal_list : EQUAL testlist equal_list | EQUAL yield_expr equal_list
compound_stmt : if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated
for_stmt : FOR exprlist IN testlist COLON suite ELSE COLON suite
try_stmt : TRY COLON suite except_clauses ELSE COLON suite
try_stmt : TRY COLON suite except_clauses FINALLY COLON suite
try_stmt : TRY COLON suite except_clauses ELSE COLON suite FINALLY COLON suite
except_clause : EXCEPT test AS test COLON suite | EXCEPT test COMMA test COLON suite
import_from : FROM dotted_name IMPORT LPAR import_as_names RPAR
import_from : FROM import_from_dots dotted_name IMPORT STAR
import_from : FROM import_from_dots dotted_name IMPORT import_as_name
import_from : FROM import_from_dots dotted_name IMPORT LPAR import_as_names RPAR
import_from : FROM import_from_dots IMPORT import_as_names
import_from : FROM import_from_dots IMPORT LPAR import_as_names RPAR
import_as_names : import_as_name import_as_names_list
import_as_names : import_as_name import_as_names_list COMMA
import_as_names_list : import_as_names_list COMMA import_as_name
dotted_as_names : dotted_as_name dotted_as_names_list
dotted_as_names_list : dotted_as_names_list COMMA dotted_as_name
testlist_comp_list : testlist_comp_list COMMA test
subscriptlist_list : subscriptlist_list COMMA subscript
dictorsetmaker : test COLON test dosm_colon_list COMMA
dosm_colon_list : dosm_colon_list COMMA test COLON test
arglist : STAR test COMMA arglist_list argument COMMA DOUBLESTAR test
testlist_safe_list : testlist_safe_list COMMA old_test
varargslist : fpdef COMMA STAR NAME COMMA DOUBLESTAR NAME
varargslist : fpdef varargslist_list COMMA STAR NAME COMMA DOUBLESTAR NAME
varargslist : fpdef varargslist_list COMMA DOUBLESTAR NAME
varargslist : fpdef EQUAL test COMMA STAR NAME COMMA DOUBLESTAR NAME
varargslist : fpdef EQUAL test varargslist_list COMMA STAR NAME
varargslist : fpdef EQUAL test varargslist_list COMMA STAR NAME COMMA DOUBLESTAR NAME
varargslist : fpdef EQUAL test varargslist_list COMMA DOUBLESTAR NAME
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.
A static method which returns whether or not the given object can be used as the type in an isinstance(..., type) expression.
Paramters
Returns: | result (bool) – True if the object is a type or defines a method named ‘__instancecheck__’, False otherwise. |
---|
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. |
---|
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.
Initialize an event dispatcher.
Parameters: |
|
---|
Dispatches the event with the given payload.
Paramters
list of weak references to the object (if defined)
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.
The trait getter method. Returns an EnamlEventDispatcher instance which can be called to emit the event.
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.
Parameters: |
|
---|
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.
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.