Zip Handler

pybacked.zip_handler.archive_write(archivepath, data, filename, compression, compressionlevel)

Create a file named filename in the archive and write data to it

Parameters
  • archivepath (str) – The path to the zip-archive

  • data (str) – The data to be written to the file

  • filename (str) – The filename for the newly created file

  • compression (int) – The desired compression for the zip-archive

  • compressionlevel (int) – The desired compression level for the zip-archive

Returns

void

pybacked.zip_handler.create_archive(archivepath, filedict, compression, compressionlevel)

Write filedict to zip-archive data subdirectory. Will check wether archive at archivepath exists before writing. If file exists will raise a FileExistsError.

Parameters
  • archivepath – the path to the file

  • filedict – dictionary containing the filepath, filename key-value pairs

  • compression – desired compression methods (see zipfile documentation)

  • compressionlevel – compression level (see zipfile documentation)

Returns

void

pybacked.zip_handler.extract_archdata(archivepath, filename, destination)

Extract a file from a archive and write it to the destination. If the destination path already exists extract_archdata will not overwrite but will throw a “FileExists” error.

Parameters
  • archivepath (str) – The path to the archive containing the file

  • filename (str) – The archive name of the desired file.

  • destination (str) – The path at which the extracted file is to be placed.

Returns

void

Return type

None

pybacked.zip_handler.read_bin(archivepath, filelist)

Read a list of files from an archive and return the file data as a dictionary of filename, data key-value pairs.

Parameters
  • archivepath – the path to the archive

  • filelist – list of filenames to read

Returns

dictionary with filename, data key-value pairs

Return type

dict

pybacked.zip_handler.read_diff_log(archivepath)

Read the diff-log.csv from a given archive file.

Parameters

archivepath (str) – The path to the zip-archive

Returns

The diff-log.csv contents in ascii string form.

Return type

str

pybacked.zip_handler.zip_extract(archivepath, filelist, extractpath)

Extract a list of files to a specific location

Parameters
  • archivepath – the path to the zip-archive

  • filelist – list of member filenames to extract

  • extractpath – path for the extracted files

Returns

void