cape.cfdx.tarcmd: Common tar/untar utilities

This module provides simple functions like tar() and untar() that either call the command-line executable (if available) or the built-in tarfile module.

cape.cfdx.tarcmd.multiglob(*a) → list

Find list of files matching a list of pattterns

Call:
>>> fnames = multiglop(*a)
Inputs:
a: tuple[str]

One or more file name patterns to include in archive

Outputs:
fnames: list[str]

List of files matching any pattern in a

Versions:
  • 2024-09-11 @ddalle: v1.0

cape.cfdx.tarcmd.tar(ftar: str, *a, fmt: str = '', wc: bool = False)

Create an archive

Call:
>>> tar(ftar, *a, fmt='', wc=False)
Inputs:
ftar: str

Name of .tar or .zip file

fmt: {''} | str

Compression format

  • '': uncompressed .tar

  • zip: use .zip instead of .tar

  • z, gz: gzip

  • j, bz2: bzip2

  • J, xz: xz

  • lzma: lzma compression

  • zst: zst compression

a: tuple[str]

One or more file name [patterns] to include in archive

wc: True | {False}

Option for a to be patterns (else fixed file/folder names)

Versions:
  • 2024-09-11 @ddalle: v1.0

cape.cfdx.tarcmd.untar(ftar: str, fmt: str = '')

Unpack an archive

Call:
>>> untar(ftar, fmt='')
Inputs:
ftar: str

Name of .tar or .zip file

fmt: {''} | str

Compression format

  • '': uncompressed .tar

  • zip: use .zip instead of .tar

  • z, gz: gzip

  • j, bz2: bzip2

  • J, xz: xz

  • lzma: lzma compression

  • zst: zst compression

Versions:
  • 2024-09-11 @ddalle: v1.0