%global _empty_manifest_terminate_build 0 Name: python-columbo Version: 0.13.0.post1 Release: 1 Summary: Specify a dynamic set of questions to ask a user and get their answers. License: MIT License URL: https://github.com/plannigan/columbo Source0: https://mirrors.nju.edu.cn/pypi/web/packages/85/f6/a82a7eadfa515d2e0b1126ed359bbc0af14b18910667ecbb9288e87d7802/columbo-0.13.0.post1.tar.gz BuildArch: noarch Requires: python3-prompt-toolkit Requires: python3-typing-extensions %description [![CI pipeline status](https://github.com/plannigan/columbo/workflows/CI/badge.svg?branch=main)][ci] [![PyPI](https://img.shields.io/pypi/v/columbo)][pypi] [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/columbo)][pypi] [![codecov](https://codecov.io/gh/plannigan/columbo/branch/main/graph/badge.svg)][codecov] [![Checked with mypy](https://img.shields.io/badge/mypy-checked-blue)][mypy-home] [![Code style: black](https://img.shields.io/badge/code%20style-black-black.svg)][black-home] # Columbo Specify a dynamic set of questions to ask a user and get their answers. `columbo`'s feature set allows a program to: * Ask multiple types of questions: * Yes or No * Multiple choice * Open-ended * Validate the response provided by the user. * Use answers from earlier questions: * As part of the text of a question * As part of the text of a default value * To decide if a question should be skipped * Accept answers from the command line in addition to prompting the user. ## Example ### User Prompts The primary use of `columbo` is to define a sequence of interactions that are used to prompt a user to provide answers using a terminal. Below is a sample which shows some ways this can be used. ```python import columbo interactions = [ columbo.Echo("Welcome to the Columbo example"), columbo.Acknowledge( "Press enter to start" ), columbo.BasicQuestion( "user", "What is your name?", default="Patrick", ), columbo.BasicQuestion( "user_email", lambda answers: f"""What email address should be used to contact {answers["user"]}?""", default="me@example.com" ), columbo.Choice( "mood", "How are you feeling today?", options={ "happy": "😀", "sad": "😢", "sleepy": "🥱", "confused": "🤔", }, default="happy", ), columbo.Confirm("likes_dogs", "Do you like dogs?", default=True), ] answers = columbo.get_answers(interactions) print(answers) ``` Below shows the output when the user accepts the default values for most of the questions. The user provides a different value for the email and explicitly confirms that they like dogs. ```text Welcome to the Columbo example Press enter to start What is your name? [Patrick]: What email address should be used to contact Patrick? [me@example.com]: patrick@example.com How are you feeling today? 1 - 😀 2 - 😢 3 - 🥱 4 - 🤔 Enter the number of your choice [1]: Do you like dogs? (Y/n): y {'user': 'Patrick', 'user_email': 'patrick@example.com', 'mood': 'happy', 'likes_dogs': True} ``` ### Command Line Answers In addition to the interactive prompts, `columbo` can also parse command line arguments for interactions. This is done by changing `columbo.get_answers()` to `columbo.parse_args()`. Below shows the output when using the same interactions from above. ```shell $ python columbo_example.py --user-email patrick@example.com --likes-dogs {'user': 'Patrick', 'user_email': 'patrick@example.com', 'mood': 'happy', 'likes_dogs': True} ```
The full example ```python import columbo interactions = [ columbo.Echo("Welcome to the Columbo example"), columbo.Acknowledge( "Press enter to start" ), columbo.BasicQuestion( "user", "What is your name?", default="Patrick", ), columbo.BasicQuestion( "user_email", lambda answers: f"""What email address should be used to contact {answers["user"]}?""", default="me@example.com" ), columbo.Choice( "mood", "How are you feeling today?", options=["happy", "sad", "sleepy", "confused"], default="happy", ), columbo.Confirm("likes_dogs", "Do you like dogs?", default=True), ] answers = columbo.parse_args(interactions) print(answers) ```
## Documentation Check out the [project documentation][columbo-docs]. For an overview on how repository structure and how to work with the code base, read the [Development Guide][development-docs]. ## Credits The development of this project was originally funded and incubated by [Wayfair](https://github.com/wayfair-incubator). [ci]: https://github.com/plannigan/columbo/actions [pypi]: https://pypi.org/project/columbo/ [codecov]: https://codecov.io/gh/plannigan/columbo [mypy-home]: http://mypy-lang.org/ [black-home]: https://github.com/psf/black [columbo-docs]: https://plannigan.github.io/columbo/latest/ [development-docs]: https://plannigan.github.io/columbo/latest/development-guide/ %package -n python3-columbo Summary: Specify a dynamic set of questions to ask a user and get their answers. Provides: python-columbo BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-columbo [![CI pipeline status](https://github.com/plannigan/columbo/workflows/CI/badge.svg?branch=main)][ci] [![PyPI](https://img.shields.io/pypi/v/columbo)][pypi] [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/columbo)][pypi] [![codecov](https://codecov.io/gh/plannigan/columbo/branch/main/graph/badge.svg)][codecov] [![Checked with mypy](https://img.shields.io/badge/mypy-checked-blue)][mypy-home] [![Code style: black](https://img.shields.io/badge/code%20style-black-black.svg)][black-home] # Columbo Specify a dynamic set of questions to ask a user and get their answers. `columbo`'s feature set allows a program to: * Ask multiple types of questions: * Yes or No * Multiple choice * Open-ended * Validate the response provided by the user. * Use answers from earlier questions: * As part of the text of a question * As part of the text of a default value * To decide if a question should be skipped * Accept answers from the command line in addition to prompting the user. ## Example ### User Prompts The primary use of `columbo` is to define a sequence of interactions that are used to prompt a user to provide answers using a terminal. Below is a sample which shows some ways this can be used. ```python import columbo interactions = [ columbo.Echo("Welcome to the Columbo example"), columbo.Acknowledge( "Press enter to start" ), columbo.BasicQuestion( "user", "What is your name?", default="Patrick", ), columbo.BasicQuestion( "user_email", lambda answers: f"""What email address should be used to contact {answers["user"]}?""", default="me@example.com" ), columbo.Choice( "mood", "How are you feeling today?", options={ "happy": "😀", "sad": "😢", "sleepy": "🥱", "confused": "🤔", }, default="happy", ), columbo.Confirm("likes_dogs", "Do you like dogs?", default=True), ] answers = columbo.get_answers(interactions) print(answers) ``` Below shows the output when the user accepts the default values for most of the questions. The user provides a different value for the email and explicitly confirms that they like dogs. ```text Welcome to the Columbo example Press enter to start What is your name? [Patrick]: What email address should be used to contact Patrick? [me@example.com]: patrick@example.com How are you feeling today? 1 - 😀 2 - 😢 3 - 🥱 4 - 🤔 Enter the number of your choice [1]: Do you like dogs? (Y/n): y {'user': 'Patrick', 'user_email': 'patrick@example.com', 'mood': 'happy', 'likes_dogs': True} ``` ### Command Line Answers In addition to the interactive prompts, `columbo` can also parse command line arguments for interactions. This is done by changing `columbo.get_answers()` to `columbo.parse_args()`. Below shows the output when using the same interactions from above. ```shell $ python columbo_example.py --user-email patrick@example.com --likes-dogs {'user': 'Patrick', 'user_email': 'patrick@example.com', 'mood': 'happy', 'likes_dogs': True} ```
The full example ```python import columbo interactions = [ columbo.Echo("Welcome to the Columbo example"), columbo.Acknowledge( "Press enter to start" ), columbo.BasicQuestion( "user", "What is your name?", default="Patrick", ), columbo.BasicQuestion( "user_email", lambda answers: f"""What email address should be used to contact {answers["user"]}?""", default="me@example.com" ), columbo.Choice( "mood", "How are you feeling today?", options=["happy", "sad", "sleepy", "confused"], default="happy", ), columbo.Confirm("likes_dogs", "Do you like dogs?", default=True), ] answers = columbo.parse_args(interactions) print(answers) ```
## Documentation Check out the [project documentation][columbo-docs]. For an overview on how repository structure and how to work with the code base, read the [Development Guide][development-docs]. ## Credits The development of this project was originally funded and incubated by [Wayfair](https://github.com/wayfair-incubator). [ci]: https://github.com/plannigan/columbo/actions [pypi]: https://pypi.org/project/columbo/ [codecov]: https://codecov.io/gh/plannigan/columbo [mypy-home]: http://mypy-lang.org/ [black-home]: https://github.com/psf/black [columbo-docs]: https://plannigan.github.io/columbo/latest/ [development-docs]: https://plannigan.github.io/columbo/latest/development-guide/ %package help Summary: Development documents and examples for columbo Provides: python3-columbo-doc %description help [![CI pipeline status](https://github.com/plannigan/columbo/workflows/CI/badge.svg?branch=main)][ci] [![PyPI](https://img.shields.io/pypi/v/columbo)][pypi] [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/columbo)][pypi] [![codecov](https://codecov.io/gh/plannigan/columbo/branch/main/graph/badge.svg)][codecov] [![Checked with mypy](https://img.shields.io/badge/mypy-checked-blue)][mypy-home] [![Code style: black](https://img.shields.io/badge/code%20style-black-black.svg)][black-home] # Columbo Specify a dynamic set of questions to ask a user and get their answers. `columbo`'s feature set allows a program to: * Ask multiple types of questions: * Yes or No * Multiple choice * Open-ended * Validate the response provided by the user. * Use answers from earlier questions: * As part of the text of a question * As part of the text of a default value * To decide if a question should be skipped * Accept answers from the command line in addition to prompting the user. ## Example ### User Prompts The primary use of `columbo` is to define a sequence of interactions that are used to prompt a user to provide answers using a terminal. Below is a sample which shows some ways this can be used. ```python import columbo interactions = [ columbo.Echo("Welcome to the Columbo example"), columbo.Acknowledge( "Press enter to start" ), columbo.BasicQuestion( "user", "What is your name?", default="Patrick", ), columbo.BasicQuestion( "user_email", lambda answers: f"""What email address should be used to contact {answers["user"]}?""", default="me@example.com" ), columbo.Choice( "mood", "How are you feeling today?", options={ "happy": "😀", "sad": "😢", "sleepy": "🥱", "confused": "🤔", }, default="happy", ), columbo.Confirm("likes_dogs", "Do you like dogs?", default=True), ] answers = columbo.get_answers(interactions) print(answers) ``` Below shows the output when the user accepts the default values for most of the questions. The user provides a different value for the email and explicitly confirms that they like dogs. ```text Welcome to the Columbo example Press enter to start What is your name? [Patrick]: What email address should be used to contact Patrick? [me@example.com]: patrick@example.com How are you feeling today? 1 - 😀 2 - 😢 3 - 🥱 4 - 🤔 Enter the number of your choice [1]: Do you like dogs? (Y/n): y {'user': 'Patrick', 'user_email': 'patrick@example.com', 'mood': 'happy', 'likes_dogs': True} ``` ### Command Line Answers In addition to the interactive prompts, `columbo` can also parse command line arguments for interactions. This is done by changing `columbo.get_answers()` to `columbo.parse_args()`. Below shows the output when using the same interactions from above. ```shell $ python columbo_example.py --user-email patrick@example.com --likes-dogs {'user': 'Patrick', 'user_email': 'patrick@example.com', 'mood': 'happy', 'likes_dogs': True} ```
The full example ```python import columbo interactions = [ columbo.Echo("Welcome to the Columbo example"), columbo.Acknowledge( "Press enter to start" ), columbo.BasicQuestion( "user", "What is your name?", default="Patrick", ), columbo.BasicQuestion( "user_email", lambda answers: f"""What email address should be used to contact {answers["user"]}?""", default="me@example.com" ), columbo.Choice( "mood", "How are you feeling today?", options=["happy", "sad", "sleepy", "confused"], default="happy", ), columbo.Confirm("likes_dogs", "Do you like dogs?", default=True), ] answers = columbo.parse_args(interactions) print(answers) ```
## Documentation Check out the [project documentation][columbo-docs]. For an overview on how repository structure and how to work with the code base, read the [Development Guide][development-docs]. ## Credits The development of this project was originally funded and incubated by [Wayfair](https://github.com/wayfair-incubator). [ci]: https://github.com/plannigan/columbo/actions [pypi]: https://pypi.org/project/columbo/ [codecov]: https://codecov.io/gh/plannigan/columbo [mypy-home]: http://mypy-lang.org/ [black-home]: https://github.com/psf/black [columbo-docs]: https://plannigan.github.io/columbo/latest/ [development-docs]: https://plannigan.github.io/columbo/latest/development-guide/ %prep %autosetup -n columbo-0.13.0.post1 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-columbo -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Tue May 30 2023 Python_Bot - 0.13.0.post1-1 - Package Spec generated