ways.helper.common module¶
A collection of functions that are used by modules in this package.
This module is not likely to change often.
-
ways.helper.common.
conform_decode
(info)[source]¶ Make sure that ‘create_using’ returns a single string.
-
ways.helper.common.
encode
(obj)[source]¶ Make the given descriptor information into a standard URL encoding.
Parameters: - obj (dict[str]) – The Descriptor information to serialize.
- is normally something like (This) –
- {'create_using' – ways.api.FolderDescriptor}.
Returns: The output encoding.
Return type: str
-
ways.helper.common.
expand_string
(format_string, obj)[source]¶ Split a string into a dict using a Python-format string.
Warning
Format-strings that have two tokens side-by-side are invalid. They must have at least some character between them. This format_string is invalid ‘{NAME}{ID}’, this format_string is valid ‘{NAME}_{ID}’.
Example
>>> shot = 'NAME_010' >>> format_string = '{SHOT}_{ID}' >>> expand_string(format_string, shot) ... {'SHOT': 'NAME', 'ID': '010'}
Parameters: - format_string (str) – The Python-format style string to use to split it.
- obj (str) – The string to split out into a dict.
Raises: ValueError
– If the format_string given is invalid.Returns: The created dict from our obj string.
Return type: dict
-
ways.helper.common.
get_platforms
(obj)[source]¶ tuple[str]: The the platform(s) for the given object.
-
ways.helper.common.
get_python_files
(item)[source]¶ Get the Python files at some file or directory.
Note
If the given item is a Python file, just return it.
Parameters: item (str) – The absolute path to a file or folder. Returns: The Python files at the given location. Return type: list[str]
-
ways.helper.common.
import_object
(name)[source]¶ Import a object of any kind, as long as it is on the PYTHONPATH.
Parameters: name (str) – An import name (Example: ‘ways.api.Plugin’) Raises: ImportError
– If some object down the name chain was not importable or if the entire name could not be found in the PYTHONPATH.Returns: The imported module, classobj, or callable function, or object.
-
ways.helper.common.
split_hierarchy
(obj, as_type=<type 'tuple'>)[source]¶ Split a hierarchy into pieces, using the “/” character.
Parameters: - obj (str or tuple[str]) – The hierarchy to split.
- as_type (
callable
, optional) – The iterable type to return the hierarchy.
Returns: The hierarchy, split into pieces.
Return type: tuple[str]
-
ways.helper.common.
split_into_parts
(obj, split, as_type=<type 'tuple'>)[source]¶ Split a string-like object into parts, using some split variable.
Example
>>> path = 'some/thing' >>> split_into_parts(path, split='/') ... ('some', 'thing')
Parameters: - obj (str or iterable) – The object to split.
- split (str) – The character(s) to split obj by.
- as_type (
callable[iterable[str]]
, optional) – The type to return from this function. Default: tuple.
Returns: The split pieces.
Return type: as_type[str]