Naive Python template
Run it
Execute this template like so:
cookiecutter https://quico.space/Quico/py-cookiecutter-templates.git --directory 'python-naive'
Cookiecutter interactively prompts you for the following info, here with example answers:
project_slug [project-slug]: dockerhost-firewalld-update
Select rich_logging:
1 - yes
2 - no
Choose from 1, 2 [1]:
Select uses_config_ini:
1 - yes
2 - no
Choose from 1, 2 [1]:
Done, directory structure and files for your next Python project are ready for you to hit the ground running.
Explanation and terminology
Your three answers translate as follows into rendered files.
- The
project_slug
is used as a directory name for your Python project where spaces and underscores are replaced-with-dashes. It's also used for a few example variables wherewe_use_underscores
instead.. └── dockerhost-firewalld-update ├── dockerhost-firewalld-update.py ├── examples │ └── config.ini.example ├── requirements.in └── requirements.txt
- The
rich_logging
variable adds settings and examples that make ample use of the Rich package for beautiful logging. You typically want this so it defaults toyes
. Just hitEnter
to confirm. The setting also adds necessary requirements. - With
uses_config_ini
you're getting a boat load of functions, presets, variables and examples that integrate a config.ini file via theconfigparser
module.
Result
Enable Rich and configparser
Above example of a Python project with Rich and configparser
enabled will give you a directory structure like this:
.
└── dockerhost-firewalld-update
├── dockerhost-firewalld-update.py
├── examples
│ └── config.ini.example
├── requirements.in
└── requirements.txt
You can see real-life example file content over at examples/rich-and-config. Cookiecutter has generated all necessary dependencies with pinned versions and a rich-and-config.py
script file to get you started.