All kinds of utility methods and classes that are used in more than one modules
Returns: | s with first letter capitalized |
---|
Copy the members or sourcecls to destcls while ignoring member names in forbiddenMembers It will only copy mebers of this class, not its base classes
Parameters: |
|
---|---|
Note: | this can be useful if you cannot inherit from a class directly because you would get method resolution order problems |
Note: | see also the MetaCopyClsMembers meta class |
Returns: | int,float or str from string valuestr - a string that encodes a numeric value or a string |
---|---|
Raises TypeError: | |
if the type could not be determined |
Returns: | as decodeString, but returns a list of appropriate values if the input argument is a list or tuple type |
---|
Returns: | iterator yielding pairs of depth, item |
---|---|
Parameters: |
|
Note: | this is an adjusted version of dge.iterShells |
Returns: | set(submodule_name, ...) list of submodule names that could be imported using __import__ |
---|---|
Parameter: | path – module path containing the submodules |
Returns: | list of sub-package names |
---|
Returns: | A path instance of the correct type |
---|---|
Note: | use this constructor if you use the Path.set_separator method at runtime to assure you will always create instances of the actual type, and not only of the type you imported last |
Returns: | all classes of modules of the given package file that additionally match given predicate |
---|---|
Parameters: |
|
Returns: | s with first letter lower case |
---|---|
Parameter: | preserveAcronymns – enabled ensures that ‘NTSC’ does not become ‘nTSC’ |
Note: | from pymel |
Bases: object
For use with python’s filter method, simulates logical AND Usage: filter(And(f1,f2,fn), sequence)
Bases: object
Call object encapsulating any code, thus providing a simple facade for it :note: derive from it if a more complex call is required
Bases: mrv.util.Call
Advanced call class providing additional options:
Epydoc: mrv.util.CallOnDeletion
Bases: object
Call the given callable object once this object is being deleted Its usefull if you want to assure certain code to run once the parent scope of this object looses focus
Bases: networkx.classes.digraph.DiGraph
Adds utility functions to DirectedTree allowing to handle a directed tree like a dag :note: currently this tree does not support instancing :todo: add instancing support
Returns: | list of children of given node n |
---|
Returns: | iterator with children of given node n |
---|
Returns: | the root node of this dag tree |
---|---|
Parameter: | startnode – if None, the first node will be used to get the root from (good for single rooted dags), otherwise this node will be used to get the root from - thus it must exist in the dag tree |
Returns: | parent of node n |
---|---|
Note: | currently there is only one parent, as instancing is not supported yet |
Returns: | iterator returning all parents of node n |
---|
Write ourselves in hierarchy file format to the given output_path.
Parameter: | root – The root of the written file, nodes above it will not be serialized. |
---|---|
Note: | Directories are expected to exist |
Raises ValueError: | |
If an node’s string representation contains a newline or starts with a tab | |
Note: | works best with strings as nodes, which may not contain newlines |
Bases: object
Descriptor allowing to easily setup callbacks for classes derived from EventSender
Send our event using the given args
Note: | if an event listener is weak referenced and goes out of scope |
---|---|
Note: | will catch all event exceptions trown by the methods called |
Returns: | False if at least one event call threw an exception, true otherwise |
Bases: object
Base class for all classes that want to provide a common callback interface to supply event information to clients.
Usage: Derive from this class and define your callbacks like:
>>> event = Event() >>> # Call it using >>> self.event.send([*args][,**kwargs]])>>> # Users register using >>> yourinstance.event = callable>>> # and deregister using >>> yourinstance.event.remove(callable)
Note: | if use_weakref is True, we will weakref the eventfunction, and deal properly with instance methods which would go out of scope immediatly otherwise |
---|---|
Note: | using weak-references to ensure one does not keep objects alive, see Event.use_weakref |
Remove all event receivers for all events registered in this instance.
Note: | This usually doesn’t need to be called directly, but might be useful in conjunction with other system that do not release your strongly bound instance |
---|
Returns: | list of event ids that exist on our class |
---|
Returns: | instance which sent the event you are currently processing |
---|---|
Raises ValueError: | |
if no event is currently in progress |
Epydoc: mrv.util.InterfaceMaster
Bases: mrv.interface.iDuplicatable
Base class making the derived class an interface provider, allowing interfaces to be set, queried and used including build-in use
Bases: object
If your interface class is derived from this base, you get access to access to call to the number of your current caller.
Note: | You can register an InterfaceBase with several InterfaceMasters and share the caller count respectively |
---|
Return the number of the caller that called your interface method
Note: | the return value of this method is undefined if called if the method has been called by someone not being an official caller (like yourself) |
---|
Returns: | number possible callers |
---|
Returns: | item with separator added to it ( just once ) |
---|---|
Note: | operates best on strings |
Parameters: |
|
Returns: | basename of this path, ‘/hello/world’ -> ‘world’ |
---|
Returns: | list of intermediate children of path, [ child1 , child2 ] |
---|---|
Parameter: | predicate – return True to include x in result |
Note: | the child objects returned are supposed to be valid paths, not just relative paths |
Returns: | list of all children of path, [ child1 , child2 ] |
---|---|
Parameters: |
|
Note: | the child objects returned are supposed to be valid paths, not just relative paths |
Copy the values of ourselves onto the given instance which must be an instance of our class to be compatible. Only the common classes will be copied to instance
Returns: | altered instance |
---|---|
Note: | instance will be altered during the process |
Create and Initialize an instance of self.__class__( ... ) based on your own data
Returns: | new instance of self |
---|---|
Note: | using self.__class__ instead of an explicit class allows derived classes that do not have anything to duplicate just to use your implementeation |
Note: | you must support args and kwargs if one of your iDuplicate bases does |
Implements a c-style copy constructor by creating a new instance of self and applying the copyFrom methods from base to all classes implementing the copyfrom method. Thus we will call the method directly on the class
Parameters: |
|
---|
Returns: | an interface registered with interfaceName |
---|---|
Raises ValueError: | |
if no such interface exists |
Returns: | True if self is a part of other, and thus can be found in other |
---|---|
Note: | operates on strings only |
Returns: | True if this path is the root of the DAG |
---|
Returns: | True other starts with self |
---|---|
Note: | operates on strings |
Note: | we assume other has the same type as self, thus the same separator |
Returns: | generator retrieving all parents up to the root |
---|---|
Parameter: | predicate – returns True for all x that you want to be returned |
Returns: | list of names indicating interfaces available at our InterfaceMaster |
---|
Returns: | parent of this path, ‘/hello/world’ -> ‘/hello’ or None if this path is the dag’s root |
---|
Returns: | all parents of this path, ‘/hello/my/world’ -> [ ‘/hello/my’,’/hello’ ] |
---|
Returns: | the root of the DAG - it has no further parents |
---|
Set the given interfaceInstance to be handed out once an interface with interfaceName is requested from the provider base
Parameters: |
|
---|---|
Raises ValueError: | |
if given InterfaceBase has a master already |
Returns: | True if this instance supports the interface of the given type |
---|---|
Parameter: | interface_type – Type of the interface you require this instance to support |
Note: | Must be used in case you only have a weak reference of your interface instance or proxy which is a case where the ordinary isinstance( obj, iInterface ) will not work |
Epydoc: mrv.util.MetaCopyClsMembers
Bases: type
Meta class copying members from given classes onto the type to be created it will read the following attributes from the class dict: forbiddenMembers, overwritePrefix, __virtual_bases__
The virtual bases are a tuple of base classes whose members you whish to receive For information on these members, check the docs of copyClsMembers
Bases: object
For use with python’s filter method, simulates logical OR Usage: filter(Or(f1,f2,fn), sequence)
Epydoc: mrv.util.PipeSeparatedFile
Bases: object
Read and write simple pipe separated files.
The number of column must remain the same per line Format:
val11 | val2 | valn ...
intiialize the writing process
Parameter: | columnSizes – list of ints defining the size in characters for each column you plan to feed |
---|---|
Note: | When done writing, you have to close the file object yourself (there is no endWriting method here) |
Generator reading one line after another, returning the stripped columns
Returns: | tuple of stripped column strings |
---|---|
Raises ValueError: | |
if the column count changes between the lines |
Write the list of tokens to the file accordingly
Parameter: | tokens – one token per column that you want to write |
---|---|
Raises TypeError: | |
If column count changed between successive calls |
Bases: object
Singleton classes can be derived from this class, you can derive from other classes as long as Singleton comes first (and class doesn’t override __new__)
Epydoc: mrv.util.WeakInstFunction
Bases: object
Create a proper weak instance to an instance function by weakly binding the instance, not the bound function object. When called, the weakreferenced instance pointer will be retrieved, if possible, to finally make the call. If it could not be retrieved, the call will do nothing.
Bases: mrv.interface.Interface
Simple interface allowing any class to be properly duplicated
Note: | to implement this interface, implement createInstance and copyFrom in your class |
---|
Returns: | item with separator added to it ( just once ) |
---|---|
Note: | operates best on strings |
Parameters: |
|
Returns: | basename of this path, ‘/hello/world’ -> ‘world’ |
---|
Returns: | list of intermediate children of path, [ child1 , child2 ] |
---|---|
Parameter: | predicate – return True to include x in result |
Note: | the child objects returned are supposed to be valid paths, not just relative paths |
Returns: | list of all children of path, [ child1 , child2 ] |
---|---|
Parameters: |
|
Note: | the child objects returned are supposed to be valid paths, not just relative paths |
Copy the data from other into self as good as possible Only copy the data that is unique to your specific class - the data of other classes will be taken care of by them !
Note: | you must support args and kwargs if one of your iDuplicate bases does |
---|
Copy the values of ourselves onto the given instance which must be an instance of our class to be compatible. Only the common classes will be copied to instance
Returns: | altered instance |
---|---|
Note: | instance will be altered during the process |
Create and Initialize an instance of self.__class__( ... ) based on your own data
Returns: | new instance of self |
---|---|
Note: | using self.__class__ instead of an explicit class allows derived classes that do not have anything to duplicate just to use your implementeation |
Note: | you must support args and kwargs if one of your iDuplicate bases does |
Implements a c-style copy constructor by creating a new instance of self and applying the copyFrom methods from base to all classes implementing the copyfrom method. Thus we will call the method directly on the class
Parameters: |
|
---|
Returns: | True if self is a part of other, and thus can be found in other |
---|---|
Note: | operates on strings only |
Returns: | True if this path is the root of the DAG |
---|
Returns: | True other starts with self |
---|---|
Note: | operates on strings |
Note: | we assume other has the same type as self, thus the same separator |
Returns: | generator retrieving all parents up to the root |
---|---|
Parameter: | predicate – returns True for all x that you want to be returned |
Returns: | parent of this path, ‘/hello/world’ -> ‘/hello’ or None if this path is the dag’s root |
---|
Returns: | all parents of this path, ‘/hello/my/world’ -> [ ‘/hello/my’,’/hello’ ] |
---|
Returns: | the root of the DAG - it has no further parents |
---|
Returns: | True if this instance supports the interface of the given type |
---|---|
Parameter: | interface_type – Type of the interface you require this instance to support |
Note: | Must be used in case you only have a weak reference of your interface instance or proxy which is a case where the ordinary isinstance( obj, iInterface ) will not work |