jade.utils.utils

Utility functions for the jade package.

Functions

aggregate_data_from_files(directory, ...)

Aggregate objects from files in directory matching end_substring.

check_filename(name)

Validates that a name is valid for use as a filename or directory.

create_chunks(items, size)

Returns a generator dividing items into chunks.

create_script(filename, text[, executable])

Creates a script with the given text.

decompress_file(filename)

Decompress a file.

dump_data(data, filename, **kwargs)

Dump data to the filename.

get_cli_string()

Return the command-line arguments issued.

get_directory_size_bytes(directory[, recursive])

Return the total space consumed by all files in directory.

get_filenames_by_ext(directory, ext)

Return filenames in directory, recursively, with file extension.

get_filenames_in_path(directory, filename[, ...])

Return all files in directory matching filename, searching recursively.

handle_file_not_found(func)

Decorator to catch FileNotFoundError exceptions.

handle_key_error(func)

Decorator to catch KeyError exceptions that happen because the user performs invalid actions.

interpret_datetime(timestamp)

Return a datetime object from a timestamp string.

load_data(filename, **kwargs)

Load data from the file.

make_directory_read_only(directory)

Set all files in the directory to be read-only.

make_file_read_only(filename)

Set the file to be read-only.

modify_file(filename, line_func, *args, **kwargs)

Modifies a file by running a function on each line.

output_to_file(data[, filename, stream, indent])

rmtree(path)

Deletes the directory tree if it exists.

rotate_filenames(directory, ext)

Rotates filenames in directory, recursively, to .1, .2, .etc.

standardize_timestamp(timestamp)

Validate string timestamp and output standard format.

Classes

ExtendedJSONEncoder(*[, skipkeys, ...])

Constructor for JSONEncoder, with sensible defaults.