paya.util.functions#
- class Undefined#
An instance of this class,
undefined
in this module, is used across Paya for keyword argument defaults for whichNone
would not represent omission.
- class short(**mapping)#
Decorator with keyword arguments, used to mimic Maya’s ‘shorthand’ flags.
- Example
@short(numJoints='nj') def makeJoints(numJoints=16): [...] # This can then be called as: makeJoints(nj=5)
- __call__(f)#
Call self as a function.
- resolveFlags(*flags, radio=None)#
Resolves passed-in user option values by omission, Maya style.
- Example
userVals = resolveFlags(True, None, None) # True, False, False userVals = resolveFlags(False, None, None) # False, True, True userVals = resolveFlags(None, None, None) # True, True, True userVals = resolveFlags(True, None, False) # True, True, False userVals = resolveFlags(None, None, None, radio=0) # True, False, False userVals = resolveFlags(None, False, None, radio=0) # True, False, False userVals = resolveFlags(True, None, True, radio=0) # ValueError: Multiple radio selection.
- Parameters
*flags (
bool
,None
) – the passed-in user option values, in orderradio – if this is defined, it should be an integer specifying which item should be
True
in a single-selection radio setup; defaults toNone
- Returns
The resolved flag values, in order.
- Return type
- conditionalExpandArgs(*args, gate=None)#
Flattens tuples and lists in user arguments into a single list.
- Parameters
*args – the arguments to expand
gate/g – if provided, this should be a callable that takes one argument and returns
True
if the item should be expanded or not (useful for preserving vectors in list form etc.); will only be used for tuples and lists; defaults to None
- Returns
The flattened args.
- Return type
- sigCollectsKwargs(signature)#
- Parameters
signature (
inspect.Signature
) – the signature object- Returns
True
if the signature object collects keyword arguments, otherwiseFalse
.
- sigWithAddedKwargs(signature, **kwargs)#
- Parameters
signature (
inspect.Signature
) – the original signature object**kwargs – defines keywords arguments, with defaults, to add to the signature copy.
- Returns
A copy of signature with the passed keyword arguments mixed-in.