Cooked Input Project
cooked_input is a Python package for getting, cleaning, converting, and validating input. If you think of input (raw_input in legacy Python) as raw input, then this is cooked input.
cooked_input provides a simple and safe way to get validated command line input that ranges from the simplest of Python programs to sophisticated database driven applications. Beginner’s can use the provided convenience classes to get simple inputs from the user. Following the quick start guide you can be up and running in minutes.
More advanced users can easily create custom classes for sophisticated cleaning and validation. Cooked_input can also be used to create menus and data tables. The latter tutorials (part one and part two) and examples show several examples ranging from simple to sophisticated calls.
Cooked_input also provides a pathway to use the same cleaning and validation logic used in the command line for validating web or GUI based inputs.
Documentation
The documentation is available at: http://cooked-input.readthedocs.io/en/latest/
Python Support
cooked_input requires Python 3.10 or later, and has been tested through Python 3.14. Python 2 is no longer supported (the last release supporting it is v0.5.4).
Release Notes
v0.7.0 is a large release by volume of change, even though it adds no new functionality. It is almost entirely work on the inside of the package. Every function, method and class was annotated with types, and a py.typed marker now ships so downstream projects actually see them; the test suite went from 86 tests at 79.6% coverage to 661 at 100%; and the two largest modules were split along the seam they already had. Reading essentially all of the code that way turned up thirty-two real defects that had been sitting behind an untyped signature or an untested line, and those fixes are the bulk of the release.
There are breaking changes. Most code will not notice, but they are worth a look before upgrading:
DecimalConvertor now honours precision and rounding, which it had been ignoring, so get_money(precision=2) returns different numbers than it used to.
Table.scroll_up_one_row and Table.scroll_down_one_row had their bodies the wrong way round and now move the view in the direction they are named for.
get_menu returns 'exit' where it used to hand back a TableItem, and Table.get_table_choice returns None when the exit row is chosen.
A blank line at a required=True prompt is reported through error_callback and counts against retries, instead of being skipped in silence – which had been an infinite loop.
in_all, in_any and not_in are no longer importable from cooked_input. They were always internal plumbing and appeared in no documentation. validate() is unaffected.
The module-level validation helpers, and SimpleValidator, now return a real bool rather than passing a validator’s truthy return value through, and return True rather than None when there is nothing to validate.
GetInput and every get_* function take their options as named keyword-only parameters instead of a **options dictionary. An unrecognised option raises a TypeError rather than logging a warning and carrying on with the default, so get_int(promt="Age?") is now reported instead of quietly asking the wrong question. Code that builds an options dictionary still works by unpacking it: get_int(**options).
Table, create_table, get_menu, Table.get_table_choice and get_table_input changed the same way. An unrecognised option raises a TypeError rather than being silently ignored – which is how two bugs in the shipped examples had gone unnoticed.
Cleaner, Convertor and Validator are now real abstract base classes. A subclass that never implemented __call__ raises TypeError when instantiated, where before it silently returned None from every call.
A single string given to AnyOfValidator or NoneOfValidator is now one choice rather than being iterated one character at a time.
See CHANGELOG.rst for the full list, including the defects the type checker found and what each of them affected.
Installation
pip install cooked_input
Project Page
Project information and source code is available at: https://github.com/lwanger/cooked_input
Tutorial
The best way to get started is to read the quick start at: http://cooked-input.readthedocs.io/en/latest/quick_start.html
After that, more advanced usage can be learned from the tutorial at: http://cooked-input.readthedocs.io/en/latest/tutorial.html
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cooked_input-0.7.0.tar.gz.
File metadata
- Download URL: cooked_input-0.7.0.tar.gz
- Upload date:
- Size: 152.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20132bf962aa466d7e1492fb9dd7eb3594b221be657e14275585d03db5efa26d
|
|
| MD5 |
89bd426289e6b43bd421b96d420cfb26
|
|
| BLAKE2b-256 |
c652799fb6169db013f15e200f6a22ca36fdb12a0011c7651e5212019cbe9ff7
|
Provenance
The following attestation bundles were made for cooked_input-0.7.0.tar.gz:
Publisher:
release.yml on lwanger/cooked_input
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cooked_input-0.7.0.tar.gz -
Subject digest:
20132bf962aa466d7e1492fb9dd7eb3594b221be657e14275585d03db5efa26d - Sigstore transparency entry: 2446980705
- Sigstore integration time:
-
Permalink:
lwanger/cooked_input@b3d5a6e8f3b51d1257135c26ef17931660dbddfa -
Branch / Tag:
refs/tags/v0.7.0 - Owner: https://github.com/lwanger
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b3d5a6e8f3b51d1257135c26ef17931660dbddfa -
Trigger Event:
push
-
Statement type:
File details
Details for the file cooked_input-0.7.0-py3-none-any.whl.
File metadata
- Download URL: cooked_input-0.7.0-py3-none-any.whl
- Upload date:
- Size: 149.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2358339e2a9f2ec06cd4cf0a0c1bad30405646aa2bbb760fc60c61a86592abaa
|
|
| MD5 |
421712bce2ffa8140902916239b0c5ca
|
|
| BLAKE2b-256 |
73183e6391286c463f34b4696e4588ef1f4303844d1b74507aaaa23aca974491
|
Provenance
The following attestation bundles were made for cooked_input-0.7.0-py3-none-any.whl:
Publisher:
release.yml on lwanger/cooked_input
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cooked_input-0.7.0-py3-none-any.whl -
Subject digest:
2358339e2a9f2ec06cd4cf0a0c1bad30405646aa2bbb760fc60c61a86592abaa - Sigstore transparency entry: 2446980797
- Sigstore integration time:
-
Permalink:
lwanger/cooked_input@b3d5a6e8f3b51d1257135c26ef17931660dbddfa -
Branch / Tag:
refs/tags/v0.7.0 - Owner: https://github.com/lwanger
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b3d5a6e8f3b51d1257135c26ef17931660dbddfa -
Trigger Event:
push
-
Statement type: