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]: update-firewall-source
Select use_rich_logging:
1 - yes
2 - no
Choose from 1, 2 [1]:
Select use_config_ini:
1 - yes
2 - no
Choose from 1, 2 [1]:
Select use_inflect:
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 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.. └── update-firewall-source ├── examples │ └── config.ini.example ├── requirements.in ├── requirements.txt └── update-firewall-source.py
-
The
use_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
use_config_ini
you're getting a boat load of functions, presets, variables and examples that integrate a config.ini file via theconfigparser
module. -
Lastly with
use_inflect
you're adding theinflect
module which does grammatically correct text rendering such as plural and singular. It also includes a few examples.
Result
Enable Rich, configparser and inflect
Above example of a Python project with all of Rich, configparser
and inflect
enabled will give you a directory structure like this:
.
└── update-firewall-source
├── examples
│ └── config.ini.example
├── requirements.in
├── requirements.txt
└── update-firewall-source.py
You can see real-life example file content over at examples/update-firewall-source. Cookiecutter has generated all necessary dependencies with pinned versions and a update-firewall-source.py
script file to get you started.