Convert bytes to human-readable file sizes and back
Project description
philiprehberger-filesize
Convert bytes to human-readable file sizes and back.
Installation
pip install philiprehberger-filesize
Usage
from philiprehberger_filesize import humanize, parse, is_larger_than
humanize(1536) # "1.5 KB"
humanize(1073741824) # "1.0 GB"
humanize(1024, binary=True) # "1.0 KiB"
parse("1.5 GB") # 1500000000
parse("1 KiB") # 1024
is_larger_than(5000000, "1 MB") # True
API
humanize(size, binary=False, precision=1)— Bytes to human stringformat_bytes(size, binary=False, precision=2)— Alias with precision=2parse(text)— Human string to bytesis_larger_than(size, threshold)— Compare size to human string
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file philiprehberger_filesize-0.1.0.tar.gz.
File metadata
- Download URL: philiprehberger_filesize-0.1.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e4065f2f8d6ca0f42aff2ff0b7cc44c4e42a7251695f28f0049f9654f3d0ea8
|
|
| MD5 |
8a7cc0a63162075a44cb3ce8d5249cc2
|
|
| BLAKE2b-256 |
7329b0b1907fcbceabae1409b798842cec3b040c58d06a59a3188aaa63a63a91
|
File details
Details for the file philiprehberger_filesize-0.1.0-py3-none-any.whl.
File metadata
- Download URL: philiprehberger_filesize-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a85ade86f7c7c016e3e6fc7e2e23953bea1dcb3483d0bc9d58783019134be3ae
|
|
| MD5 |
54099c7e2efd6ef83be388c222785959
|
|
| BLAKE2b-256 |
27c5a703763d665ffa996971a1640a7bf765cd5fb15f2de55c5938e28a7808de
|