cape.tar: Semiautomatic folder archiving

This is a module for tarring and untarring folders automatically in combination with changing directory into and out of the folder. This function works in combination primarily with the cape.cfdx.report.Report class when the "Report" > "Archive" option is set to True.

The primary functions and their actions are:

  • chdir_up(): Leave a folder, archive it, and delete the folder
    • Starting from folder called thisdir/

    • cd ..

    • tar -uf thisdir.tar thisdir

    • rm -r thisdir/

  • chdir_in(): Go into a folder that may be archived
    • tar -xf thisdir.tar

    • cd thisdir/

cape.tar.chdir_in(fdir)

Go into a folder that may be archived

Call:
>>> tar.chdir_in(fdir)
Inputs:
fdir: str

Name of folder

Versions:
  • 2015-03-07 @ddalle: First version

cape.tar.chdir_up()

Leave a folder, archive it, and delete the folder

Call:
>>> tar.chdir_up()
Versions:
  • 2015-03-07 @ddalle: First version

cape.tar.tar(ftar, *a)

Untar an archive

Call:
>>> tar.tar(ftar, fdir, *a)
Inputs:
ftar: str

Name of the archive

fdir: str

Name of the folder to archive, for example

a: list (str)

Additional arguments are also passed to the tar command

Versions:
  • 2015-03-07 @ddalle: First version

  • 2019-11-07 @ddalle: Using tarfile

cape.tar.untar(ftar)

Untar an archive

Call:
>>> ierr = tar.untar(ftar)
Inputs:
ftar: str

Name of the archive to untar

Outputs:
ierr: int

Exit code from the tar command

Versions:
  • 2015-03-07 @ddalle: First version