swh.core.tarball module#

swh.core.tarball.register_new_archive_formats()[source]#

Register new archive formats to uncompress

swh.core.tarball.uncompress(tarpath: str, dest: str)[source]#

Uncompress tarpath to dest folder if tarball is supported.

Note that this fixes permissions after successfully uncompressing the archive.

Parameters:
  • tarpath – path to tarball to uncompress

  • dest – the destination folder where to uncompress the tarball, it will be created if it does not exist

Raises:

ValueError when a problem occurs during unpacking

swh.core.tarball.normalize_permissions(path: str)[source]#

Normalize the permissions of all files and directories under path.

This makes all subdirectories and files with the user executable bit set mode 0o0755, and all other files mode 0o0644.

Parameters:

path – the path under which permissions should be normalized

swh.core.tarball.compress(tarpath, nature, dirpath_or_files)[source]#

Create a tarball tarpath with nature nature. The content of the tarball is either dirpath’s content (if representing a directory path) or dirpath’s iterable contents.

Compress the directory dirpath’s content to a tarball. The tarball being dumped at tarpath. The nature of the tarball is determined by the nature argument.