<commit_before>.. image:: https://api.travis-ci.org/tbielawa/bitmath.png
   :target: https://travis-ci.org/tbielawa/bitmath/
   :align: right
   :height: 19
   :width: 77

.. image:: https://coveralls.io/repos/tbielawa/bitmath/badge.png?branch=master
   :target: https://coveralls.io/r/tbielawa/bitmath?branch=master
   :align: right
   :height: 19
   :width: 77

.. image:: https://readthedocs.org/projects/bitmath/badge/?version=latest
   :target: http://bitmath.rtfd.org/
   :align: right
   :height: 19
   :width: 77


bitmath
=======

`bitmath <http://bitmath.readthedocs.org/en/latest/>`_ simplifies many
facets of interacting with file sizes in various units. Originally
focusing on file size unit conversion, functionality now includes:

* Converting between **SI** and **NIST** prefix units (``kB`` to ``GiB``)
* Converting between units of the same type (SI to SI, or NIST to NIST)
* Automatic human-readable prefix selection (like in `hurry.filesize <https://pypi.python.org/pypi/hurry.filesize>`_)
* Basic arithmetic operations (subtracting 42KiB from 50GiB)
* Rich comparison operations (``1024 Bytes == 1KiB``)
* bitwise operations (``<<``, ``>>``, ``&``, ``|``, ``^``)
* Reading a device's storage capacity (Linux/OS X support only)
* `argparse <https://docs.python.org/2/library/argparse.html>`_
  integration as a custom type
* `click <https://click.palletsprojects.com/>`_
  integration as a custom parameter type
* `progressbar <https://code.google.com/p/python-progressbar/>`_
  integration as a better file transfer speed widget
* String parsing
* Sorting


In addition to the conversion and math operations, `bitmath` provides
human readable representations of values which are suitable for use in
interactive shells as well as larger scripts and applications. The
format produced for these representations is customizable via the
functionality included in stdlibs `string.format
<https://docs.python.org/2/library/string.html>`_.

In discussion we will refer to the NIST units primarily. I.e., instead
of "megabyte" we will refer to "mebibyte". The former is ``10^3 =
1,000,000`` bytes, whereas the second is ``2^20 = 1,048,576``
bytes. When you see file sizes or transfer rates in your web browser,
most of the time what you're really seeing are the base-2 sizes/rates.

**Don't Forget!** The source for bitmath `is available on GitHub
<https://github.com/tbielawa/bitmath>`_.

And did we mention there's almost 200 unittests? `Check them out for
yourself <https://github.com/tbielawa/bitmath/tree/master/tests>`_.


Installation
============

The easiest way to install bitmath is via ``dnf`` (or ``yum``) if
you're on a Fedora/RHEL based distribution. bitmath is available in
the main Fedora repositories, as well as the `EPEL6
<http://download.fedoraproject.org/pub/epel/6/i386/repoview/epel-release.html>`_
and `EPEL7
<http://download.fedoraproject.org/pub/epel/7/x86_64/repoview/epel-release.html>`_
repositories. There are now dual python2.x and python3.x releases
available.<commit_msg>Make it clearer how to run the tests from the README<commit_after>.. image:: https://api.travis-ci.org/tbielawa/bitmath.png
   :target: https://travis-ci.org/tbielawa/bitmath/
   :align: right
   :height: 19
   :width: 77

.. image:: https://coveralls.io/repos/tbielawa/bitmath/badge.png?branch=master
   :target: https://coveralls.io/r/tbielawa/bitmath?branch=master
   :align: right
   :height: 19
   :width: 77

.. image:: https://readthedocs.org/projects/bitmath/badge/?version=latest
   :target: http://bitmath.rtfd.org/
   :align: right
   :height: 19
   :width: 77


bitmath
=======

`bitmath <http://bitmath.readthedocs.org/en/latest/>`_ simplifies many
facets of interacting with file sizes in various units. Originally
focusing on file size unit conversion, functionality now includes:

* Converting between **SI** and **NIST** prefix units (``kB`` to ``GiB``)
* Converting between units of the same type (SI to SI, or NIST to NIST)
* Automatic human-readable prefix selection (like in `hurry.filesize <https://pypi.python.org/pypi/hurry.filesize>`_)
* Basic arithmetic operations (subtracting 42KiB from 50GiB)
* Rich comparison operations (``1024 Bytes == 1KiB``)
* bitwise operations (``<<``, ``>>``, ``&``, ``|``, ``^``)
* Reading a device's storage capacity (Linux/OS X support only)
* `argparse <https://docs.python.org/2/library/argparse.html>`_
  integration as a custom type
* `click <https://click.palletsprojects.com/>`_
  integration as a custom parameter type
* `progressbar <https://code.google.com/p/python-progressbar/>`_
  integration as a better file transfer speed widget
* String parsing
* Sorting


In addition to the conversion and math operations, `bitmath` provides
human readable representations of values which are suitable for use in
interactive shells as well as larger scripts and applications. The
format produced for these representations is customizable via the
functionality included in stdlibs `string.format
<https://docs.python.org/2/library/string.html>`_.

In discussion we will refer to the NIST units primarily. I.e., instead
of "megabyte" we will refer to "mebibyte". The former is ``10^3 =
1,000,000`` bytes, whereas the second is ``2^20 = 1,048,576``
bytes. When you see file sizes or transfer rates in your web browser,
most of the time what you're really seeing are the base-2 sizes/rates.

**Don't Forget!** The source for bitmath `is available on GitHub
<https://github.com/tbielawa/bitmath>`_.

And did we mention there's almost 200 unittests? `Check them out for
yourself <https://github.com/tbielawa/bitmath/tree/master/tests>`_.

Running the tests should be as simple as calling the ``ci-all`` target
in the Makefile: ``make ci-all``.




Installation
============

The easiest way to install bitmath is via ``dnf`` (or ``yum``) if
you're on a Fedora/RHEL based distribution. bitmath is available in
the main Fedora repositories, as well as the `EPEL6
<http://download.fedoraproject.org/pub/epel/6/i386/repoview/epel-release.html>`_
and `EPEL7
<http://download.fedoraproject.org/pub/epel/7/x86_64/repoview/epel-release.html>`_
repositories. There are now dual python2.x and python3.x releases
available.
{'fraction_non_alphanumeric': 0.12942889500080892, 'fraction_numerical': 0.01941433425012134, 'mean_word_length': 4.539426523297491, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 24, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2578244', 'n_tokens_mistral': 2107, 'n_tokens_neox': 1929, 'n_words': 650}