command_interpreter.utils – Utilities¶
Utility functionalities
-
vdat.command_interpreter.utils.id_(*args)[source]¶ Identity function: returns the input unchanged
If the input is one element only, extract it from
argsExamples
>>> id_() () >>> id_(5) 5 >>> id_(3, 4) (3, 4) >>> a, b, c = id_(2, 3, 4) >>> print(a, b, c) 2 3 4
-
vdat.command_interpreter.utils.flip(func)[source]¶ Flip the order of the arguments in the function
Can also be used a decorator
Parameters: - func : callable
function to replace
Returns: - callable
-
vdat.command_interpreter.utils.multiwrap(*decorators)[source]¶ Create a decorator combining the given decorators
-
class
vdat.command_interpreter.utils.SliceLike(str_or_int, *args)[source]¶ A slice like object, but it’s not usable as
slice.If the input argument is a string of
:or,separated integers parse it assuming[start]:[stop][:step].start,stop, andstepmust be integers orNone; the latter is optional and cannot be zero.It’s possible to use the
instatement to check if a value is in the slice with the following logic:- if
startis not given, it checks that the value is less thanstop - if
stopis not given, it checks that the value is greater or equal thanstart - if neither
startnotstopare given andstepis not given or one, returnsTrue - if
stepis not 1, it checks that the value is equal tostart + n*stepwith integern. - if
startis not given andstepis not 1, returnsFalse; undefined behaviour.
Parameters: - str_or_int, args : string or one/two/three integers
if the first argument is a string is parsed as if it’s a
:or,separated one and all the elements are converted to None (if empty) or to integers. In this case no other arguments are allowed. If the arguments are integers are interpreted as:SliceLike(stop)SliceLike(start, stop[, step])
Raises: - CISliceError
if the initialisation fails
Attributes: -
start¶ Start of the slice (read only)
-
stop¶ Stop of the slice (read only)
-
step¶ Step of the slice (read only)
- if
-
vdat.command_interpreter.utils.abstractproperty(func)¶ - Python 3: decorator from combining
propertyandabc.abstractmethod() - Python 2: alias of
abc.abstractproperty()
- Python 3: decorator from combining