calmsize
NOTICE
I forked the repo from source file downloaded from pip hurry.filesize.
That simple library is very useful when debugging memory issues, but
unfortunately out-of-maintainance since 2009, so I decided to fork
the great work of Martijn Faassen, Startifact.
Intro
calmsize a simple Python library that can take a number of bytes and returns a human-readable string with the size in it, in kilobytes (K), megabytes (M), etc.
The default system it uses is "traditional", where multipliers of 1024 increase the unit size::
>>> from calmsize import size, ByteSize
>>> size(1024)
'1K'
>>> size(-1024)
'-1K'
>>> '{:.2f}'.format(size(-1024))
'-1.00K'
An alternative, slightly more verbose system::
>>> from calmsize import alternative
>>> size(1, system=alternative)
'1 byte'
>>> size(10, system=alternative)
'10 bytes'
>>> size(1024, system=alternative)
'1 KB'
A verbose system::
>>> from calmsize import verbose
>>> size(10, system=verbose)
'10 bytes'
>>> size(1024, system=verbose)
'1 kilobyte'
>>> size(2000, system=verbose)
'1 kilobyte'
>>> size(3000, system=verbose)
'2 kilobytes'
>>> size(1024 * 1024, system=verbose)
'1 megabyte'
>>> size(1024 * 1024 * 3, system=verbose)
'3 megabytes'
You can also use the SI system, where multipliers of 1000 increase the unit size::
>>> from calmsize import si
>>> size(1000, system=si)
'1K'
Changes
0.1.2 (2019-05-27)
- Fix pip install fail of python2.7
0.1.1 (2019-05-25)
- Fix pip install filenotfound error
0.1.0 (2019-05-24)
- Add support for negative input
- Add support for format the leading number
- Add ByteSize as a new class
- Add support for comparing between two Bytesize, ByteSize and numbers
0.0.1 (2019-05-24)
- Forked from hurry.filesize
Download
Metadata
Release files for calmsize 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| calmsize-0.1.3.tar.gz | 3.7 kB | Without provenance | Details for calmsize-0.1.3.tar.gz |
Release files / calmsize-0.1.3.tar.gz
| Download URL | calmsize-0.1.3.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e1f1233228ae6b7fafc8c23e52129c7ca58fee6bcf7875ae152eee5123ba122d
|
|
BLAKE2b-256 checksum How to use checksums |
da69382ee4e1553f15321dd76109325f6a186a79354c53e8ac97cf79a2ebddbe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.15
|
Security for calmsize 0.1.3
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.