Package mrv :: Module dge :: Class _PlugShell
[hide private]
[frames] | no frames]

Class _PlugShell

source code

object --+    
         |    
     tuple --+
             |
            _PlugShell
Known Subclasses:

Handles per-node-instance plug connection setup and storage. As plugs are descriptors and thus an instance of the class, per-node-instance information needs special treatment. This class is being returned whenever the descriptors get and set methods are called, it contains information about the node and the plug being involved, allowing to track connection info directly using the node dict

This allows plugs to be connected, and information to flow through the dependency graph. Plugs never act alone since they always belong to a parent node that will be asked for value computations if the value is not yet cached. :note: Do not instantiate this class youself, it must be created by the node as different node types can use different versions of this shell

Instance Methods [hide private]

Inherited from tuple: __add__, __contains__, __eq__, __ge__, __getattribute__, __getitem__, __getnewargs__, __getslice__, __gt__, __hash__, __iter__, __le__, __len__, __lt__, __mul__, __ne__, __rmul__, __sizeof__, count, index

Inherited from object: __delattr__, __format__, __init__, __reduce__, __reduce_ex__, __setattr__, __subclasshook__

    Object Overrides
 
__getattr__(self, attr)
Allow easy attribute access while staying memory efficient
source code
 
__repr__(self)
repr(x)
source code
 
__str__(self)
str(x)
source code
    Values
 
get(self, mode=None)
Returns: value of the plug
source code
 
set(self, value, ignore_connection=False)
Set the given value to be used in our plug :param ignore_connection: if True, the plug can be destination of a connection and will still get its value set - usually it would be overwritten by the value form the connection.
source code
 
compatabilityRate(self, value)
Compute compatability rate for teh given value
source code
    Connections
 
connect(self, otherplugshell, **kwargs)
Connect this plug to otherplugshell such that otherplugshell is an input plug for our output
source code
 
disconnect(self, otherplugshell)
Remove the connection to otherplugshell if we are connected to it.
source code
 
input(self, predicate=<function <lambda> at 0x2f58500>)
Returns: the connected input plug or None if there is no such connection
source code
 
outputs(self, predicate=<function <lambda> at 0x2f585f0>)
Returns: a list of plugs being the destination of the connection
source code
 
connections(self, inpt, output, predicate=<function <lambda> at 0x2f586e0>)
Returns: get all input and or output connections from this shell or to this shell as edges ( sourceshell, destinationshell )
source code
 
isConnected(self)
Returns: True, if the shell is connected as source or as destination of a connection
source code
 
iterShells(self, **kwargs)
Iterate plugs and their connections starting at this plug :return: generator for plug shells :note: supports all options of iterShells, this method allows syntax like: node.outAttribute.iterShells( )
source code
    Caching
 
_cachename(self) source code
 
hasCache(self)
Returns: True if currently store a cached value
source code
 
setCache(self, value)
Set the given value to be stored in our cache :raise: TypeError if the value is not compatible to our defined type
source code
 
cache(self)
Returns: the cached value or raise
source code
 
clearCache(self, clear_affected=False, cleared_shells_set=None)
Empty the cache of our plug :param clear_affected: if True, the caches of our affected plugs ( connections or affects relations ) will also be cleared This operation is recursive, and needs to be as different shells on different nodes might do things differently.
source code
    Name Overrides
 
__rshift__(self, other)
force
source code
Static Methods [hide private]
    Object Overrides
a new object with type S, a subtype of T
__new__(cls, *args) source code
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__new__(cls, *args)
Static Method

source code 
Returns: a new object with type S, a subtype of T
Overrides: object.__new__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

get(self, mode=None)

source code 
Parameters:
  • mode - optional arbitary value specifying the mode of the get attempt
Returns:
value of the plug

set(self, value, ignore_connection=False)

source code 
Set the given value to be used in our plug :param ignore_connection: if True, the plug can be destination of a connection and will still get its value set - usually it would be overwritten by the value form the connection. The set value will be cleared if something upstream in it's connection chain changes. :raise AssertionError: the respective attribute must be cached, otherwise the value will be lost

compatabilityRate(self, value)

source code 
Compute compatability rate for teh given value
Returns:
value between 0 and 255, 0 means no compatability, 255 a perfect match if larger than 0, the plug can hold the value ( assumed the flags are set correctly )

connect(self, otherplugshell, **kwargs)

source code 
Connect this plug to otherplugshell such that otherplugshell is an input plug for our output
Parameters:
Returns:
self on success, allows chained connections
Raises:

disconnect(self, otherplugshell)

source code 
Remove the connection to otherplugshell if we are connected to it. :note: does not raise if no connection is present

input(self, predicate=<function <lambda> at 0x2f58500>)

source code 
Parameters:
  • predicate - plug will only be returned if predicate is true for it
Returns:
the connected input plug or None if there is no such connection

Note: input plugs have on plug at most, output plugs can have more than one connected plug

outputs(self, predicate=<function <lambda> at 0x2f585f0>)

source code 
Parameters:
  • predicate - plug will only be returned if predicate is true for it - shells will be passed in
Returns:
a list of plugs being the destination of the connection

connections(self, inpt, output, predicate=<function <lambda> at 0x2f586e0>)

source code 
Parameters:
  • predicate - return true for each destination shell that you can except in the returned edge or the sourceshell where your shell is the destination.
Returns:
get all input and or output connections from this shell or to this shell as edges ( sourceshell, destinationshell )

Note: Use this method to get edges read for connection/disconnection

isConnected(self)

source code 
Returns:
True, if the shell is connected as source or as destination of a connection

hasCache(self)

source code 
Returns:
True if currently store a cached value

cache(self)

source code 
Returns:
the cached value or raise
Raises:
  • ValueError

clearCache(self, clear_affected=False, cleared_shells_set=None)

source code 
Empty the cache of our plug :param clear_affected: if True, the caches of our affected plugs ( connections or affects relations ) will also be cleared This operation is recursive, and needs to be as different shells on different nodes might do things differently. :param cleared_shells_set: if set, it can be used to track which plugs have already been dirtied to prevent recursive loops Propagation will happen even if we do not have a cache to clear ourselves