tarfile_interface#

ioapps.tarfile_interface.read_tarfile(path, tarball_path, mode=None, filelist=None)[source]#

DESCRIPTION:

This function parses a specified tarball archive and extracts the specified files; if filelist is NoneType upon entry, all files within the archive will be extracted.

Parameters:
path: str

A Python string specifying the path beneath which the contents of the tarball are to be extracted to.

tarball_path: str

A Python string specifying the path to the tarball to be read.

Keywords:
mode: str, optional

A Python string specifying the mode to be used to open the tarball archive; a complete list of combinations can be found at https://docs.python.org/3/library/tarfile.html#tarfile.open.

filelist: List, optional

A Python list of member files within the tarball archive to be extracted.

Raises:
TarFileInterfaceError:
  • raised if an exception is encountered while extracting files from the tarball file path specified upon entry.

  • raised if an execption is encountered while extracting a specified file from the tarball file path specified upon entry.

Return type:

None

ioapps.tarfile_interface.write_tarfile(path, tarball_path, filelist=None, filedict=None, ref_local=False, gzip=False, compresslevel=1)[source]#

DESCRIPTION:

This function creates a POSIX compliant tarball file and appends the files within the specified filelist to the respective tarball file.

Parameters:
path: str

A Python string specifying the path beneath which the files to be archived (see filelist) exist on the local host.

tarball_path: str

A Python string specifying the path to the tarball, containing the contents of path, to be written.

Keywords:
filelist: List, optional

A Python list of filename and/or paths beneath the path to be archived (see path, above); if provided, only the files contained within the list will be writen to tarball archive.

filedict: Dict, optional

A Python dictionary containing the key and value pairs to be used to construct the tarball file; the key values are the local filename path and the corresponding values are the tarball file member file paths.

ref_local: bool, optional

A Python boolean variable specifying whether to define the archive path, within the user-specified tarball, relative to the working directory (path).

gzip: bool, optional

A Python boolean variable specifying whether to apply gzip compression to the tarball.

compresslevel: int, optional

A Python integer value specifying the compression level for the archive; the default is minimal compression.

Raises:
TarFileInterfaceError:
  • raised if an exception is encountered while validating the parameter values provided upon entry.

Return type:

None