Skip to main content

A simple tar library for Python.

Project description

shiertier_tar

English | 中文

Introduction

shiertier_tar is a Python library designed to simplify the process of working with tar archives. It provides a set of utility functions to pack directories into tar files, unpack tar files, create and manage tar file indexes, and perform various operations on tar files. This library is particularly useful for managing large datasets or archives in a structured manner. This project is a simplified version of [hfutils].

Installation

You can install shiertier_tar via pip:

pip install shiertier_tar

Please note that this project is still under development.

Usage

Packing a Directory to a Tar File

You can pack a directory into a tar file using the pack_directory_to_tarfile function. This function allows you to specify a source directory, an optional archive file name, and a pattern to filter files.

from shiertier_tar import pack_directory_to_tarfile

# Pack a directory into a tar file
pack_directory_to_tarfile(src_directory='path/to/source_directory', archive_file='path/to/archive.tar', pattern='*.txt;*.md')

Unpacking a Tar File

You can unpack a tar file using the unpack_tarfile function. This function allows you to specify the tar file and an optional destination directory.

from shiertier_tar import unpack_tarfile

# Unpack a tar file
unpack_tarfile(archive_file='path/to/archive.tar', directory='path/to/destination_directory')

Creating an Index from a Tar File

You can create an index from a tar file using the create_index_from_tarfile function. This function allows you to specify the tar file and an optional index directory.

from shiertier_tar import create_index_from_tarfile

# Create an index from a tar file
create_index_from_tarfile(archive_file='path/to/archive.tar', directory='path/to/index_directory')

Creating a Tar File Index for a Directory

You can create a tar file index for a directory using the create_tarfile_index_for_directory function. This function allows you to specify the source directory, an optional archive file name, an optional index directory, and a pattern to filter files.

from shiertier_tar import create_tarfile_index_for_directory

# Create a tar file index for a directory
create_tarfile_index_for_directory(src_directory='path/to/source_directory', archive_file='path/to/archive.tar', index_directory='path/to/index_directory', pattern='*.txt;*.md')

Listing Files in a Tar File

You can list files in a tar file using the list_files_in_tarfile function. This function allows you to specify the tar file and an optional index file.

from shiertier_tar import list_files_in_tarfile

# List files in a tar file
files = list_files_in_tarfile(archive_file='path/to/archive.tar')
print(files)

Checking if a File Exists in a Tar File

You can check if a file exists in a tar file using the is_file_in_tarfile function. This function allows you to specify the tar file, the file in the archive, and an optional index file.

from shiertier_tar import is_file_in_tarfile

# Check if a file exists in a tar file
exists = is_file_in_tarfile(archive_file='path/to/archive.tar', file_in_archive='file_in_archive.txt')
print(exists)

Getting File Size in a Tar File

You can get the size of a file in a tar file using the get_file_size_in_tarfile function. This function allows you to specify the tar file, the file in the archive, and an optional index file.

from shiertier_tar import get_file_size_in_tarfile

# Get the size of a file in a tar file
size = get_file_size_in_tarfile(archive_file='path/to/archive.tar', file_in_archive='file_in_archive.txt')
print(size)

Getting File Info in a Tar File

You can get information about a file in a tar file using the get_file_info_in_tarfile function. This function allows you to specify the tar file, the file in the archive, and an optional index file.

from shiertier_tar import get_file_info_in_tarfile

# Get information about a file in a tar file
info = get_file_info_in_tarfile(archive_file='path/to/archive.tar', file_in_archive='file_in_archive.txt')
print(info)

Exporting a File from a Tar File

You can export a file from a tar file using the export_file_from_tarfile function. This function allows you to specify the tar file, the file in the archive, the local file path, an optional index file, and an optional chunk size.

from shiertier_tar import export_file_from_tarfile

# Export a file from a tar file
export_file_from_tarfile(archive_file='path/to/archive.tar', file_in_archive='file_in_archive.txt', local_file='path/to/local_file.txt')

Dependencies

  • hfutils

License

This project is released under the MIT License. See the LICENSE file for details.

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

shiertier_tar-0.0.3.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

shiertier_tar-0.0.3-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file shiertier_tar-0.0.3.tar.gz.

File metadata

  • Download URL: shiertier_tar-0.0.3.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for shiertier_tar-0.0.3.tar.gz
Algorithm Hash digest
SHA256 136ef26a2b985ae7331c888b80e38b75981cec309aa5ddc185e0637fa557b287
MD5 2d4c7acb43d5d86a67e40d23a8af4257
BLAKE2b-256 62725b130d8e1fae16994604cabd500c6c97decdf179a0d49309d3d39a652def

See more details on using hashes here.

File details

Details for the file shiertier_tar-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: shiertier_tar-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for shiertier_tar-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ff194c1d90717410605a23d9efbde9d073cdff4b673db0fcb30530603180e686
MD5 da8d29c0bdcb024b27ea7fc495623603
BLAKE2b-256 41070bed184cfae48ad612a05a6047fa26d62f651bb4bb04ad2127783f2eac02

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