{ "info": { "author": "Ofek Lev", "author_email": "ofekmeister@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy" ], "description": "binary\n======\n\n.. image:: https://img.shields.io/pypi/v/binary.svg?style=flat-square\n :target: https://pypi.org/project/binary\n :alt: Latest PyPI version\n\n.. image:: https://img.shields.io/travis/ofek/binary/master.svg?style=flat-square\n :target: https://travis-ci.org/ofek/binary\n :alt: Travis CI\n\n.. image:: https://img.shields.io/appveyor/ci/ofek/binary/master.svg?style=flat-square\n :target: https://ci.appveyor.com/project/ofek/binary\n :alt: AppVeyor CI\n\n.. image:: https://img.shields.io/codecov/c/github/ofek/binary/master.svg?style=flat-square\n :target: https://codecov.io/gh/ofek/binary\n :alt: Codecov\n\n.. image:: https://img.shields.io/pypi/pyversions/binary.svg?style=flat-square\n :target: https://pypi.org/project/binary\n :alt: Supported Python versions\n\n.. image:: https://img.shields.io/pypi/l/binary.svg?style=flat-square\n :target: https://choosealicense.com/licenses\n :alt: License\n\n-----\n\n``binary`` provides a bug-free and easy way to convert between and within\nbinary (`IEC`_) and decimal (`SI`_) units.\n\n.. contents:: **Table of Contents**\n :backlinks: none\n\nInstallation\n------------\n\n``binary`` is distributed on `PyPI `_ as a universal\nwheel and is available on Linux/macOS and Windows and supports\nPython 2.7/3.5+ and PyPy.\n\n.. code-block:: bash\n\n $ pip install binary\n\nExamples\n--------\n\nLet's import what we need:\n\n.. code-block:: python\n\n >>> from binary import BinaryUnits, DecimalUnits, convert_units\n\n**Basic conversion:**\n\n.. code-block:: python\n\n >>> convert_units(1536, BinaryUnits.KB, BinaryUnits.MB)\n (1.5, 'MiB')\n\n**How much actual storage your new hard drive has:**\n\n.. code-block:: python\n\n >>> convert_units(4, DecimalUnits.TB, BinaryUnits.TB)\n (3.637978807091713, 'TiB')\n\n**Human readable:**\n\n.. code-block:: python\n\n >>> amount, unit = convert_units(kubernetes_ingest_bytes_per_second)\n >>> 'Incoming traffic: {:.2f} {}/s'.format(amount, unit)\n 'Incoming traffic: 24.77 GiB/s'\n\nUsage\n-----\n\nJust a single function!\n\n``convert_units(n, unit=BYTE, to=None, si=False, exact=False)``\n\nConverts between and within binary and decimal units. If no ``unit``\nis specified, ``n`` is assumed to already be in bytes. If no ``to`` is\nspecified, ``n`` will be converted to the highest unit possible. If\nno ``unit`` nor ``to`` is specified, the output will be binary units\nunless ``si`` is ``True``. If ``exact`` is ``True``. the calculations\nwill use ``decimal.Decimal``.\n\n| Binary units conform to IEC standards, see:\n| ``_\n| ``_\n| ``_ (paywalled)\n|\n| Decimal units conform to SI standards, see:\n| ``_\n|\n\n* Parameters\n\n - **n** (``int`` or ``float``) - The number of ``unit``\\ s.\n - **unit** - The unit ``n`` represents. See `types`_.\n - **to** - The unit to convert to. See `types`_.\n - **si** (``bool``) - Assume SI units when no ``unit`` nor ``to`` is specified.\n - **exact** (``bool``) - Use ``decimal.Decimal`` for calculations.\n\nTypes\n^^^^^\n\nAlthough the string representations for binary units end in ``iB``,\nthe attributes do not for ease of use.\n\n+--------------+-------+-----------+\n| Type | Short | Long |\n+==============+=======+===========+\n| BinaryUnits | B | BYTE |\n+--------------+-------+-----------+\n| BinaryUnits | KB | KIBIBYTE |\n+--------------+-------+-----------+\n| BinaryUnits | MB | MEBIBYTE |\n+--------------+-------+-----------+\n| BinaryUnits | GB | GIBIBYTE |\n+--------------+-------+-----------+\n| BinaryUnits | TB | TEBIBYTE |\n+--------------+-------+-----------+\n| BinaryUnits | PB | PEBIBYTE |\n+--------------+-------+-----------+\n| BinaryUnits | EB | EXBIBYTE |\n+--------------+-------+-----------+\n| BinaryUnits | ZB | ZEBIBYTE |\n+--------------+-------+-----------+\n| BinaryUnits | YB | YOBIBYTE |\n+--------------+-------+-----------+\n| DecimalUnits | B | BYTE |\n+--------------+-------+-----------+\n| DecimalUnits | KB | KILOBYTE |\n+--------------+-------+-----------+\n| DecimalUnits | MB | MEGABYTE |\n+--------------+-------+-----------+\n| DecimalUnits | GB | GIGABYTE |\n+--------------+-------+-----------+\n| DecimalUnits | TB | TERABYTE |\n+--------------+-------+-----------+\n| DecimalUnits | PB | PETABYTE |\n+--------------+-------+-----------+\n| DecimalUnits | EB | EXABYTE |\n+--------------+-------+-----------+\n| DecimalUnits | ZB | ZETTABYTE |\n+--------------+-------+-----------+\n| DecimalUnits | YB | YOTTABYTE |\n+--------------+-------+-----------+\n\nLicense\n-------\n\n``binary`` is distributed under the terms of both\n\n- `MIT License `_\n- `Apache License, Version 2.0 `_\n\nat your option.\n\n.. _IEC: https://en.wikipedia.org/wiki/Binary_prefix\n.. _SI: https://en.wikipedia.org/wiki/International_System_of_Units\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ofek/binary", "keywords": "", "license": "MIT/Apache-2.0", "maintainer": "", "maintainer_email": "", "name": "binary", "package_url": "https://pypi.org/project/binary/", "platform": "", "project_url": "https://pypi.org/project/binary/", "project_urls": { "Homepage": "https://github.com/ofek/binary" }, "release_url": "https://pypi.org/project/binary/1.0.0/", "requires_dist": null, "requires_python": "", "summary": "", "version": "1.0.0" }, "last_serial": 3548866, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "67b81bd468dcaf0910c1eef47bb6d3cc", "sha256": "2cf0e7a542bef4b27a6c6a3857c79c649759c9caf11dfa39ebbd707c53bfb607" }, "downloads": -1, "filename": "binary-0.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "67b81bd468dcaf0910c1eef47bb6d3cc", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 3357, "upload_time": "2018-01-09T01:55:38", "url": "https://files.pythonhosted.org/packages/42/96/f85da5b6c8f98de9e47fb5d627fa8e51c240db0859a05081168458b03c8c/binary-0.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e0aa3d9a7ee08d879ed29f762167e065", "sha256": "d41c0506fe89feead5e4fd1c2d226f356022113b7f684d912ddd49d883cb8fdd" }, "downloads": -1, "filename": "binary-0.0.1.tar.gz", "has_sig": false, "md5_digest": "e0aa3d9a7ee08d879ed29f762167e065", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6267, "upload_time": "2018-01-09T01:55:39", "url": "https://files.pythonhosted.org/packages/c9/1a/14517fb497ebe02596598b1a5cd13b84d05c3ec285abe48ce3448dd37f98/binary-0.0.1.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "5c2e13ffe1efc0b800044ce290dbeffe", "sha256": "e1b61f3a5c002717d1a28e4d9d2dc8acbc9d6b12baf7b1e4ab25d743da97e323" }, "downloads": -1, "filename": "binary-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "5c2e13ffe1efc0b800044ce290dbeffe", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9203, "upload_time": "2018-02-03T17:37:05", "url": "https://files.pythonhosted.org/packages/b4/ba/37de520e4870635793164a3d6861d98357d4e43aa6ce244327183ccaa3cb/binary-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "930448e9b4a275f53dde8be721b8c7b7", "sha256": "6ec010e58f7331ebc8bc9638dbe6c66d635de60d5818b0723bef4dead0ec28a6" }, "downloads": -1, "filename": "binary-1.0.0.tar.gz", "has_sig": false, "md5_digest": "930448e9b4a275f53dde8be721b8c7b7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10671, "upload_time": "2018-02-03T17:37:07", "url": "https://files.pythonhosted.org/packages/7a/09/403408a5908f0af33f454c3f825c9cbb85ce7c1648594e81925de1d9e0d5/binary-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5c2e13ffe1efc0b800044ce290dbeffe", "sha256": "e1b61f3a5c002717d1a28e4d9d2dc8acbc9d6b12baf7b1e4ab25d743da97e323" }, "downloads": -1, "filename": "binary-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "5c2e13ffe1efc0b800044ce290dbeffe", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9203, "upload_time": "2018-02-03T17:37:05", "url": "https://files.pythonhosted.org/packages/b4/ba/37de520e4870635793164a3d6861d98357d4e43aa6ce244327183ccaa3cb/binary-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "930448e9b4a275f53dde8be721b8c7b7", "sha256": "6ec010e58f7331ebc8bc9638dbe6c66d635de60d5818b0723bef4dead0ec28a6" }, "downloads": -1, "filename": "binary-1.0.0.tar.gz", "has_sig": false, "md5_digest": "930448e9b4a275f53dde8be721b8c7b7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10671, "upload_time": "2018-02-03T17:37:07", "url": "https://files.pythonhosted.org/packages/7a/09/403408a5908f0af33f454c3f825c9cbb85ce7c1648594e81925de1d9e0d5/binary-1.0.0.tar.gz" } ] }