Skip to main content

Byte-Formatter

Byte-Formatter is a Python project for formatting bytes into a human-readable format. It supports various units and styles, including binary, decimal, SI units, and Unix-style units.

Table of Contents

Installation

To install Byte-Formatter, you need to have Python 3.7 or higher and Poetry installed on your system. Follow these steps:

  1. Clone the repository:
    git clone https://github.com/yourusername/byte-formatter.git
    
  2. Navigate to the project directory:
    cd byte-formatter
    
  3. Install the dependencies using Poetry:
    poetry install
    

Usage

Local Usage

To use Byte-Formatter locally, you can run it through Poetry:

# Output: 12.3 KB
poetry run byte-formatter 12345

This command will format the number 12345 into a human-readable byte format based on the default settings.

Basic Usage

To format a number into a human-readable byte format with default settings (decimal units and one decimal place):

# Output: 12.3 KB
byte-formatter 12345

Advanced Options

You can customize the output using the following options:

  • -b, --binary: Use binary (base-1024) units (KiB, MiB, etc.).
  • -p, --precision <number>: Set the number of decimal places.
  • -s, --suffix <text>: Append a custom suffix to the formatted size.
  • -t, --strip-trailing-zeros: Remove trailing zeros from the formatted size.
  • -S, --si-units: Use SI units (kB, MB, etc.) which are base-1000 but with different symbols.
  • -U, --uppercase-units: Use uppercase unit symbols (KB, MB). This is the default setting.
  • -l, --lowercase-units: Use lowercase unit symbols (kb, mb), overriding the default uppercase setting.
  • -v, --verbose: Use verbose unit names (Bytes, Kilobytes, etc.).
  • -x, --unix-style: Use single-letter Unix-style unit names (B, K, M, G, T, P).

Examples

Format a size using binary units with two decimal places:

# Output: 12.06 KiB
poetry run byte-formatter 12345 -b -p 2

Format a size with verbose unit names and no trailing zeros:

# Output: 2.0 Kilobytes
poetry run byte-formatter 2048 -v -t

Use SI units with lowercase symbols and a custom suffix:

# Output: 5.0 MB of data
poetry run byte-formatter 5000000 -S -l -s " of data"

Features

Byte-Formatter offers the following features:

  • Support for binary (base-1024) and decimal (base-1000) units.
  • Option to use SI units with different symbols.
  • Verbose and Unix-style unit names.
  • Customizable precision and option to strip trailing zeros.

License

Byte-Formatter is licensed under the MIT License. See the LICENSE file for more details.

Metadata

Release files for byte-formatter 0.0.2

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

Source distribution (sdist)

Source distribution for byte-formatter 0.0.2
File Size Uploaded Provenance Actions
byte_formatter-0.0.2.tar.gz 5.2 kB Without provenance Details for byte_formatter-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for byte-formatter 0.0.2
File Interpreter ABI Platform Actions
byte_formatter-0.0.2-py3-none-any.whl Python 3 none any Details for byte_formatter-0.0.2-py3-none-any.whl

Total release size: 11.9 kB

Release files / byte_formatter-0.0.2.tar.gz

Download URL byte_formatter-0.0.2.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
cd89c410412a9528a1ef726412a92133651fd1895b9c1cf0b5b0670c93c41508
BLAKE2b-256 checksum
How to use checksums
c0a6926282282abefa8e13a53c68965496573e889cf57826004bab03461842a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Darwin/23.5.0

Release files / byte_formatter-0.0.2-py3-none-any.whl

Download URL byte_formatter-0.0.2-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
74221d8d9984cf174d16fb7ffbbaefe032376814b6d175683db8630696430f30
BLAKE2b-256 checksum
How to use checksums
8df5c574fed1d4321fa741d0252a411fa773ed4a71c31c23454a16e8fddbc1c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Darwin/23.5.0

Security for byte-formatter 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

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