This is a code repo template for code using a command line interface
The code does not have functional use. However, the template covers:
- Code directory layout
- Command line interface using "Argh"
- Progressbar / Parallel processing using progressbar, "tqdm"
- Testing using "pytest"
- Requirements file
- Documentation
Starting with this template should make an initial code repo setup faster and easier.
This guide assumes you are using windows, the instructions should be similar for other operating systems. Its assumed that you are using vscode and have python installed.
- Download/clone the code (where this readme is located)
- Open vscode and from within vscode open the main folder with the code
- Open a new terminal
- Press: Ctrl+Shift+P and type "terminal"
- Select: Python: create terminal
- In the new terminal create a new environment and activate it
- 'python -m venv .venv'
- If prompted, click yes to use the new virtual environment
- If not prompted, click the python/environment button i the bottom left of the blue ribbon and select the new environment
- Ensure that the correct environment is activated, you should see the following in the terminal
([env_name]) folderpath]>
(.venv) C:\Users\testuser>
- Install the requirements file.
- Ensure that you are in the correct directory and using the "[env_name]" environment
- Run:
pip install -r requirements.txt
- Done! you can now move on to the next section on how to use the code
- Pre-requisites
- Ensure that you have followed all the steps to Install code
- Ensure that you have activated the correct virtual environment.
- Ensure that the dependencies in requirements.txt are installed.
- Ensure that you have navigated to the directory containing this code.
Use the command line
- Get help
python main.py -h
- Get version information
python main.py version
python main.py version -h
- Run the main entry point
python main.py entry 5
python main.py entry 5 --y 10
python main.py entry -h
Use the command line
- Run all tests
pytest
- Run all tests in specific folder
pytest tests/unit
- Run all tests in specific test file
pytest tests/unit/src/test_myprojectcode.py
- Run single specific test in file
pytest tests/unit/src/test_myprojectcode.py::test_is_even
Describe the folder structure and file content
-
Template code - The main directory of the template
-
src - The source code
- __ init __.py - Empty init file
- about.py - File with version information and change log
- myprojectcode.py - The main project code file
- utils.py - Utility functions and methods used by the main
-
tests - Code for tests
-
integration - Code for integration tests
-
src - Integration tests for the code in src
- __ init __.py - Empty init file
- __ init __.py - Empty init file
-
-
unit - Code for unit tests
-
src - Unit tests for the code in src
- __ init __.py - Empty init file
- test_myprojectcode.py - unit tests
- __ init __.py - Empty init file
-
- __ init __.py - Empty init file
- conftest.py - File containing pytest fixtures and configurations
-
- main.py - The entry point of the code
- README.md - The project documentation
- requirements.txt - The code dependencies/requirements
- template_log.log - The output log of the code
-