py_trees.utilities module
Assorted utility functions.
- class py_trees.utilities.Process(*args: Any, **kwargs: Any)
Bases:
Process
Convenience wrapper around multiprocessing.Process.
- property exception: Any
Check the connection, if there is an error, reflect it as an exception.
- Returns:
The exception.
- run() None
Start the process, handle exceptions if needed.
- py_trees.utilities.get_fully_qualified_name(instance: object) str
Retrieve the fully qualified name of an object.
For example, an instance of
Sequence
becomes ‘py_trees.composites.Sequence’.- Args:
instance (
object
): an instance of any class- Returns:
str
: the fully qualified name
- py_trees.utilities.get_valid_filename(s: str) str
Clean up and style a string so that it can be used as a filename.
This is valid only from the perspective of the py_trees package. It does place a few extra constraints on strings to keep string handling and manipulation complexities to a minimum so that sanity prevails.
Removes leading and trailing spaces
Convert other spaces and newlines to underscores
Remove anything that is not an alphanumeric, dash, underscore, or dot
>>> utilities.get_valid_filename("john's portrait in 2004.jpg") 'johns_portrait_in_2004.jpg'
- Args:
program (
str
): string to convert to a valid filename- Returns:
str
: a representation of the specified string as a valid filename
- py_trees.utilities.is_primitive(incoming: Any) bool
Check if an incoming argument is a primitive type with no esoteric accessors.
That is, it has no class attributes or container style [] accessors.
- Args:
incoming: the instance to check
- Returns:
True or false, depending on the check against the reserved primitives
- py_trees.utilities.static_variables(**kwargs: Any) Callable[[C], C]
Attach initialised static variables to a python method.
@static_variables(counter=0) def foo(): foo.counter += 1 print("Counter: {}".format(foo.counter))
- py_trees.utilities.truncate(original: str, length: int) str
Provide an elided (…) version of a string if it is longer than desired.
- Args:
original: string to elide length: constrain the elided string to this
- py_trees.utilities.which(program: str) str | None
Call the command line ‘which’ tool (convenience wrapper).
- Args:
program: name of the program to find.
- Returns:
path to the program or None if it doesnt exist.