Skip to main content

TestStatus PyPiStatus BlackStyle BlackPackStyle MITLicenseBadge

A wrapper around tarfile which is deliberatly limited and simple. The package sequential_tar is meant to ease the writing and reading of tarfiles where the payload of the files within the tarfile is maent to go through the program’s memory. Here, only regular files can be written to a tarfile and blocks different from regular files are ignored while reading. This package is a good start when one plans to use tarfiles as containers for programs to read data from directly into their memory without seeking or the creation of temporary files.

modes

When writing the next file to the tarfile, one can set the mode to choose either text "t" or binary "b". Further a compression can be applied by adding "|gz" to the mode. In the same manner, a mode can be set when reading a file from the tarfile. This way, possible decompression and text/binary conversions can be taken care of with just a few characters in the mode parameter.

import sequential_tar as seqtar
import os
path = "test.tar"

Set the mode for each file while writing to the tarfile.

with seqtar.open(path, "w") as tar:
    tar.write(
        name="1.txt",
        payload="I am text number 1.",
        mode="wt",
    )
    tar.write(
        name="2.txt.gz",
        payload="I am text number 2.",
        mode="wt|gz",
    )
    tar.write(
        name="3.bin.gz",
        payload=b"0123456789",
        mode="wb|gz",
    )
    tar.write(
        name="4.bin",
        payload=b"123-123-123-123-123-123-123",
        mode="wb",
    )

Set the mode for each file while reading from the tarfile.

with seqtar.open(path, "r") as tar:
    item = next(tar)
    assert item.name == "1.txt"
    assert item.read(mode="rt") == "I am text number 1."

    item = next(tar)
    assert item.name == "2.txt.gz"
    assert item.read(mode="rt|gz") == "I am text number 2."

    item = next(tar)
    assert item.name == "3.bin.gz"
    assert item.read(mode="rb|gz") == b"0123456789"

    item = next(tar)
    assert item.name == "4.bin"
    assert item.read(mode="rb") == b"123-123-123-123-123-123-123"

Metadata

Release files for sequential-tar 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sequential-tar 0.0.4
File Size Uploaded
sequential_tar-0.0.4.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sequential-tar 0.0.4
File Interpreter ABI Platform
sequential_tar-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 9.1 kB

Release files / sequential_tar-0.0.4.tar.gz

Download URL sequential_tar-0.0.4.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
53f99cfe7c6790ae850e7db3a0d14def945093d80059809821a4be56276a4e3c
BLAKE2b-256 checksum
How to use checksums
84d12b41419e1c5862c5300b5fd0c2379befa0e422fad581541cd2d9c4db816a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.5

Release files / sequential_tar-0.0.4-py3-none-any.whl

Download URL sequential_tar-0.0.4-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
12f6ee4edf591bb0112c49e23bf4c0c4c1ae829337b2a9b742d5a31ed04afd1f
BLAKE2b-256 checksum
How to use checksums
cd3873da7d67a75170cb6c39cf994a3c2262aa1732e2ab1a02638ebc461a4bf4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.5

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page