files

Tools for paths and files

Functions

add_to_zip(zip_path, dirs_to_add)

Add folders to an already existing zip file (recursively).

archive(folder_path, archive_path[, fmt])

Archives a folder recursively.

copy(src, dst)

Copy a file or a directory (recursively) with copytree or copy2.

extract_file(file_path, output[, overwrite])

Extract an archived file (zip or others).

extract_files(archives, output[, overwrite])

Extract all archived files.

find_files(names, root_paths[, ...])

Returns matching files recursively from a list of root paths.

get_archived_file_list(archive_path)

Get the list of all the files contained in an archive.

get_archived_rio_path(archive_path, file_regex)

Get archived file path from inside the archive, to be read with rasterio:

get_file_in_dir(directory, pattern_str[, ...])

Get one or all matching files (pattern + extension) from inside a directory.

get_filename(file_path)

Get file name (without extension) from file path, ie:

get_root_path()

Get the root path of the current disk:

hash_file_content(file_content[, len_param])

Hash a file into a unique str.

is_writable(dir_path)

Determine whether the directory is writeable or not :param dir_path: Directory path :type dir_path: Union[str, CloudPath, Path]

listdir_abspath(directory)

Get absolute path of all files in the given directory.

load_obj(path)

Load a pickled object.

read_archived_file(archive_path, regex)

Read archived file (in bytes) from zip or tar archives.

read_archived_html(archive_path, regex)

Read archived HTML from zip or tar archives.

read_archived_xml(archive_path, xml_regex)

Read archived XML from zip or tar archives.

read_json(json_file[, print_file])

Read a JSON file

real_rel_path(path, start)

Gives the real relative path from a starting folder.

remove(path)

Deletes a file or a directory (recursively) using shutil.rmtree or os.remove.

remove_by_pattern(directory[, ...])

Remove files corresponding to a pattern from a directory.

save_json(output_json, json_dict)

Save a JSON file, with datetime, numpy types and Enum management.

save_obj(obj, path)

Save an object as a pickle (can save any Python objects).

to_abspath(path[, create])

Return the absolute path of the specified path and check if it exists

Classes

CustomDecoder(*args, **kwargs)

Decoder for JSON with methods for datetimes

CustomEncoder(*[, skipkeys, ensure_ascii, ...])

Encoder for JSON with methods for datetimes and np.int64