A Python project for formatting bytes
Project description
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:
- Clone the repository:
git clone https://github.com/yourusername/byte-formatter.git
- Navigate to the project directory:
cd byte-formatter
- 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file byte_formatter-0.0.2.tar.gz
.
File metadata
- Download URL: byte_formatter-0.0.2.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd89c410412a9528a1ef726412a92133651fd1895b9c1cf0b5b0670c93c41508 |
|
MD5 | f8d8d8be76ccd55a0813a7543679e4ef |
|
BLAKE2b-256 | c0a6926282282abefa8e13a53c68965496573e889cf57826004bab03461842a7 |
File details
Details for the file byte_formatter-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: byte_formatter-0.0.2-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74221d8d9984cf174d16fb7ffbbaefe032376814b6d175683db8630696430f30 |
|
MD5 | a5d48285b711b0a9d2c31b111751a7a5 |
|
BLAKE2b-256 | 8df5c574fed1d4321fa741d0252a411fa773ed4a71c31c23454a16e8fddbc1c5 |