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 20240318: Initial PyPI release with nice traced_cpdir() function.

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:]))

Function 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

Function traced_cpdir(srcdirpath, dstdirpath, *, label=None, tar_exe='tar', bcount=2048, upd)

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

Function traced_untar(tarfd, *, chdirpath='.', label=None, tar_exe='tar', bcount=2048, total=None, _stat_fd=False, upd)

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 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-20240318.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

cs.tarutils-20240318-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file cs.tarutils-20240318.tar.gz.

File metadata

  • Download URL: cs.tarutils-20240318.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.6

File hashes

Hashes for cs.tarutils-20240318.tar.gz
Algorithm Hash digest
SHA256 94970061d5dae7d4894a808082e5d8e36e64a357ddb4c914b0174fbbb6e255e9
MD5 c9505f2b1cf3397164373f9a01715263
BLAKE2b-256 5712f48e1201bbb7923a18b4f22b4be4d99297c152979f97bbb5d73d71a6483c

See more details on using hashes here.

File details

Details for the file cs.tarutils-20240318-py3-none-any.whl.

File metadata

File hashes

Hashes for cs.tarutils-20240318-py3-none-any.whl
Algorithm Hash digest
SHA256 6829df016051a16e4cefd9b39a4edff35b3e88585f70081b4995b75567b25180
MD5 91219db4a5d0a5a99c445952ea2774a1
BLAKE2b-256 4c17c20665757b8d3253b64bd55313ef638a51f5a2ec939a7cc06ff86855bef9

See more details on using hashes here.

Supported by

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