{"id":15672631,"url":"https://github.com/thombashi/humanreadable","last_synced_at":"2025-04-30T15:50:10.947Z","repository":{"id":62569803,"uuid":"175954857","full_name":"thombashi/humanreadable","owner":"thombashi","description":"humanreadable is a Python library to convert human-readable values to other units.","archived":false,"fork":false,"pushed_at":"2023-07-22T15:36:33.000Z","size":195,"stargazers_count":17,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-30T15:49:55.864Z","etag":null,"topics":["converter","human-readable","python-library","text-processing"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thombashi.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-03-16T09:58:46.000Z","updated_at":"2025-02-15T22:40:58.000Z","dependencies_parsed_at":"2022-11-03T17:15:28.299Z","dependency_job_id":null,"html_url":"https://github.com/thombashi/humanreadable","commit_stats":{"total_commits":181,"total_committers":1,"mean_commits":181.0,"dds":0.0,"last_synced_commit":"7b08e95609c98b296a384a6d53dff70a2ed91ae9"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thombashi%2Fhumanreadable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thombashi%2Fhumanreadable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thombashi%2Fhumanreadable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thombashi%2Fhumanreadable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thombashi","download_url":"https://codeload.github.com/thombashi/humanreadable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251734542,"owners_count":21635155,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["converter","human-readable","python-library","text-processing"],"created_at":"2024-10-03T15:29:14.225Z","updated_at":"2025-04-30T15:50:10.916Z","avatar_url":"https://github.com/thombashi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":".. contents:: **humanreadable**\n   :backlinks: top\n   :depth: 2\n\n\nSummary\n============================================\nhumanreadable is a Python library to convert human-readable values to other units.\n\n.. image:: https://badge.fury.io/py/humanreadable.svg\n    :target: https://badge.fury.io/py/humanreadable\n    :alt: PyPI package version\n\n.. image:: https://img.shields.io/pypi/pyversions/humanreadable.svg\n   :target: https://pypi.org/project/humanreadable\n    :alt: Supported Python versions\n\n.. image:: https://img.shields.io/pypi/implementation/humanreadable.svg\n    :target: https://pypi.org/project/humanreadable\n    :alt: Supported Python implementations\n\n.. image:: https://github.com/thombashi/humanreadable/actions/workflows/lint_and_test.yml/badge.svg\n    :target: https://github.com/thombashi/humanreadable/actions/workflows/lint_and_test.yml\n    :alt: CI status of Linux/macOS/Windows\n\n.. image:: https://coveralls.io/repos/github/thombashi/humanreadable/badge.svg?branch=master\n    :target: https://coveralls.io/github/thombashi/humanreadable?branch=master\n    :alt: Test coverage\n\n\nSupported Unites\n-------------------------------------------\n- time (days, hours, minutes, seconds, etc.)\n- bits per second\n\n\nUsage\n============================================\n\nConvert a human-readable value to another unit\n----------------------------------------------\n:Sample Code:\n    .. code-block:: python\n\n        import humanreadable as hr\n\n        print(\"\\n[Examples: humanreadable.Time]\")\n        value = \"120 sec\"\n        print(f\"'{value}' to msecs -\u003e {hr.Time(value).milliseconds}\")\n        print(f\"'{value}' to minutes -\u003e {hr.Time(value).minutes}\")\n\n        value = \"12 min 40 sec\"\n        print(f\"'{value}' to seconds -\u003e {hr.Time(value).seconds}\")\n\n        print(\"\\n[Examples: humanreadable.BitsPerSecond]\")\n        value = \"1 Gbps\"\n        print(f\"'{value}' to Mbps -\u003e {hr.BitsPerSecond(value).mega_bps}\")\n        print(f\"'{value}' to Kbps -\u003e {hr.BitsPerSecond(value).kilo_bps}\")\n        print(f\"'{value}' to Kibps -\u003e {hr.BitsPerSecond(value).kibi_bps}\")\n\n:Output:\n    .. code-block::\n\n        [Examples: humanreadable.Time]\n        '120 sec' to msecs -\u003e 120000.0\n        '120 sec' to minutes -\u003e 2.0\n        '12 minutes 40 seconds' to seconds -\u003e 760.0\n\n        [Examples: humanreadable.BitsPerSecond]\n        '1 Gbps' to Mbps -\u003e 1000.0\n        '1 Gbps' to Kbps -\u003e 1000000.0\n        '1 Gbps' to Kibps -\u003e 976562.5\n\n\nConvert a value to a human readable string\n----------------------------------------------\n:Sample Code:\n    .. code-block:: python\n\n        import humanreadable as hr\n\n        t = hr.Time(\"400\", default_unit=hr.Time.Unit.SECOND)\n        print(t.to_humanreadable())\n        print(t.to_humanreadable(style=\"short\"))\n\n:Output:\n    .. code-block::\n\n        6 minutes 40 seconds\n        6m 40s\n\nSet default unit\n-------------------------------------------\nUnit for an instance is determined by input value.\nIf a valid unit is not found, ``default_unit`` will be used for the instance (defaults to ``None``).\n\n:Sample Code:\n    .. code-block:: python\n\n        import humanreadable as hr\n\n        print(hr.Time(\"1\", default_unit=hr.Time.Unit.SECOND))\n\n:Output:\n    .. code-block::\n\n        1.0 seconds\n\n\nUnits\n-------------------------------------------\n.. table:: Available units for ``humanreadable.Time``\n\n    +--------------+------------------------------------------------------------+\n    |     Unit     |              Available unit specifiers (str)               |\n    +==============+============================================================+\n    | days         | ``d``/``day``/``days``                                     |\n    +--------------+------------------------------------------------------------+\n    | hours        | ``h``/``hour``/``hours``                                   |\n    +--------------+------------------------------------------------------------+\n    | minutes      | ``m``/``min``/``mins``/``minute``/``minutes``              |\n    +--------------+------------------------------------------------------------+\n    | seconds      | ``s``/``sec``/``secs``/``second``/``seconds``              |\n    +--------------+------------------------------------------------------------+\n    | milliseconds | ``ms``/``msec``/``msecs``/``millisecond``/``milliseconds`` |\n    +--------------+------------------------------------------------------------+\n    | microseconds | ``us``/``usec``/``usecs``/``microsecond``/``microseconds`` |\n    +--------------+------------------------------------------------------------+\n\n.. table:: Available units for ``humanreadable.BitsPerSecond``\n\n    +-------+--------------------------------------------------------+\n    | Unit  |            Available unit specifiers (str)             |\n    +=======+========================================================+\n    | Kbps  | ``[kK]bps``/``[kK]bits?(/|\\s?per\\s?)(s|sec|second)``   |\n    +-------+--------------------------------------------------------+\n    | Kibps | ``[kK]ibps``/``[kK]ibits?(/|\\s?per\\s?)(s|sec|second)`` |\n    +-------+--------------------------------------------------------+\n    | Mbps  | ``[mM]bps``/``[mM]bits?(/|\\s?per\\s?)(s|sec|second)``   |\n    +-------+--------------------------------------------------------+\n    | Mibps | ``[mM]ibps``/``[mM]ibits?(/|\\s?per\\s?)(s|sec|second)`` |\n    +-------+--------------------------------------------------------+\n    | Gbps  | ``[gG]bps``/``[gG]bits?(/|\\s?per\\s?)(s|sec|second)``   |\n    +-------+--------------------------------------------------------+\n    | Gibps | ``[gG]ibps``/``[gG]ibits?(/|\\s?per\\s?)(s|sec|second)`` |\n    +-------+--------------------------------------------------------+\n    | Tbps  | ``[tT]bps``/``[tT]bits?(/|\\s?per\\s?)(s|sec|second)``   |\n    +-------+--------------------------------------------------------+\n    | Tibps | ``[tT]ibps``/``[tT]ibits?(/|\\s?per\\s?)(s|sec|second)`` |\n    +-------+--------------------------------------------------------+\n    | bps   | ``bps``/``bits?(/|\\s?per\\s?)(s|sec|second)``           |\n    +-------+--------------------------------------------------------+\n\n\nInstallation\n============================================\nInstallation: pip\n------------------------------\n::\n\n    pip install humanreadable\n\nInstallation: apt (for Ubuntu)\n------------------------------\n::\n\n    sudo add-apt-repository ppa:thombashi/ppa\n    sudo apt update\n    sudo apt install python3-humanreadable\n\n\nDependencies\n============================================\n- Python 3.7+\n- `Python package dependencies (automatically installed) \u003chttps://github.com/thombashi/humanreadable/network/dependencies\u003e`__\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthombashi%2Fhumanreadable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthombashi%2Fhumanreadable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthombashi%2Fhumanreadable/lists"}