66 lines
2.4 KiB
Markdown
Raw Normal View History

# 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]:
```
2022-06-17 03:32:59 +02:00
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.
1. 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 where `we_use_underscores` instead.
```
.
└── update-firewall-source
├── examples
│   └── config.ini.example
├── requirements.in
├── requirements.txt
└── update-firewall-source.py
```
2. The `use_rich_logging` variable adds settings and examples that make ample use of the [Rich package](https://github.com/Textualize/rich/) for beautiful logging. You typically want this so it defaults to `yes`. Just hit `Enter` to confirm. The setting also adds necessary requirements.
3. With `use_config_ini` you're getting a boat load of functions, presets, variables and examples that integrate a config.ini file via the `configparser` module.
4. Lastly with `use_inflect` you're adding the `inflect` 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
```
2022-07-05 19:53:40 +02:00
You can see real-life example file content over at [examples/update-firewall-source](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.