dazu.utils package

Submodules

dazu.utils.io module

dazu.utils.io.create_directory(directory_path: str) → None

Creates a directory and its super paths. Succeeds even if the path already exists.

dazu.utils.io.create_directory_for_file(file_path: str) → None

Creates any missing parent directories of this file path.

dazu.utils.io.create_path(file_path: str) → None

Makes sure all directories in the ‘file_path’ exists.

dazu.utils.io.create_temporary_file(data: Any, suffix: str = '', mode: str = 'w+') → str

Creates a tempfile.NamedTemporaryFile object for data. mode defines NamedTemporaryFile’s mode parameter in py3.

dazu.utils.io.dump_obj_as_json_to_file(filename: str, obj: Any) → None

Dump an object as a json string to a file.

dazu.utils.io.enable_async_loop_debugging(event_loop: asyncio.events.AbstractEventLoop, slow_callback_duration: float = 0.1) → asyncio.events.AbstractEventLoop
dazu.utils.io.fix_yaml_loader() → None

Ensure that any string read by yaml is represented as unicode.

dazu.utils.io.is_subdirectory(path: str, potential_parent_directory: str) → bool
dazu.utils.io.list_directory(path: str) → List[str]

Returns all files and folders excluding hidden files. If the path points to a file, returns the file. This is a recursive implementation returning files in any depth of the path.

dazu.utils.io.list_files(path: str) → List[str]

Returns all files excluding hidden files. If the path points to a file, returns the file.

dazu.utils.io.list_subdirectories(path: str) → List[str]

Returns all folders excluding hidden files. If the path points to a file, returns an empty list.

dazu.utils.io.read_config_file(filename: str) → Dict[str, Any]

Parses a yaml configuration file. Content needs to be a dictionary :param filename: The path to the file which should be read.

dazu.utils.io.read_file(filename: str, encoding: str = 'utf-8') → Any

Read text from a file.

dazu.utils.io.read_json_file(filename: str) → Any

Read json from a file.

dazu.utils.io.read_yaml(content: str) → Union[List[Any], Dict[str, Any]]

Parses yaml from a text. :param content: A text containing yaml content.

dazu.utils.io.read_yaml_file(filename: str) → Union[List[Any], Dict[str, Any]]

Parses a yaml file. :param filename: The path to the file which should be read.

dazu.utils.io.replace_environment_variables() → None

Enable yaml loader to process the environment variables in the yaml.

dazu.utils.io.unarchive(byte_array: bytes, directory: str) → str

Tries to unpack a byte array interpreting it as an archive. Tries to use tar first to unpack, if that fails, zip will be used.

dazu.utils.io.write_text_file(content: str, file_path: Union[str, pathlib.Path], encoding: str = 'utf-8', append: bool = False) → None

Writes text to a file. :param content: The content to write. :param file_path: The path to which the content should be written. :param encoding: The encoding which should be used. :param append: Whether to append to the file or to truncate the file.

dazu.utils.io.write_yaml_file(data: Dict, filename: Union[str, pathlib.Path]) → None

Writes a yaml file. :param data: The data to write. :param filename: The path to the file which should be written.

dazu.utils.io.zip_folder(folder: str) → str

Create an archive from a folder.

Module contents