nvflare.fuel.hci.zip_utils module

convert_legacy_zip(zip_data: bytes) bytes[source]

Convert a legacy app in zip into job layout in memory.

Parameters

zip_data – The input zip data

Returns

The converted zip data

get_all_file_paths(directory)[source]

Gets all file paths in the directory.

Parameters

directory – directory to get all paths for

Returns

A list of paths of all the files in the provided directory

normpath_for_zip(path)[source]

Normalizes the path for zip file.

Parameters

path (str) – the path to be normalized

remove_leading_dotdot(path: str) str[source]
split_path(path: str) -> (<class 'str'>, <class 'str'>)[source]

Splits a path into a pair of head and tail.

It removes trailing os.path.sep and call os.path.split

Parameters

path – Path to split

Returns

A tuple of (head, tail)

unzip_all_from_bytes(zip_data: bytes, output_dir_name: str)[source]

Decompresses a zip and extracts all files to the specified output directory.

Parameters
  • zip_data – the input zip data

  • output_dir_name – the output directory for extracted content

zip_directory_to_bytes(root_dir: str, folder_name: str) bytes[source]

Compresses a directory and return the bytes value of it.

Parameters
  • root_dir – root path that contains the folder to be zipped

  • folder_name – path to the folder to be zipped, relative to root_dir