confused-argparse
Note: VERY Beta, please wait for relase 1.0, since it is not even complete yet
"My standard" goto package for all my scripts/apps. Get argparse cli and configuration management in ONE LINE per parameter ;-)
With minimal boilerplate to handle:
- System, default and script level configuration management files with confuse using YAML
- OS enviroment does overwite settings from YAML
- Automagic argparse CLI creation and handling. Will overwrite all settings from YAML and os enviroment
- Setting the logging level
And:
- Creating the user default and script level YAML files at first run
- Optional: Saving state at exit
- and so much more ...
See:
-
confused-argparse THIS PACKAGE
-
venv for python virtual enviroment
-
confuse for handling configuration TOML files
-
argparse for creating a CLI parser
-
os.environ for reading enviroment variables
-
logging for logging to console
-
YAML for saving configuration data
Install:
- bash Shell:
$ python3 -m venv /path/to/new/virtual/environment
$ cd /path/to/new/virtual/environment
$ source ./bin/activate
$ pip install confused-argparse
First Excample
- PROGNAME.py:
import confused-argparse
ca=confused-argparse.set_var()
ca('input_file', str, 'Input file: Read from a local file')
Behind the scenes:
- If
input_filewas set in any of the YAML files, it will already have a value (Actually views of values, see confuse) - If
input_filewas set in the os enviroment,input_filewill be set accrodingly, overriting the YAML setting - If
--input_filewas set via the command line interface withpython3 PROGNAME.py --input_file my_file.txt, overriting the YAML and os enviroment setting to my_file.txt
In the bash shell:
$ python3 PROGNAME.py -h
usage: PROGNAME.py [-h] [--input_file INPUT_FILE]
optional arguments:
-h, --help show this help message and exit
--input_file INPUT_FILE Input file: Read from a local file
Next level:
- PROGNAME.py:
import confused-argparse
ca = confused-argparse.set_var(standard=True, description='My App: Solves a problem')
ca('input_file', str, 'Input file: Read from a local file', group='I/O')
Behind the scenes:
standard=True:- There are a number of standard argparse options already set, like
--verbose,--debug,--cron - Scans and read the values defined in the os enviroment, case independant, so also the enviroment variable
VERBOSE - For excample:
--verbosewill set the logging level to INFO
- There are a number of standard argparse options already set, like
description='My App: Solves a problem'- argparse will print this
group='I/O':- argparse will group options with this optional parameter
$ python3 PROGNAME.py -h
usage: PROGNAME.py [-h] [--input_file INPUT_FILE] [--list_defaults] [--debug] [--verbose] [--cron]
My App: Solves a problem
optional arguments:
-h, --help show this help message and exit
I/O:
--input_file INPUT_FILE Input file: Read from a local file [str]=''
Debug options:
Note: Will override
--list_defaults List: List all Vars in dict with there Defaults [bool]=False
--debug Debug: Logging DEBUG Messages (if not --cron, overrides --verbose) [bool]=False
--verbose Verbose: Logging INFO Messages (if not --cron) [bool]=False
--cron Called from Cronjob [bool]=False
Want more?
See Documentation. (Soon)
Pull Requests?
- Will be welcomed, when we reached the first beta
- Note: The confused-argparse github repository is still private/closed
DEV
-
Supports latest python3.7+
-
poetry for managing dependencies and build & publish to pypy
-
wemake-python-package for steting up a out of the box ready building enviroment
- Minor tweaks to
.gitignoreandMakefile
- Minor tweaks to
-
gnu make for runing tests and building docs
-
jupyter for quick tests and some development
-
sphinx and readthedocs.org for documentation
-
travis or Github Actions as the default CI
-
@dependabot for always up-to-date dependencies
-
mypy for optional static typing
-
pytest for testing
-
flake8 and wemake-python-styleguide for linting
License
(c) 2020 Nikolai von Krusenstiern
Credits
This project was generated with wemake-python-package. Current template version is: 69435b231f7f398474073ac6dd14868dd3edf2c1. See what is updated since then.
Metadata
Release files for confused-argparse 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| confused-argparse-0.2.2.tar.gz | 5.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| confused_argparse-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.5 kB
Release files / confused-argparse-0.2.2.tar.gz
| Download URL | confused-argparse-0.2.2.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fc4776b4653ed5b9e4d16d85434a5156f69f3df1bb74825c452825da250ba76c
|
|
BLAKE2b-256 checksum How to use checksums |
5ec21086814916a50f761ea17b8f02ea8e0c4315358d8da3896df13a58879358
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.10 CPython/3.8.5 Darwin/18.6.0
|
Release files / confused_argparse-0.2.2-py3-none-any.whl
| Download URL | confused_argparse-0.2.2-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7651aee55f7a39b35158f704ca96a7e96196ec89feecc8498dfa5c55960756a5
|
|
BLAKE2b-256 checksum How to use checksums |
0f08bf249334263194df04a523e3dc1554eed89c4574249ea22d9ba58b615039
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.10 CPython/3.8.5 Darwin/18.6.0
|