Utilities Module#

nexus.utilities.per_type_cmp(type_)[source]#
class nexus.utilities.python2_sort_key(ob)[source]#

Bases: object

nexus.utilities.dict_cmp(a, b, _s=<object object>)[source]#
nexus.utilities.sorted_py2(iterable)[source]#
nexus.utilities.to_str(s)[source]#

Convert a value to a string

nexus.utilities.is_valid_path(path: str | bytes | Path) bool[source]#

Screen out paths with invalid characters.

nexus.utilities.is_valid_filename(filename: str | bytes | Path) bool[source]#

Screen out filenames with invalid characters.

nexus.utilities.is_relative_path(path: str | bytes | Path)[source]#

Determine if a path is relative to some current working directory.

nexus.utilities.path_string(path: str | bytes | Path, strict: bool = False, relative: bool = False, check: bool = False) str[source]#

Convert a path to a string.

Parameters:
pathstr, bytes or Path

A file path or directory path.

strictbool, default=False

Require inputted path to be str type. Raises ValueError otherwise.

relativebool, default=False

Check if path is a relative path. Raises ValueError otherwise.

checkbool, default=True

Check if a path contains only valid characters. ValueError is raised for invalid paths.

Returns:
path_outstr

The path as a string.