humanreadable is a Python library to convert from human-readable values to Python values.
Project description
Summary
humanreadable is a Python library to convert from human-readable values to other units.
Supported Unites
time (days, hours, minutes, seconds, etc.)
bit per seconds
Usage
Basic usages
- Sample Code:
import humanreadable as hr print("\n[Examples: humanreadable.Time]") value = "120 sec" print("'{}' to msecs -> {}".format(value, hr.Time(value).milliseconds)) print("'{}' to minutes -> {}".format(value, hr.Time(value).minutes)) print("\n[Examples: humanreadable.BitPerSecond]") value = "1 Gbps" print("'{}' to Mbps -> {}".format(value, hr.BitPerSecond(value).mega_bps)) print("'{}' to Kbps -> {}".format(value, hr.BitPerSecond(value).kilo_bps)) print("'{}' to Kibps -> {}".format(value, hr.BitPerSecond(value).kibi_bps))- Output:
[Examples: humanreadable.Time] '120 sec' to msecs -> 120000.0 '120 sec' to minutes -> 2.0 [Examples: humanreadable.BitPerSecond] '1 Gbps' to Mbps -> 1000.0 '1 Gbps' to Kbps -> 1000000.0 '1 Gbps' to Kibps -> 953674.31640625
Set default unit
Unit for an instance is determined by input value. If a valid unit not found, default_unit will be used for the instance (defaults to None).
- Sample Code:
import humanreadable as hr print(hr.Time("1", default_unit=hr.Time.Unit.SECOND))- Output:
1.0 seconds
Units
Unit |
Available specifiers (str) |
|---|---|
days |
d/day/days |
hours |
h/hour/hours |
minutes |
m/min/mins/minute/minutes |
seconds |
s/sec/secs/second/seconds |
milliseconds |
ms/msec/msecs/millisecond/milliseconds |
microseconds |
us/usec/usecs/microsecond/microseconds |
Unit |
Available specifiers (str) |
|---|---|
bps |
bps/bit/s |
Kbps |
[kK]bps/[kK]bit/s |
Kibps |
[kK]ibps/[kK]ibit/s |
Mbps |
[mM]bps/[mM]bit/s |
Mibps |
[mM]ibps/[mM]ibit/s |
Gbps |
[gG]bps/[gG]bit/s |
Gibps |
[gG]ibps/[gG]ibit/s |
Tbps |
[tT]bps/[tT]bit/s |
Tibps |
[tT]ibps/[tT]ibit/s |
Installation
Installation: pip
pip install humanreadable
Installation: apt (for Ubuntu)
sudo add-apt-repository ppa:thombashi/ppa sudo apt update sudo apt install python3-humanreadable
Dependencies
Python 2.7+ or 3.5+
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
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 humanreadable-0.0.9.tar.gz.
File metadata
- Download URL: humanreadable-0.0.9.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3504cfd55265660d09e0f527570296f6bf7924a78f97e46e920c9566968c290d
|
|
| MD5 |
5f96b13903e769b8e166837fbc4c40f0
|
|
| BLAKE2b-256 |
4b12302bd2bb8acb824caf342f4cc89ee3be93bb7d402f013f1ae74f4c804c0f
|
File details
Details for the file humanreadable-0.0.9-py2.py3-none-any.whl.
File metadata
- Download URL: humanreadable-0.0.9-py2.py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51780390df8a1a158a12c0e6814d2e99395a58947a21cd4a61e1302440820bcc
|
|
| MD5 |
947334b4720ae2fee2ff69c0f3c1ca63
|
|
| BLAKE2b-256 |
dd4a5a98ffe14f91f4475be7fa40147fe580528a8a4ab6cad757f45ba442923d
|