11humanfriendly: Human friendly input/output in Python
22====================================================
33
4- .. image :: https://travis-ci.org /xolox/python-humanfriendly.svg?branch=master
5- :target: https://travis-ci.org /xolox/python-humanfriendly
4+ .. image :: https://github.com /xolox/python-humanfriendly/actions/workflows/test.yml/badge .svg?branch=master
5+ :target: https://github.com /xolox/python-humanfriendly/actions
66
7- .. image :: https://coveralls .io/repos/github/ xolox/python-humanfriendly/badge.svg?branch=master
8- :target: https://coveralls .io/github /xolox/python-humanfriendly?branch=master
7+ .. image :: https://codecov .io/gh/ xolox/python-humanfriendly/branch/master/graph/ badge.svg?token=jYaj4T74TU
8+ :target: https://codecov .io/gh /xolox/python-humanfriendly
99
1010The functions and classes in the `humanfriendly ` package can be used to make
1111text interfaces more user friendly. Some example features:
@@ -19,7 +19,7 @@ text interfaces more user friendly. Some example features:
1919- Prompting the user to select a choice from a list of options by typing the
2020 option's number or a unique substring of the option.
2121
22- - Terminal interaction including text styling (ANSI escape sequences), user
22+ - Terminal interaction including text styling (` ANSI escape sequences `_ ), user
2323 friendly rendering of usage messages and querying the terminal for its
2424 size.
2525
@@ -35,17 +35,25 @@ Getting started
3535
3636It's very simple to start using the `humanfriendly ` package::
3737
38- >>> import humanfriendly
39- >>> user_input = raw_input("Enter a readable file size: ")
40- Enter a readable file size: 16G
41- >>> num_bytes = humanfriendly.parse_size(user_input)
42- >>> print num_bytes
38+ >>> from humanfriendly import format_size, parse_size
39+ >>> from humanfriendly.prompts import prompt_for_input
40+ >>> user_input = prompt_for_input("Enter a readable file size: ")
41+
42+ Enter a readable file size: 16G
43+
44+ >>> num_bytes = parse_size(user_input)
45+ >>> print(num_bytes)
4346 16000000000
44- >>> print "You entered:", humanfriendly. format_size(num_bytes)
47+ >>> print( "You entered:", format_size(num_bytes) )
4548 You entered: 16 GB
46- >>> print "You entered:", humanfriendly. format_size(num_bytes, binary=True)
49+ >>> print( "You entered:", format_size(num_bytes, binary=True) )
4750 You entered: 14.9 GiB
4851
52+ To get a demonstration of supported terminal text styles (based on
53+ `ANSI escape sequences `_) you can run the following command::
54+
55+ $ humanfriendly --demo
56+
4957Command line
5058------------
5159
@@ -144,12 +152,13 @@ License
144152
145153This software is licensed under the `MIT license `_.
146154
147- © 2020 Peter Odding.
155+ © 2021 Peter Odding.
148156
149157.. External references:
150158 .. _#4 : https://github.com/xolox/python-humanfriendly/issues/4
151159.. _#8 : https://github.com/xolox/python-humanfriendly/pull/8
152160.. _#9 : https://github.com/xolox/python-humanfriendly/pull/9
161+ .. _ANSI escape sequences : https://en.wikipedia.org/wiki/ANSI_escape_code
153162.. _changelog : https://humanfriendly.readthedocs.io/en/latest/changelog.html
154163.. _colorama : https://pypi.org/project/colorama
155164.. _format_size() : https://humanfriendly.readthedocs.io/en/latest/#humanfriendly.format_size
0 commit comments