Logging Module

class pybacked.logging.MetadataContainer(timestamp=None)

A container class to hold metadata of a given archive.

Parameters

timestamp (float) – The timestamp at the creation of the archive

pybacked.logging.create_log(diffcache)

Create a diff-log from a given diffcache. This function only returns the content of the diff-log.txt, it does not create or write the diff-file itself.

Parameters

diffcache (DiffCache) – The DiffCachhe object returned by diff.collect()

Returns

The Content of the diff-log in string form.

Return type

str

pybacked.logging.create_metadata_string(metadata)

Create a serialized json string from the given metadata.

Parameters

metadata (MetadataContainer) – The metadata which should be serialized.

Returns

Returns the string containing the json-style metadata

Return type

str

pybacked.logging.serialize_diff(diffcache, subdir='')

Serialize the information in the diffcache for csv writing. Return a list of rows which can be written to the csv without further processing.

Parameters
  • diffcache (DiffCache) – The DiffCache object to be serialized

  • subdir (str) – The subdir seriaize_diff is currently working in. Mainly used for recursion

Returns

A List of csv-rows (3-element-Lists)

Return type

List

pybacked.logging.write_log(diffcache, archivepath, compression, compresslevel)

Writes the log created by create_log() directly to the diff-log.csv in the given zip-archive.

Parameters
  • diffcache (DiffCache) – The DiffCache from which the log will be created

  • archivepath (str) – The path to the archive

  • compression (int) – The chosen compression algorithm

  • compresslevel (int) – The chosen compression level (0-9)

pybacked.logging.write_metadata(metadata, archpath, compression, compresslevel)

Writes the metadata created by create_metadata_string to a metadata.json file in the archive.

Prarm archpath

The path to the archive

Parameters
  • metadata (MetadataContainer) – The metadata to be written to the file.

  • compression (int) – The chosen compression algorithm

  • compresslevel (int) – The chosen compression level (0-9)

Returns

Doesn’t return anything