Skip to main content

No project description provided

Project description

Latest Version Supported Python Versions Code style: black Documentation Status https://travis-ci.org/aws/base64io-python.svg?branch=master https://ci.appveyor.com/api/projects/status/ds8xvogp4m70j9ks?svg=true

This project is designed to develop a class, base64io.Base64IO, that implements a streaming interface for Base64 encoding.

Python has supported native Base64 encoding since version 2.4. However, there is no streaming interface for Base64 encoding, and none is available from the community.

The legacy base64.encode and base64.decode interface lets you shuffle data between two streams, but it assumes that you have two complete streams. We wanted a standard stream that applies Base64 encoding and decoding.

base64io.Base64IO provides an io streaming interface with context manager support that transparently Base64-encodes data read from it. You can use it to transform large files without caching the entire context in memory, or to transform an existing stream.

For the latest full documentation, see Read the Docs.

Find us on GitHub.

Getting Started

base64io.Base64IO has no dependencies other than the standard library and should work with any version of Python greater than 2.6. We test it on CPython 2.6, 2.7, 3.3, 3.4, 3.5, 3.6, and 3.7.

Installation

$ pip install base64io

Use

base64io.Base64IO wraps the input stream and transparently encodes or decodes data written to or read from the input stream.

  • write() encodes data before writing it to the wrapped stream

  • read() decodes data after reading it from the wrapped stream

Because the position of the base64io.Base64IO stream and the wrapped stream will almost always be different, base64io.Base64IO does not support:

  • seek()

  • tell()

Also, base64io.Base64IO does not support:

  • fileno()

  • truncate()

Encode data

from base64io import Base64IO

with open("source_file", "rb") as source, open("encoded_file", "wb") as target:
    with Base64IO(target) as encoded_target:
        for line in source:
            encoded_target.write(line)

Decode data

from base64io import Base64IO

with open("encoded_file", "rb") as encoded_source, open("target_file", "wb") as target:
    with Base64IO(encoded_source) as source:
        for line in source:
            target.write(line)

License

This library is licensed under the Apache 2.0 License.

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

base64io-1.0.2.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

base64io-1.0.2-py2.py3-none-any.whl (17.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file base64io-1.0.2.tar.gz.

File metadata

  • Download URL: base64io-1.0.2.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0rc1

File hashes

Hashes for base64io-1.0.2.tar.gz
Algorithm Hash digest
SHA256 a71b95f00c849700d60122a29614ad232efa6883cc40cb57160941d8fa14d71d
MD5 7fd3a7976e2927cdd989e45174f42b2b
BLAKE2b-256 6e85b0bc43f6a2daf864a7ef3a6f4aff5ea535363d6a9082976883e9a77a8391

See more details on using hashes here.

File details

Details for the file base64io-1.0.2-py2.py3-none-any.whl.

File metadata

  • Download URL: base64io-1.0.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0rc1

File hashes

Hashes for base64io-1.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 db5763a67fc6b00f7c04c8f8d8bab3dfeef4cdb0856dc3881e542358b9a55530
MD5 1a8f3d6228144be457f41835f699f7c9
BLAKE2b-256 25eee2c1dea0e2a5cc6c80e018f7010e9a609a458739c2ddd6c41a6a762639c4

See more details on using hashes here.

Supported by

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