Skip to main content

A Python wrapper for the Captioned File (CPTF) file format

Project description

Captioned File

This is a Python wrapper for the CPTN (CaPTioNed file) file format. For more info about the format check https://github.com/Oakchris1955/Captioned-File

Usage

To write bytes:

from cptf import Buffer

# Create a new bytes object
data = Buffer()
data.create_new("Some content...", "Caption 1234") 
# This will change the caption of our data to "Caption 1234" and the content "Some content..."

# Let's get the raw bytes now and write them to "test.cptn"
with open("test.cptn", "wb") as f:
    f.write(data.get_bytes())

To read bytes:

from cptf import Buffer

# Create a new bytes object
data = Buffer()

# Read bytes from file and decode them
with open("test.cptn", "rb") as f:
    # Note: read_from_bytes also outputs a dictionary contaning the caption, the content and the filename. However, it still writes those data to the Buffer object
    
    data.read_from_bytes(f.read()) # The function can take one optional argument, get_header which is a bool. If this is supplied and is True, the result dictionary will also include the caption, filename and content text size in bytes (although you could also use a len())

print(f"Filename: {data.filename}, Caption: {data.caption}, Content: {data.content}")

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

CaptionedFileFormat-1.1.0.post2.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

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

CaptionedFileFormat-1.1.0.post2-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file CaptionedFileFormat-1.1.0.post2.tar.gz.

File metadata

File hashes

Hashes for CaptionedFileFormat-1.1.0.post2.tar.gz
Algorithm Hash digest
SHA256 cec3b7cfb37b908cdee87aa416f71dbff6e9aec99bf654e2026be414bb26a7ce
MD5 8ce40a57f8c983111d8f71fa2357e549
BLAKE2b-256 89f413f687779b68160c14ade5aa65fdd21d7af57727d59de90c02b15140ad45

See more details on using hashes here.

File details

Details for the file CaptionedFileFormat-1.1.0.post2-py3-none-any.whl.

File metadata

File hashes

Hashes for CaptionedFileFormat-1.1.0.post2-py3-none-any.whl
Algorithm Hash digest
SHA256 ea5d09c708aeeb2ef4017c37cc191ad208c50942269c1730230e7336529c61b0
MD5 2bdbff01886feb0fe22b2a4231f02bc9
BLAKE2b-256 8220676d8718f5b45ac07ad29a76a02a5a0a00886269a77283f9b1eb4db4b023

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