Skip to main content

almighty

English | 中文

把字节数、大数字和比例格式化成一眼能读的量级。

安装

pip install almighty

用法

from almighty import human_count, human_ratio, human_size

human_size(0)              # '0 B'
human_size(1536)           # '1.5 KB'
human_size(1500, n_base=1000)   # '1.5 KB'
human_count(1_200_000)     # '1.2M'
human_ratio(1, 3)          # '33.3%'
human_ratio(1, 0)          # 'n/a'

说明

human_size 默认 1024 进制,传 n_base=1000 切十进制;human_ratio 分母为 0 时返回 n/a 而不抛错——报表需要一个可展示的值。

许可证

MIT


English

Human readable formatting for byte sizes, counts and ratios.

Install

pip install almighty

Usage

from almighty import human_count, human_ratio, human_size

human_size(0)              # '0 B'
human_size(1536)           # '1.5 KB'
human_size(1500, n_base=1000)   # '1.5 KB'
human_count(1_200_000)     # '1.2M'
human_ratio(1, 3)          # '33.3%'
human_ratio(1, 0)          # 'n/a'

Notes

Binary units by default; n_base=1000 switches to decimal. human_ratio returns n/a instead of raising on a zero total, because that is what a report needs to show.

License

MIT

Metadata

Release files for almighty 0.0.4

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

Source distribution (sdist)

Source distribution for almighty 0.0.4
File Size Uploaded Provenance Actions
almighty-0.0.4.tar.gz 3.0 kB Without provenance Details for almighty-0.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for almighty 0.0.4
File Interpreter ABI Platform Actions
almighty-0.0.4-py3-none-any.whl Python 3 none any Details for almighty-0.0.4-py3-none-any.whl

Total release size: 6.5 kB

Release files / almighty-0.0.4.tar.gz

Download URL almighty-0.0.4.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c2e2e2b2a39d1d2f04a9d73ef05b7d0dea5365f2a9929c4901b3233cb7f758fb
BLAKE2b-256 checksum
How to use checksums
530cde4ecfecbad6b3363ee0d9da0655b29cdcf0eb06d9ca2d62c8687fd660de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Release files / almighty-0.0.4-py3-none-any.whl

Download URL almighty-0.0.4-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b43c340be4b97056f73314ba9619c46445413dc2136dad249dbb95702fbb09b
BLAKE2b-256 checksum
How to use checksums
fbbe37f5599900ecbe9320a8f30c3008521dd535c9284f7a2d18a50cccc5ed21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Security for almighty 0.0.4

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.

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