Metadata-Version: 2.4
Name: cooked-input
Version: 0.7.0
Summary: Get, clean, convert and validate input.
Author-email: Len Wanger <len_wanger@hotmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/lwanger/cooked_input
Project-URL: Source, https://github.com/lwanger/cooked_input
Project-URL: Documentation, https://cooked-input.readthedocs.io
Keywords: command line,tool development,input,raw_input
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Topic :: Database :: Front-Ends
Classifier: Topic :: Software Development
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.10
Description-Content-Type: text/x-rst
License-File: LICENSE
License-File: LICENSE.txt
Requires-Dist: prettytable>=3.18.0
Requires-Dist: dateparser>=1.4.2
Provides-Extra: test
Requires-Dist: pytest>=8; extra == "test"
Requires-Dist: pytest-timeout>=2.3; extra == "test"
Requires-Dist: pytest-cov>=5; extra == "test"
Provides-Extra: typecheck
Requires-Dist: ty==0.0.70; extra == "typecheck"
Requires-Dist: ruff>=0.16.2; extra == "typecheck"
Requires-Dist: types-dateparser>=1.4; extra == "typecheck"
Dynamic: license-file


.. Keep this file in sync with README.md.

   This file is the canonical copy: pyproject.toml ships it to PyPI as the long
   description. README.md exists because GitHub renders it in preference to this
   file, so it is what visitors to the repository see. Any change to one belongs in
   the other, and the "tested through Python X.Y" line below must also match
   README.md, docs/README.rst and the classifiers in pyproject.toml.

.. image:: https://img.shields.io/pypi/v/cooked_input.svg
    :target: https://pypi.org/project/cooked_input/

.. image:: https://img.shields.io/pypi/l/cooked_input.svg
    :target: https://pypi.org/project/cooked_input/

.. image:: https://readthedocs.org/projects/cooked-input/badge/?version=latest
    :target: https://cooked-input.readthedocs.io/en/latest/

.. image:: https://github.com/lwanger/cooked_input/actions/workflows/tests.yml/badge.svg
    :target: https://github.com/lwanger/cooked_input/actions/workflows/tests.yml

.. image:: https://img.shields.io/pypi/pyversions/cooked_input.svg
    :target: https://pypi.org/project/cooked_input/



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 <http://cooked-input.readthedocs.io/en/latest/quick_start.html>`_
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 <http://cooked-input.readthedocs.io/en/latest/tutorial.html>`_ and `part two <http://cooked-input.readthedocs.io/en/latest/tutorial2.html>`_) 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 <https://github.com/lwanger/cooked_input/blob/master/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
