-
Notifications
You must be signed in to change notification settings - Fork 1
Home
A Python archetype to help developers begin developing a coding project.
A Python archetype to help developers begin developing a coding project. The archetype follows a customizable project structure using cookiecutter as a template generator.
A command-line utility that creates projects from cookiecutters (project templates), e.g. creating a Python package project from a Python package project template.
Visit these links to learn more about cookiecutter. Documentation: https://cookiecutter.readthedocs.io/ GitHub: https://github.com/cookiecutter/cookiecutter
To create the project from the template you need to install cookiecutter and follow these instructions.
Installing cookiecutter package on Ubuntu is very easy, you can simply run the next command to install it.
pip install cookiecutter
Visit the link to the cookiecutter documentation to learn more about the installation:
Install cookiecutter
To generate a custom project from the template, follow these steps:
-
- Navigate to the path where you desire to generate the project folder.
-
- Run the cookiecutter command followed by the repository URL.
cookiecutter https://github.com/charlstown/py-template.git
-
- Fill out the form in the console and the project will be generated at the end.
After generating your first project, you can do a test run.
(optional) Execute in the console this command to see the possible arguments.
python code/main.py -h
Run the code by the next command.
python code/main.py
The output should be something like this:
2022-11-02 19:51:36 [INFO] main.py - run (L101): [Initializing MyAwesomeProject]
2022-11-02 19:51:36 [INFO] exampleclass.py - public_method (L41): This "public_method" is a method from ExampleClass.
2022-11-02 19:51:36 [INFO] exampleclass.py - _private_method (L34): This "_private_method" is a method from ExampleClass.
2022-11-02 19:51:36 [INFO] exampleclass.py - public_method (L43): This "Hello World" is a global variable.
2022-11-02 19:51:36 [INFO] main.py - run (L110): [Exiting MyAwesomeProject app.Total elapsed time: 00:00:00.]
We recommend starting coding your project with these tips:
You can start creating your custom classes using the class "exampleclass.py" as the template.
class ExampleClass:
"""
Example class as a template for other classes. Explain the use of this class here.
"""
You can instance your custom classes in the "main.py" file the same way we instanced ExampleClass.
# Global instances
self.example_class = ExampleClass(logger=logger, config=config)
You can start orchestrating your methods from the "run" method from the App class in the "main.py" file.
# >>> Start your code here <<<
self.example_class.public_method()
The main branch has been tested and before any push, we make sure everything is working fine. Feel fre to open a new issue if you see the archetype is no working correctly or any additional requirement is needed.
This is an archetype template done in Python using the library cookiecutter. This template is intended to help coding in python.
Do not use this template for any commercial nor redistribution purpose. Actually, the use of such tool might be allowed for open-source or private projects.
This repository does provide the required installation instructions to install it by your own. Feel free to contact me on https://carlosgrande.me/contact-me-carlos-grande/
This project is based on the Python project structure from this post:
Interested links: