[Python-modules-commits] [humanfriendly] 01/17: New upstream version 2.3.2

Gaurav Juvekar gauravjuvekar-guest at moszumanska.debian.org
Sun Mar 12 19:58:49 UTC 2017


This is an automated email from the git hooks/post-receive script.

gauravjuvekar-guest pushed a commit to branch master
in repository humanfriendly.

commit 717a8b7a1e8712c0e9089041b2ddd14aa353a6c4
Author: Gaurav Juvekar <gauravjuvekar at gmail.com>
Date:   Thu Jan 19 06:48:01 2017 +0100

    New upstream version 2.3.2
---
 LICENSE.txt                                 |  20 +
 MANIFEST.in                                 |   2 +
 PKG-INFO                                    | 182 ++++++
 README.rst                                  | 146 +++++
 humanfriendly.egg-info/PKG-INFO             | 182 ++++++
 humanfriendly.egg-info/SOURCES.txt          |  23 +
 humanfriendly.egg-info/dependency_links.txt |   1 +
 humanfriendly.egg-info/entry_points.txt     |   3 +
 humanfriendly.egg-info/requires.txt         |   6 +
 humanfriendly.egg-info/top_level.txt        |   1 +
 humanfriendly/__init__.py                   | 974 +++++++++++++++++++++++++++
 humanfriendly/cli.py                        | 189 ++++++
 humanfriendly/compat.py                     | 105 +++
 humanfriendly/prompts.py                    | 349 ++++++++++
 humanfriendly/sphinx.py                     | 143 ++++
 humanfriendly/tables.py                     | 276 ++++++++
 humanfriendly/terminal.py                   | 484 ++++++++++++++
 humanfriendly/tests.py                      | 976 ++++++++++++++++++++++++++++
 humanfriendly/text.py                       | 333 ++++++++++
 humanfriendly/usage.py                      | 351 ++++++++++
 requirements-checks.txt                     |   4 +
 requirements-testing.txt                    |   4 +
 setup.cfg                                   |   8 +
 setup.py                                    | 144 ++++
 24 files changed, 4906 insertions(+)

diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..71c0236
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,20 @@
+Copyright (c) 2017 Peter Odding
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..f218bf2
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,2 @@
+include *.rst
+include *.txt
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..97552fb
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,182 @@
+Metadata-Version: 1.1
+Name: humanfriendly
+Version: 2.3.2
+Summary: Human friendly output for text interfaces using Python
+Home-page: https://humanfriendly.readthedocs.io
+Author: Peter Odding
+Author-email: peter at peterodding.com
+License: UNKNOWN
+Description: humanfriendly: Human friendly input/output in Python
+        ====================================================
+        
+        .. image:: https://travis-ci.org/xolox/python-humanfriendly.svg?branch=master
+           :target: https://travis-ci.org/xolox/python-humanfriendly
+        
+        .. image:: https://coveralls.io/repos/xolox/python-humanfriendly/badge.png?branch=master
+           :target: https://coveralls.io/r/xolox/python-humanfriendly?branch=master
+        
+        The functions and classes in the `humanfriendly` package can be used to make
+        text interfaces more user friendly. Some example features:
+        
+        - Parsing and formatting numbers, file sizes, pathnames and timespans in
+          simple, human friendly formats.
+        
+        - Easy to use timers for long running operations, with human friendly
+          formatting of the resulting timespans.
+        
+        - Prompting the user to select a choice from a list of options by typing the
+          option's number or a unique substring of the option.
+        
+        - Terminal interaction including text styling (ANSI escape sequences), user
+          friendly rendering of usage messages and querying the terminal for its
+          size.
+        
+        The `humanfriendly` package is currently tested on Python 2.6, 2.7, 3.4, 3.5
+        and PyPy.
+        
+        .. contents::
+           :local:
+        
+        Getting started
+        ---------------
+        
+        It's very simple to start using the `humanfriendly` package::
+        
+           >>> import humanfriendly
+           >>> user_input = raw_input("Enter a readable file size: ")
+           Enter a readable file size: 16G
+           >>> num_bytes = humanfriendly.parse_size(user_input)
+           >>> print num_bytes
+           16000000000
+           >>> print "You entered:", humanfriendly.format_size(num_bytes)
+           You entered: 16 GB
+           >>> print "You entered:", humanfriendly.format_size(num_bytes, binary=True)
+           You entered: 14.9 GiB
+        
+        Command line
+        ------------
+        
+        .. A DRY solution to avoid duplication of the `humanfriendly --help' text:
+        ..
+        .. [[[cog
+        .. from humanfriendly.usage import inject_usage
+        .. inject_usage('humanfriendly.cli')
+        .. ]]]
+        
+        **Usage:** `humanfriendly [OPTIONS]`
+        
+        Human friendly input/output (text formatting) on the command line based on the Python package with the same name.
+        
+        **Supported options:**
+        
+        .. csv-table::
+           :header: Option, Description
+           :widths: 30, 70
+        
+        
+           "``-c``, ``--run-command``","Execute an external command (given as the positional arguments) and render
+           a spinner and timer while the command is running. The exit status of the
+           command is propagated."
+           ``--format-table``,"Read tabular data from standard input (each line is a row and each
+           whitespace separated field is a column), format the data as a table and
+           print the resulting table to standard output. See also the ``--delimiter``
+           option."
+           "``-d``, ``--delimiter=VALUE``","Change the delimiter used by ``--format-table`` to ``VALUE`` (a string). By default
+           all whitespace is treated as a delimiter."
+           "``-l``, ``--format-length=LENGTH``","Convert a length count (given as the integer or float ``LENGTH``) into a human
+           readable string and print that string to standard output."
+           "``-n``, ``--format-number=VALUE``","Format a number (given as the integer or floating point number ``VALUE``) with
+           thousands separators and two decimal places (if needed) and print the
+           formatted number to standard output."
+           "``-s``, ``--format-size=BYTES``","Convert a byte count (given as the integer ``BYTES``) into a human readable
+           string and print that string to standard output."
+           "``-t``, ``--format-timespan=SECONDS``","Convert a number of seconds (given as the floating point number ``SECONDS``)
+           into a human readable timespan and print that string to standard output."
+           ``--parse-size=VALUE``,"Parse a human readable data size (given as the string ``VALUE``) and print the
+           number of bytes to standard output."
+           ``--parse-length=VALUE``,"Parse a human readable length (given as the string ``VALUE``) and print the
+           number of metres to standard output."
+           "``-h``, ``--help``","Show this message and exit.
+           "
+        
+        .. [[[end]]]
+        
+        A note about size units
+        -----------------------
+        
+        When I originally published the `humanfriendly` package I went with binary
+        multiples of bytes (powers of two). It was pointed out several times that this
+        was a poor choice (see issue `#4`_ and pull requests `#8`_ and `#9`_) and thus
+        the new default became decimal multiples of bytes (powers of ten):
+        
+        +------+---------------+---------------+
+        | Unit | Binary value  | Decimal value |
+        +------+---------------+---------------+
+        | KB   |          1024 |          1000 +
+        +------+---------------+---------------+
+        | MB   |       1048576 |       1000000 |
+        +------+---------------+---------------+
+        | GB   |    1073741824 |    1000000000 |
+        +------+---------------+---------------+
+        | TB   | 1099511627776 | 1000000000000 |
+        +------+---------------+---------------+
+        | etc  |               |               |
+        +------+---------------+---------------+
+        
+        The option to use binary multiples of bytes remains by passing the keyword
+        argument `binary=True` to the `format_size()`_ and `parse_size()`_ functions.
+        
+        Contact
+        -------
+        
+        The latest version of `humanfriendly` is available on PyPI_ and GitHub_. The
+        documentation is hosted on `Read the Docs`_. For bug reports please create an
+        issue on GitHub_. If you have questions, suggestions, etc. feel free to send me
+        an e-mail at `peter at peterodding.com`_.
+        
+        License
+        -------
+        
+        This software is licensed under the `MIT license`_.
+        
+        © 2017 Peter Odding.
+        
+        .. External references:
+        .. _#4: https://github.com/xolox/python-humanfriendly/issues/4
+        .. _#8: https://github.com/xolox/python-humanfriendly/pull/8
+        .. _#9: https://github.com/xolox/python-humanfriendly/pull/9
+        .. _format_size(): https://humanfriendly.readthedocs.io/en/latest/#humanfriendly.format_size
+        .. _GitHub: https://github.com/xolox/python-humanfriendly
+        .. _MIT license: http://en.wikipedia.org/wiki/MIT_License
+        .. _parse_size(): https://humanfriendly.readthedocs.io/en/latest/#humanfriendly.parse_size
+        .. _peter at peterodding.com: peter at peterodding.com
+        .. _PyPI: https://pypi.python.org/pypi/humanfriendly
+        .. _Read the Docs: https://humanfriendly.readthedocs.io
+        
+Platform: UNKNOWN
+Classifier: Development Status :: 6 - Mature
+Classifier: Environment :: Console
+Classifier: Framework :: Sphinx :: Extension
+Classifier: Intended Audience :: Developers
+Classifier: Intended Audience :: System Administrators
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Natural Language :: English
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Topic :: Communications
+Classifier: Topic :: Scientific/Engineering :: Human Machine Interfaces
+Classifier: Topic :: Software Development
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Classifier: Topic :: Software Development :: User Interfaces
+Classifier: Topic :: System :: Shells
+Classifier: Topic :: System :: System Shells
+Classifier: Topic :: System :: Systems Administration
+Classifier: Topic :: Terminals
+Classifier: Topic :: Text Processing :: General
+Classifier: Topic :: Text Processing :: Linguistic
+Classifier: Topic :: Utilities
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..b8dbdb1
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,146 @@
+humanfriendly: Human friendly input/output in Python
+====================================================
+
+.. image:: https://travis-ci.org/xolox/python-humanfriendly.svg?branch=master
+   :target: https://travis-ci.org/xolox/python-humanfriendly
+
+.. image:: https://coveralls.io/repos/xolox/python-humanfriendly/badge.png?branch=master
+   :target: https://coveralls.io/r/xolox/python-humanfriendly?branch=master
+
+The functions and classes in the `humanfriendly` package can be used to make
+text interfaces more user friendly. Some example features:
+
+- Parsing and formatting numbers, file sizes, pathnames and timespans in
+  simple, human friendly formats.
+
+- Easy to use timers for long running operations, with human friendly
+  formatting of the resulting timespans.
+
+- Prompting the user to select a choice from a list of options by typing the
+  option's number or a unique substring of the option.
+
+- Terminal interaction including text styling (ANSI escape sequences), user
+  friendly rendering of usage messages and querying the terminal for its
+  size.
+
+The `humanfriendly` package is currently tested on Python 2.6, 2.7, 3.4, 3.5
+and PyPy.
+
+.. contents::
+   :local:
+
+Getting started
+---------------
+
+It's very simple to start using the `humanfriendly` package::
+
+   >>> import humanfriendly
+   >>> user_input = raw_input("Enter a readable file size: ")
+   Enter a readable file size: 16G
+   >>> num_bytes = humanfriendly.parse_size(user_input)
+   >>> print num_bytes
+   16000000000
+   >>> print "You entered:", humanfriendly.format_size(num_bytes)
+   You entered: 16 GB
+   >>> print "You entered:", humanfriendly.format_size(num_bytes, binary=True)
+   You entered: 14.9 GiB
+
+Command line
+------------
+
+.. A DRY solution to avoid duplication of the `humanfriendly --help' text:
+..
+.. [[[cog
+.. from humanfriendly.usage import inject_usage
+.. inject_usage('humanfriendly.cli')
+.. ]]]
+
+**Usage:** `humanfriendly [OPTIONS]`
+
+Human friendly input/output (text formatting) on the command line based on the Python package with the same name.
+
+**Supported options:**
+
+.. csv-table::
+   :header: Option, Description
+   :widths: 30, 70
+
+
+   "``-c``, ``--run-command``","Execute an external command (given as the positional arguments) and render
+   a spinner and timer while the command is running. The exit status of the
+   command is propagated."
+   ``--format-table``,"Read tabular data from standard input (each line is a row and each
+   whitespace separated field is a column), format the data as a table and
+   print the resulting table to standard output. See also the ``--delimiter``
+   option."
+   "``-d``, ``--delimiter=VALUE``","Change the delimiter used by ``--format-table`` to ``VALUE`` (a string). By default
+   all whitespace is treated as a delimiter."
+   "``-l``, ``--format-length=LENGTH``","Convert a length count (given as the integer or float ``LENGTH``) into a human
+   readable string and print that string to standard output."
+   "``-n``, ``--format-number=VALUE``","Format a number (given as the integer or floating point number ``VALUE``) with
+   thousands separators and two decimal places (if needed) and print the
+   formatted number to standard output."
+   "``-s``, ``--format-size=BYTES``","Convert a byte count (given as the integer ``BYTES``) into a human readable
+   string and print that string to standard output."
+   "``-t``, ``--format-timespan=SECONDS``","Convert a number of seconds (given as the floating point number ``SECONDS``)
+   into a human readable timespan and print that string to standard output."
+   ``--parse-size=VALUE``,"Parse a human readable data size (given as the string ``VALUE``) and print the
+   number of bytes to standard output."
+   ``--parse-length=VALUE``,"Parse a human readable length (given as the string ``VALUE``) and print the
+   number of metres to standard output."
+   "``-h``, ``--help``","Show this message and exit.
+   "
+
+.. [[[end]]]
+
+A note about size units
+-----------------------
+
+When I originally published the `humanfriendly` package I went with binary
+multiples of bytes (powers of two). It was pointed out several times that this
+was a poor choice (see issue `#4`_ and pull requests `#8`_ and `#9`_) and thus
+the new default became decimal multiples of bytes (powers of ten):
+
++------+---------------+---------------+
+| Unit | Binary value  | Decimal value |
++------+---------------+---------------+
+| KB   |          1024 |          1000 +
++------+---------------+---------------+
+| MB   |       1048576 |       1000000 |
++------+---------------+---------------+
+| GB   |    1073741824 |    1000000000 |
++------+---------------+---------------+
+| TB   | 1099511627776 | 1000000000000 |
++------+---------------+---------------+
+| etc  |               |               |
++------+---------------+---------------+
+
+The option to use binary multiples of bytes remains by passing the keyword
+argument `binary=True` to the `format_size()`_ and `parse_size()`_ functions.
+
+Contact
+-------
+
+The latest version of `humanfriendly` is available on PyPI_ and GitHub_. The
+documentation is hosted on `Read the Docs`_. For bug reports please create an
+issue on GitHub_. If you have questions, suggestions, etc. feel free to send me
+an e-mail at `peter at peterodding.com`_.
+
+License
+-------
+
+This software is licensed under the `MIT license`_.
+
+© 2017 Peter Odding.
+
+.. External references:
+.. _#4: https://github.com/xolox/python-humanfriendly/issues/4
+.. _#8: https://github.com/xolox/python-humanfriendly/pull/8
+.. _#9: https://github.com/xolox/python-humanfriendly/pull/9
+.. _format_size(): https://humanfriendly.readthedocs.io/en/latest/#humanfriendly.format_size
+.. _GitHub: https://github.com/xolox/python-humanfriendly
+.. _MIT license: http://en.wikipedia.org/wiki/MIT_License
+.. _parse_size(): https://humanfriendly.readthedocs.io/en/latest/#humanfriendly.parse_size
+.. _peter at peterodding.com: peter at peterodding.com
+.. _PyPI: https://pypi.python.org/pypi/humanfriendly
+.. _Read the Docs: https://humanfriendly.readthedocs.io
diff --git a/humanfriendly.egg-info/PKG-INFO b/humanfriendly.egg-info/PKG-INFO
new file mode 100644
index 0000000..97552fb
--- /dev/null
+++ b/humanfriendly.egg-info/PKG-INFO
@@ -0,0 +1,182 @@
+Metadata-Version: 1.1
+Name: humanfriendly
+Version: 2.3.2
+Summary: Human friendly output for text interfaces using Python
+Home-page: https://humanfriendly.readthedocs.io
+Author: Peter Odding
+Author-email: peter at peterodding.com
+License: UNKNOWN
+Description: humanfriendly: Human friendly input/output in Python
+        ====================================================
+        
+        .. image:: https://travis-ci.org/xolox/python-humanfriendly.svg?branch=master
+           :target: https://travis-ci.org/xolox/python-humanfriendly
+        
+        .. image:: https://coveralls.io/repos/xolox/python-humanfriendly/badge.png?branch=master
+           :target: https://coveralls.io/r/xolox/python-humanfriendly?branch=master
+        
+        The functions and classes in the `humanfriendly` package can be used to make
+        text interfaces more user friendly. Some example features:
+        
+        - Parsing and formatting numbers, file sizes, pathnames and timespans in
+          simple, human friendly formats.
+        
+        - Easy to use timers for long running operations, with human friendly
+          formatting of the resulting timespans.
+        
+        - Prompting the user to select a choice from a list of options by typing the
+          option's number or a unique substring of the option.
+        
+        - Terminal interaction including text styling (ANSI escape sequences), user
+          friendly rendering of usage messages and querying the terminal for its
+          size.
+        
+        The `humanfriendly` package is currently tested on Python 2.6, 2.7, 3.4, 3.5
+        and PyPy.
+        
+        .. contents::
+           :local:
+        
+        Getting started
+        ---------------
+        
+        It's very simple to start using the `humanfriendly` package::
+        
+           >>> import humanfriendly
+           >>> user_input = raw_input("Enter a readable file size: ")
+           Enter a readable file size: 16G
+           >>> num_bytes = humanfriendly.parse_size(user_input)
+           >>> print num_bytes
+           16000000000
+           >>> print "You entered:", humanfriendly.format_size(num_bytes)
+           You entered: 16 GB
+           >>> print "You entered:", humanfriendly.format_size(num_bytes, binary=True)
+           You entered: 14.9 GiB
+        
+        Command line
+        ------------
+        
+        .. A DRY solution to avoid duplication of the `humanfriendly --help' text:
+        ..
+        .. [[[cog
+        .. from humanfriendly.usage import inject_usage
+        .. inject_usage('humanfriendly.cli')
+        .. ]]]
+        
+        **Usage:** `humanfriendly [OPTIONS]`
+        
+        Human friendly input/output (text formatting) on the command line based on the Python package with the same name.
+        
+        **Supported options:**
+        
+        .. csv-table::
+           :header: Option, Description
+           :widths: 30, 70
+        
+        
+           "``-c``, ``--run-command``","Execute an external command (given as the positional arguments) and render
+           a spinner and timer while the command is running. The exit status of the
+           command is propagated."
+           ``--format-table``,"Read tabular data from standard input (each line is a row and each
+           whitespace separated field is a column), format the data as a table and
+           print the resulting table to standard output. See also the ``--delimiter``
+           option."
+           "``-d``, ``--delimiter=VALUE``","Change the delimiter used by ``--format-table`` to ``VALUE`` (a string). By default
+           all whitespace is treated as a delimiter."
+           "``-l``, ``--format-length=LENGTH``","Convert a length count (given as the integer or float ``LENGTH``) into a human
+           readable string and print that string to standard output."
+           "``-n``, ``--format-number=VALUE``","Format a number (given as the integer or floating point number ``VALUE``) with
+           thousands separators and two decimal places (if needed) and print the
+           formatted number to standard output."
+           "``-s``, ``--format-size=BYTES``","Convert a byte count (given as the integer ``BYTES``) into a human readable
+           string and print that string to standard output."
+           "``-t``, ``--format-timespan=SECONDS``","Convert a number of seconds (given as the floating point number ``SECONDS``)
+           into a human readable timespan and print that string to standard output."
+           ``--parse-size=VALUE``,"Parse a human readable data size (given as the string ``VALUE``) and print the
+           number of bytes to standard output."
+           ``--parse-length=VALUE``,"Parse a human readable length (given as the string ``VALUE``) and print the
+           number of metres to standard output."
+           "``-h``, ``--help``","Show this message and exit.
+           "
+        
+        .. [[[end]]]
+        
+        A note about size units
+        -----------------------
+        
+        When I originally published the `humanfriendly` package I went with binary
+        multiples of bytes (powers of two). It was pointed out several times that this
+        was a poor choice (see issue `#4`_ and pull requests `#8`_ and `#9`_) and thus
+        the new default became decimal multiples of bytes (powers of ten):
+        
+        +------+---------------+---------------+
+        | Unit | Binary value  | Decimal value |
+        +------+---------------+---------------+
+        | KB   |          1024 |          1000 +
+        +------+---------------+---------------+
+        | MB   |       1048576 |       1000000 |
+        +------+---------------+---------------+
+        | GB   |    1073741824 |    1000000000 |
+        +------+---------------+---------------+
+        | TB   | 1099511627776 | 1000000000000 |
+        +------+---------------+---------------+
+        | etc  |               |               |
+        +------+---------------+---------------+
+        
+        The option to use binary multiples of bytes remains by passing the keyword
+        argument `binary=True` to the `format_size()`_ and `parse_size()`_ functions.
+        
+        Contact
+        -------
+        
+        The latest version of `humanfriendly` is available on PyPI_ and GitHub_. The
+        documentation is hosted on `Read the Docs`_. For bug reports please create an
+        issue on GitHub_. If you have questions, suggestions, etc. feel free to send me
+        an e-mail at `peter at peterodding.com`_.
+        
+        License
+        -------
+        
+        This software is licensed under the `MIT license`_.
+        
+        © 2017 Peter Odding.
+        
+        .. External references:
+        .. _#4: https://github.com/xolox/python-humanfriendly/issues/4
+        .. _#8: https://github.com/xolox/python-humanfriendly/pull/8
+        .. _#9: https://github.com/xolox/python-humanfriendly/pull/9
+        .. _format_size(): https://humanfriendly.readthedocs.io/en/latest/#humanfriendly.format_size
+        .. _GitHub: https://github.com/xolox/python-humanfriendly
+        .. _MIT license: http://en.wikipedia.org/wiki/MIT_License
+        .. _parse_size(): https://humanfriendly.readthedocs.io/en/latest/#humanfriendly.parse_size
+        .. _peter at peterodding.com: peter at peterodding.com
+        .. _PyPI: https://pypi.python.org/pypi/humanfriendly
+        .. _Read the Docs: https://humanfriendly.readthedocs.io
+        
+Platform: UNKNOWN
+Classifier: Development Status :: 6 - Mature
+Classifier: Environment :: Console
+Classifier: Framework :: Sphinx :: Extension
+Classifier: Intended Audience :: Developers
+Classifier: Intended Audience :: System Administrators
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Natural Language :: English
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Topic :: Communications
+Classifier: Topic :: Scientific/Engineering :: Human Machine Interfaces
+Classifier: Topic :: Software Development
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Classifier: Topic :: Software Development :: User Interfaces
+Classifier: Topic :: System :: Shells
+Classifier: Topic :: System :: System Shells
+Classifier: Topic :: System :: Systems Administration
+Classifier: Topic :: Terminals
+Classifier: Topic :: Text Processing :: General
+Classifier: Topic :: Text Processing :: Linguistic
+Classifier: Topic :: Utilities
diff --git a/humanfriendly.egg-info/SOURCES.txt b/humanfriendly.egg-info/SOURCES.txt
new file mode 100644
index 0000000..6f96b0b
--- /dev/null
+++ b/humanfriendly.egg-info/SOURCES.txt
@@ -0,0 +1,23 @@
+LICENSE.txt
+MANIFEST.in
+README.rst
+requirements-checks.txt
+requirements-testing.txt
+setup.cfg
+setup.py
+humanfriendly/__init__.py
+humanfriendly/cli.py
+humanfriendly/compat.py
+humanfriendly/prompts.py
+humanfriendly/sphinx.py
+humanfriendly/tables.py
+humanfriendly/terminal.py
+humanfriendly/tests.py
+humanfriendly/text.py
+humanfriendly/usage.py
+humanfriendly.egg-info/PKG-INFO
+humanfriendly.egg-info/SOURCES.txt
+humanfriendly.egg-info/dependency_links.txt
+humanfriendly.egg-info/entry_points.txt
+humanfriendly.egg-info/requires.txt
+humanfriendly.egg-info/top_level.txt
\ No newline at end of file
diff --git a/humanfriendly.egg-info/dependency_links.txt b/humanfriendly.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/humanfriendly.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/humanfriendly.egg-info/entry_points.txt b/humanfriendly.egg-info/entry_points.txt
new file mode 100644
index 0000000..2ce8fb8
--- /dev/null
+++ b/humanfriendly.egg-info/entry_points.txt
@@ -0,0 +1,3 @@
+[console_scripts]
+humanfriendly = humanfriendly.cli:main
+
diff --git a/humanfriendly.egg-info/requires.txt b/humanfriendly.egg-info/requires.txt
new file mode 100644
index 0000000..0b619b0
--- /dev/null
+++ b/humanfriendly.egg-info/requires.txt
@@ -0,0 +1,6 @@
+
+[:python_version == "2.6" or python_version == "2.7" or python_version == "3.0" or python_version == "3.1" or python_version == "3.2"]
+monotonic
+
+[:python_version == "2.6" or python_version == "3.0"]
+importlib
diff --git a/humanfriendly.egg-info/top_level.txt b/humanfriendly.egg-info/top_level.txt
new file mode 100644
index 0000000..f5368c4
--- /dev/null
+++ b/humanfriendly.egg-info/top_level.txt
@@ -0,0 +1 @@
+humanfriendly
diff --git a/humanfriendly/__init__.py b/humanfriendly/__init__.py
new file mode 100644
index 0000000..f9cf8ed
--- /dev/null
+++ b/humanfriendly/__init__.py
@@ -0,0 +1,974 @@
+# Human friendly input/output in Python.
+#
+# Author: Peter Odding <peter at peterodding.com>
+# Last Change: January 17, 2017
+# URL: https://humanfriendly.readthedocs.io
+
+"""The main module of the `humanfriendly` package."""
+
+# Standard library modules.
+import collections
+import decimal
+import multiprocessing
+import numbers
+import os
+import os.path
+import re
+import sys
+import time
+
+# In humanfriendly 1.23 the format_table() function was added to render a table
+# using characters like dashes and vertical bars to emulate borders. Since then
+# support for other tables has been added and the name of format_table() has
+# changed. The following import statement preserves backwards compatibility.
+from humanfriendly.tables import format_pretty_table as format_table  # NOQA
+
+# In humanfriendly 1.30 the following text manipulation functions were moved
+# out into a separate module to enable their usage in other modules of the
+# humanfriendly package (without causing circular imports).
+from humanfriendly.text import (  # NOQA
+    compact, concatenate, dedent, format, is_empty_line,
+    pluralize, tokenize, trim_empty_lines,
+)
+
+# In humanfriendly 1.38 the prompt_for_choice() function was moved out into a
+# separate module because several variants of interactive prompts were added.
+from humanfriendly.prompts import prompt_for_choice  # NOQA
+
+# Compatibility with Python 2 and 3.
+from humanfriendly.compat import is_string, monotonic
+
+# Semi-standard module versioning.
+__version__ = '2.3.2'
+
+# Spinners are redrawn at most this many seconds.
+minimum_spinner_interval = 0.2
+
+# The following ANSI escape sequence can be used to clear a line and move the
+# cursor back to the start of the line.
+erase_line_code = '\r\x1b[K'
+
+# ANSI escape sequences to hide and show the text cursor.
+hide_cursor_code = '\x1b[?25l'
+show_cursor_code = '\x1b[?25h'
+
+SizeUnit = collections.namedtuple('SizeUnit', 'divider, symbol, name')
+CombinedUnit = collections.namedtuple('CombinedUnit', 'decimal, binary')
+
+# Common disk size units in binary (base-2) and decimal (base-10) multiples.
+disk_size_units = (
+    CombinedUnit(SizeUnit(1000**1, 'KB', 'kilobyte'), SizeUnit(1024**1, 'KiB', 'kibibyte')),
+    CombinedUnit(SizeUnit(1000**2, 'MB', 'megabyte'), SizeUnit(1024**2, 'MiB', 'mebibyte')),
+    CombinedUnit(SizeUnit(1000**3, 'GB', 'gigabyte'), SizeUnit(1024**3, 'GiB', 'gibibyte')),
+    CombinedUnit(SizeUnit(1000**4, 'TB', 'terabyte'), SizeUnit(1024**4, 'TiB', 'tebibyte')),
+    CombinedUnit(SizeUnit(1000**5, 'PB', 'petabyte'), SizeUnit(1024**5, 'PiB', 'pebibyte')),
+)
+
+# Common length size units, used for formatting and parsing.
+length_size_units = (dict(prefix='nm', divider=1e-09, singular='nm', plural='nm'),
+                     dict(prefix='mm', divider=1e-03, singular='mm', plural='mm'),
+                     dict(prefix='cm', divider=1e-02, singular='cm', plural='cm'),
+                     dict(prefix='m', divider=1, singular='metre', plural='metres'),
+                     dict(prefix='km', divider=1000, singular='km', plural='km'))
+
+# Common time units, used for formatting of time spans.
+time_units = (dict(divider=1e-3, singular='millisecond', plural='milliseconds', abbreviation='ms'),
+              dict(divider=1, singular='second', plural='seconds', abbreviation='s'),
+              dict(divider=60, singular='minute', plural='minutes', abbreviation='m'),
+              dict(divider=60 * 60, singular='hour', plural='hours', abbreviation='h'),
+              dict(divider=60 * 60 * 24, singular='day', plural='days', abbreviation='d'),
+              dict(divider=60 * 60 * 24 * 7, singular='week', plural='weeks', abbreviation='w'),
+              dict(divider=60 * 60 * 24 * 7 * 52, singular='year', plural='years', abbreviation='y'))
+
+
+def coerce_boolean(value):
+    """
+    Coerce any value to a boolean.
+
+    :param value: Any Python value. If the value is a string:
+
+                  - The strings '1', 'yes', 'true' and 'on' are coerced to :data:`True`.
+                  - The strings '0', 'no', 'false' and 'off' are coerced to :data:`False`.
+                  - Other strings raise an exception.
+
+                  Other Python values are coerced using :py:func:`bool()`.
+    :returns: A proper boolean value.
+    :raises: :py:exc:`exceptions.ValueError` when the value is a string but
+             cannot be coerced with certainty.
+    """
+    if is_string(value):
+        normalized = value.strip().lower()
+        if normalized in ('1', 'yes', 'true', 'on'):
+            return True
+        elif normalized in ('0', 'no', 'false', 'off', ''):
+            return False
+        else:
+            msg = "Failed to coerce string to boolean! (%r)"
+            raise ValueError(msg % value)
+    else:
+        return bool(value)
+
+
+def format_size(num_bytes, keep_width=False, binary=False):
+    """
+    Format a byte count as a human readable file size.
+
+    :param num_bytes: The size to format in bytes (an integer).
+    :param keep_width: :data:`True` if trailing zeros should not be stripped,
+                       :data:`False` if they can be stripped.
+    :param binary: :data:`True` to use binary multiples of bytes (base-2),
+                   :data:`False` to use decimal multiples of bytes (base-10).
+    :returns: The corresponding human readable file size (a string).
+
+    This function knows how to format sizes in bytes, kilobytes, megabytes,
+    gigabytes, terabytes and petabytes. Some examples:
+
+    >>> from humanfriendly import format_size
+    >>> format_size(0)
+    '0 bytes'
+    >>> format_size(1)
+    '1 byte'
+    >>> format_size(5)
+    '5 bytes'
+    > format_size(1000)
+    '1 KB'
+    > format_size(1024, binary=True)
+    '1 KiB'
+    >>> format_size(1000 ** 3 * 4)
+    '4 GB'
+    """
+    for unit in reversed(disk_size_units):
+        if num_bytes >= unit.binary.divider and binary:
+            number = round_number(float(num_bytes) / unit.binary.divider, keep_width=keep_width)
+            return pluralize(number, unit.binary.symbol, unit.binary.symbol)
+        elif num_bytes >= unit.decimal.divider and not binary:
+            number = round_number(float(num_bytes) / unit.decimal.divider, keep_width=keep_width)
+            return pluralize(number, unit.decimal.symbol, unit.decimal.symbol)
+    return pluralize(num_bytes, 'byte')
+
+
+def parse_size(size, binary=False):
+    """
+    Parse a human readable data size and return the number of bytes.
+
+    :param size: The human readable file size to parse (a string).
+    :param binary: :data:`True` to use binary multiples of bytes (base-2) for
+                   ambiguous unit symbols and names, :data:`False` to use
+                   decimal multiples of bytes (base-10).
+    :returns: The corresponding size in bytes (an integer).
+    :raises: :exc:`InvalidSize` when the input can't be parsed.
+
+    This function knows how to parse sizes in bytes, kilobytes, megabytes,
+    gigabytes, terabytes and petabytes. Some examples:
+
+    >>> from humanfriendly import parse_size
+    >>> parse_size('42')
+    42
+    >>> parse_size('13b')
+    13
+    >>> parse_size('5 bytes')
+    5
+    >>> parse_size('1 KB')
+    1000
+    >>> parse_size('1 kilobyte')
+    1000
+    >>> parse_size('1 KiB')
+    1024
+    >>> parse_size('1 KB', binary=True)
+    1024
+    >>> parse_size('1.5 GB')
+    1500000000
+    >>> parse_size('1.5 GB', binary=True)
+    1610612736
+    """
+    tokens = tokenize(size)
+    if tokens and isinstance(tokens[0], numbers.Number):
+        # Get the normalized unit (if any) from the tokenized input.
+        normalized_unit = tokens[1].lower() if len(tokens) == 2 and is_string(tokens[1]) else ''
+        # If the input contains only a number, it's assumed to be the number of
+        # bytes. The second token can also explicitly reference the unit bytes.
+        if len(tokens) == 1 or normalized_unit.startswith('b'):
+            return int(tokens[0])
+        # Otherwise we expect two tokens: A number and a unit.
+        if normalized_unit:
+            for unit in disk_size_units:
+                # First we check for unambiguous symbols (KiB, MiB, GiB, etc)
+                # and names (kibibyte, mebibyte, gibibyte, etc) because their
+                # handling is always the same.
+                if normalized_unit in (unit.binary.symbol.lower(), unit.binary.name.lower()):
+                    return int(tokens[0] * unit.binary.divider)
+                # Now we will deal with ambiguous prefixes (K, M, G, etc),
+                # symbols (KB, MB, GB, etc) and names (kilobyte, megabyte,
+                # gigabyte, etc) according to the caller's preference.
+                if (normalized_unit in (unit.decimal.symbol.lower(), unit.decimal.name.lower()) or
+                        normalized_unit.startswith(unit.decimal.symbol[0].lower())):
+                    return int(tokens[0] * (unit.binary.divider if binary else unit.decimal.divider))
+    # We failed to parse the size specification.
+    msg = "Failed to parse size! (input %r was tokenized as %r)"
+    raise InvalidSize(msg % (size, tokens))
+
+
+def format_length(num_metres, keep_width=False):
+    """
+    Format a metre count as a human readable length.
+
+    :param num_metres: The length to format in metres (float / integer).
+    :param keep_width: :data:`True` if trailing zeros should not be stripped,
+                       :data:`False` if they can be stripped.
+    :returns: The corresponding human readable length (a string).
+
+    This function supports ranges from nanometres to kilometres.
+
+    Some examples:
+
+    >>> from humanfriendly import format_length
+    >>> format_length(0)
+    '0 metres'
+    >>> format_length(1)
+    '1 metre'
+    >>> format_length(5)
+    '5 metres'
+    >>> format_length(1000)
+    '1 km'
+    >>> format_length(0.004)
+    '4 mm'
+    """
+    for unit in reversed(length_size_units):
+        if num_metres >= unit['divider']:
+            number = round_number(float(num_metres) / unit['divider'], keep_width=keep_width)
+            return pluralize(number, unit['singular'], unit['plural'])
+    return pluralize(num_metres, 'metre')
+
+
+def parse_length(length):
+    """
+    Parse a human readable length and return the number of metres.
+
+    :param length: The human readable length to parse (a string).
+    :returns: The corresponding length in metres (a float).
+    :raises: :exc:`InvalidLength` when the input can't be parsed.
+
+    Some examples:
+
+    >>> from humanfriendly import parse_length
+    >>> parse_length('42')
+    42
+    >>> parse_length('1 km')
+    1000
+    >>> parse_length('5mm')
+    0.005
+    >>> parse_length('15.3cm')
+    0.153
+    """
+    tokens = tokenize(length)
+    if tokens and isinstance(tokens[0], numbers.Number):
+        # If the input contains only a number, it's assumed to be the number of metres.
+        if len(tokens) == 1:
+            return int(tokens[0])
+        # Otherwise we expect to find two tokens: A number and a unit.
+        if len(tokens) == 2 and is_string(tokens[1]):
+            normalized_unit = tokens[1].lower()
+            # Try to match the first letter of the unit.
+            for unit in length_size_units:
+                if normalized_unit.startswith(unit['prefix']):
+                    return tokens[0] * unit['divider']
+    # We failed to parse the length specification.
+    msg = "Failed to parse length! (input %r was tokenized as %r)"
+    raise InvalidLength(msg % (length, tokens))
+
+
+def format_number(number, num_decimals=2):
+    """
+    Format a number as a string including thousands separators.
+
+    :param number: The number to format (a number like an :class:`int`,
+                   :class:`long` or :class:`float`).
+    :param num_decimals: The number of decimals to render (2 by default). If no
+                         decimal places are required to represent the number
+                         they will be omitted regardless of this argument.
+    :returns: The formatted number (a string).
+
+    This function is intended to make it easier to recognize the order of size
+    of the number being formatted.
+
+    Here's an example:
+
+    >>> from humanfriendly import format_number
+    >>> print(format_number(6000000))
+    6,000,000
+    > print(format_number(6000000000.42))
+    6,000,000,000.42
+    > print(format_number(6000000000.42, num_decimals=0))
+    6,000,000,000
+    """
+    integer_part, _, decimal_part = str(float(number)).partition('.')
+    reversed_digits = ''.join(reversed(integer_part))
+    parts = []
+    while reversed_digits:
+        parts.append(reversed_digits[:3])
+        reversed_digits = reversed_digits[3:]
+    formatted_number = ''.join(reversed(','.join(parts)))
+    decimals_to_add = decimal_part[:num_decimals].rstrip('0')
+    if decimals_to_add:
+        formatted_number += '.' + decimals_to_add
+    return formatted_number
+
+
+def round_number(count, keep_width=False):
+    """
+    Round a floating point number to two decimal places in a human friendly format.
+
+    :param count: The number to format.
+    :param keep_width: :data:`True` if trailing zeros should not be stripped,
+                       :data:`False` if they can be stripped.
+    :returns: The formatted number as a string. If no decimal places are
+              required to represent the number, they will be omitted.
+
+    The main purpose of this function is to be used by functions like
+    :func:`format_length()`, :func:`format_size()` and
+    :func:`format_timespan()`.
+
+    Here are some examples:
+
+    >>> from humanfriendly import round_number
+    >>> round_number(1)
+    '1'
... 4083 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/humanfriendly.git



More information about the Python-modules-commits mailing list