Skip to main content

Assorted tar related things, including a fast tar-based copy.

Project description

Assorted tar related things, including a fast tar-based copy.

Latest release 20260531: Update because an IterableQueue no longer has a .open() method.

My most heavily used use for this is my cpdir script which does a high performance directory copy by piping 2 tars together. It runs this:

from cs.tarutils import traced_cpdir
sys.exit(traced_cpdir(*sys.argv[1:]))

Short summary:

  • tar: Tar up the contents of srcpaths to output. Return the Popen object for the tar command.
  • traced_cpdir: Copy a directory to a new place using piped tars with progress reporting. Return 0 if both tars succeed, nonzero otherwise.
  • traced_untar: Read tar data from tarfd and extract. Return the tar exit code.

Module contents:

  • tar(*srcpaths: List[str], chdirpath='.', output, tar_exe='tar', bcount=2048): Tar up the contents of srcpaths to output. Return the Popen object for the tar command.

    Parameters:

    • srcpaths: source filesystem paths
    • chdirpath: optional directory to which to chdir before accessing srcpaths
    • tar_exe: optional tar executable, default from TAR_EXE: tar
    • bcount: blocking factor in 512 byte unites, default from DEFAULT_BCOUNT: 2048
  • traced_cpdir(*a, upd: Optional[cs.upd.Upd] = <function uses_upd.<locals>.<lambda> at 0x10b0b7920>, **kw): Copy a directory to a new place using piped tars with progress reporting. Return 0 if both tars succeed, nonzero otherwise.

    Parameters:

    • srcdirpath: the source directory filesystem path
    • dstdirpath: the destination directory filesystem path, which must not already exist
    • label: optional label for the progress bar
    • tar_exe: optional tar executable, default from TAR_EXE: tar
    • bcount: blocking factor in 512 byte unites, default from DEFAULT_BCOUNT: 2048
  • traced_untar(*a, upd: Optional[cs.upd.Upd] = <function uses_upd.<locals>.<lambda> at 0x10b0b7560>, **kw): Read tar data from tarfd and extract. Return the tar exit code.

    Parameters:

    • tarfd: the source tar data, suitable for subprocess.Popen's stdin parameter
    • chdirpath: optional directory to which to chdir before accessing srcpaths
    • label: optional label for the progress bar
    • tar_exe: optional tar executable, default from TAR_EXE: tar
    • bcount: blocking factor in 512 byte unites, default from DEFAULT_BCOUNT: 2048

Release Log

Release 20260531: Update because an IterableQueue no longer has a .open() method.

Release 20240318: Initial PyPI release with nice traced_cpdir() function.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cs_tarutils-20260531.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cs_tarutils-20260531-py2.py3-none-any.whl (5.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file cs_tarutils-20260531.tar.gz.

File metadata

  • Download URL: cs_tarutils-20260531.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for cs_tarutils-20260531.tar.gz
Algorithm Hash digest
SHA256 6855e4d5084e3512ab40a340b416d3b03bc19de9b02cd7996838b5fa2ff4e8e2
MD5 aaf0d64217cb7596480b703d38887c18
BLAKE2b-256 51f660503906a4f9dd46f71cbe883fb2791d0dc21d5c99cf6f3f65bb4efdc050

See more details on using hashes here.

File details

Details for the file cs_tarutils-20260531-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for cs_tarutils-20260531-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a0890f523d479e2102f2d2ac02b4faa261a52a6e0640b89c947af6a4675bbcfa
MD5 3348ad7090fc06d6f41bafa6a80e2854
BLAKE2b-256 14b2b4983e60664cbdeb9b8b3139c838c44873057ae3037036c0495b5f60c820

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page