tar

TAR I/O module.

Classes

TarReader

Safe TAR reader

TarWriter

Safe TAR writer.

class TarReader[source]

Bases: object

Safe TAR reader

static check(path)[source]

Checks that a file is of the correct extension and exists.

Parameters:

path (Union[str, Path]) – Path to the file.

Returns:

static read(path, verbose=True)[source]

Extracts the content from a TAR archive.

Parameters:
  • path (Union[str, Path]) – Path to the file.

  • verbose (Union[bool, int]) – Verbosity of the method.

Return type:

Dict[str, Any]

Returns:

Extracted data.

class TarWriter[source]

Bases: object

Safe TAR writer.

static check(path, overwrite=False)[source]

Checks that a file has of the correct extension and verifies that we can overwrite it if it exists.

Parameters:
  • path (Union[str, Path]) – Path to the file.

  • overwrite (bool)

Returns:

static write(dictionary, path, overwrite=False, verbose=True)[source]

Write a TAR archive of the dictionary, each key/value represents a single path name and associated file.

Parameters:
  • dictionary (Dict[str, Any]) – Dictionary to be archived.

  • path (Union[str, Path]) – Path to the file.

  • overwrite (bool) – Whether to overwrite, in case of an existing file.

  • verbose (Union[bool, int]) – Verbosity of the method.

Returns: