Skip to main content

pyqa makes it easier to write terminal based tools which ask the user a bunch of questions and then generate some configuration file based on the answers.

Usage

See /demos for some working examples.

pyqa provides single function, “ask”. It expects a set of questions given in a specific format. The following description is in YAML but you are free to use any other markup language as long as the output matches:

---
id: project_name # id to use at the template
q: Could you please give the project name? # question shown to the user
---
id: license
q: Please pick a license for your project?
choices: # if choices field is used, the user will see these as numbered choice
    - BSD
    - GPL
    - MIT
---
id: use_fizzler
q: Are you sure you want to use fizzler?
type: boolean -- this will accept either true or false answer and emits True/False

Note that keywords “Yes” and “No” seem to be converted to booleans by YAML. If you need to use those within choices, remember to use explicit form (ie. “Yes” instead of Yes).

After the user has finished answering “ask” will return the results in a format like this:

{'project_name': 'myproject', 'license': 'BSD', 'use_fizzler': True}

This format happens to be compatible with pystache (Python version of mustache) and no doubt with many other template engines. Just pass that data to your favorite engine, render and output the file somewhere. Voilá!

License

pyqa is available under MIT license. See LICENSE for more details.

Metadata

Release files for pyqa 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyqa 0.6.1
File Size Uploaded
pyqa-0.6.1.tar.gz 3.4 kB Details

Release files / pyqa-0.6.1.tar.gz

Download URL pyqa-0.6.1.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5f2f2395b639a64996ea5f60ee214a0230af73080c2935fe80944c1910d95b50
BLAKE2b-256 checksum
How to use checksums
f04711aa4b554e7f4732e97dcb998a334de783e2f7bc5926fe2dca9edab81e02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.6.1 This release

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page