Package mrv :: Module util
[hide private]
[frames] | no frames]

Module util

source code

All kinds of utility methods and classes that are used in more than one modules
Classes [hide private]
  And
For use with python's filter method, simulates logical AND Usage: filter(And(f1,f2,fn), sequence)
  Call
Call object encapsulating any code, thus providing a simple facade for it :note: derive from it if a more complex call is required
  CallAdv
Advanced call class providing additional options:
  CallOnDeletion
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
  DAGTree
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
  Event
Descriptor allowing to easily setup callbacks for classes derived from EventSender
  EventSender
Base class for all classes that want to provide a common callback interface to supply event information to clients.
  InterfaceMaster
Base class making the derived class an interface provider, allowing interfaces to be set, queried and used including build-in use
  MetaCopyClsMembers
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__
  Or
For use with python's filter method, simulates logical OR Usage: filter(Or(f1,f2,fn), sequence)
  PipeSeparatedFile
Read and write simple pipe separated files.
  Singleton
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__)
  WeakInstFunction
Create a proper weak instance to an instance function by weakly binding the instance, not the bound function object.
Functions [hide private]
 
capitalize(s)
Returns: s with first letter capitalized
source code
 
copyClsMembers(sourcecls, destcls, overwritePrefix=None, forbiddenMembers=[], copyNamespaceGlobally=None)
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
source code
 
decodeString(valuestr)
Returns: int,float or str from string valuestr - a string that encodes a numeric value or a string
source code
 
decodeStringOrList(valuestrOrList)
Returns: as decodeString, but returns a list of appropriate values if the input argument is a list or tuple type
source code
 
iterNetworkxGraph(graph, startItem, direction=0, prune=<function <lambda> at 0x2aedb90>, stop=<function <lambda> at 0x2aedc08>, depth=-1, branch_first=True, visit_once=True, ignore_startitem=1)
Returns: iterator yielding pairs of depth, item
source code
 
list_submodules(path)
Returns: set(submodule_name, ...) list of submodule names that could be imported using __import__
source code
 
list_subpackages(path)
Returns: list of sub-package names
source code
 
packageClasses(importBase, packageFile, predicate=<function <lambda> at 0x2aedaa0>)
Returns: all classes of modules of the given package file that additionally match given predicate
source code
 
pythonIndex(index, length)
Compute the actual index based on the given index and array length, thus -1 will result in the last array element's index
source code
 
uncapitalize(s, preserveAcronymns=False)
Returns: s with first letter lower case
source code
Variables [hide private]
  __package__ = 'mrv'
  log = <logging.Logger instance at 0x2ae99e0>
Function Details [hide private]

capitalize(s)

source code 
Returns:
s with first letter capitalized

copyClsMembers(sourcecls, destcls, overwritePrefix=None, forbiddenMembers=[], copyNamespaceGlobally=None)

source code 
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:
  • sourcecls - class whose members should be copied
  • destcls - class to receive members from sourcecls
  • overwritePrefix - if None, existing members on destcls will not be overwritten, if string, the original method will be stored in a name like prefix+originalname (allowing you to access the original method lateron)
  • copyNamespaceGlobally - if not None, the variable contains the name of the namespace as string whose methods should also be copied into the global namespace, possibly overwriting existing ones. For instance, 'nsmethod' will be available as obj.nsmethod and as obj.method if the namespace value was 'ns. The forbiddenMembers list is applied to the original as well as the global name
Notes:
  • this can be useful if you cannot inherit from a class directly because you would get method resolution order problems
  • see also the MetaCopyClsMembers meta class

decodeString(valuestr)

source code 
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

decodeStringOrList(valuestrOrList)

source code 
Returns:
as decodeString, but returns a list of appropriate values if the input argument is a list or tuple type

iterNetworkxGraph(graph, startItem, direction=0, prune=<function <lambda> at 0x2aedb90>, stop=<function <lambda> at 0x2aedc08>, depth=-1, branch_first=True, visit_once=True, ignore_startitem=1)

source code 
Parameters:
  • direction - specifies search direction, either : 0 = items being successors of startItem 1 = items being predecessors of startItem
  • prune - return True if item d,i in graph g should be pruned from result. d is the depth of item i
  • stop - return True if item d,i in graph g, d is the depth of item i stop the search in that direction. It will not be returned.
  • depth - define at which level the iteration should not go deeper if -1, there is no limit if 0, you would only get startitem. i.e. if 1, you would only get the startitem and the first level of predessessors/successors
  • branch_first - if True, items will be returned branch first, otherwise depth first
  • visit_once - if True, items will only be returned once, although they might be encountered several times
  • ignore_startitem - if True, the startItem will be ignored and automatically pruned from the result
Returns:
iterator yielding pairs of depth, item

Note: this is an adjusted version of dge.iterShells

list_submodules(path)

source code 
Parameters:
  • path - module path containing the submodules
Returns:
set(submodule_name, ...) list of submodule names that could be imported using __import__

list_subpackages(path)

source code 
Returns:
list of sub-package names

packageClasses(importBase, packageFile, predicate=<function <lambda> at 0x2aedaa0>)

source code 
Parameters:
  • importBase - longest import base path whose submodules contain the classes to import
  • packageFile - the filepath to the package, as given in your __file__ variables
  • predicate - receives the class and returns True if it is a class you are looking for
Returns:
all classes of modules of the given package file that additionally match given predicate

uncapitalize(s, preserveAcronymns=False)

source code 
Parameters:
  • preserveAcronymns - enabled ensures that 'NTSC' does not become 'nTSC'
Returns:
s with first letter lower case

Note: from pymel