-
Notifications
You must be signed in to change notification settings - Fork 1
Home
A Python archetype to help me and others 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
Installing cookiecutter package on Ubuntu is very easy, visit the link to the cookiecutter documentation to learn how to install it. 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()
Errors, future updates, or beta configurations. Explain why and how it could break.
Explain the dos and don'ts of your app, what you take responsibility for, and where is the limit of its purpose.
Some extra help or clarification about the whole process. What you don't provide.
References, contact, or related repositories go here.