Skip to main content

CLI Util for project code gen by jinja snippets

Project description

Koroviev

Code jinja template generator for structured projects :)

PyPI

Install

pip3 install koroviev

Help and init

For see commands list (man), type to console:

koroviev

For init, type to console (in project root folder):

koroviev init

Simple example: Create template and generate

Test project structure:

test_project
├── .koroviev_templates
├── .koroviev.toml
└── test_project
    ├── ... other ...
    ├── base.py
    └── cruds

For example, I add one template with name "crud" in my config file (.koroviev.toml) with two params

[setup]
language = 'python'
project_folder = 'test_project'
templates_folder = '.koroviev_templates'
template_extension = 'py'

[templates.crud]
comment = "my test template"
target_project_dir = "cruds/"
params = ["name", "table"]

For easy get auto generate templates folder structure

koroviev structure generate
Create template type folder 'unary': '/home/user/projects/test_project/.koroviev_templates/unary'...
Create template file 'test': '/home/user/projects/test_project/.koroviev_templates/unary/test.py'...

Structure after template folder generate:

test_project
├── .koroviev_templates
│   └── unary
│       └── crud.py
├── .koroviev.toml
└── test_project
    ├── ... other ...
    ├── base.py
    └── cruds

Fill crud.py with this code:

from test_project.base import BaseCRUD

class {{name|capitalize}}CRUD(BaseCRUD):
    table = "{{table}}"

Next, generate "test" crud by this template:

$ koroviev gen crud
Input name for generated file: test
Input 'name' value: test
Input 'table' value: test
Create file by template: /home/user/projects/test_project/test_project/cruds/test.py...

Result cruds/test.py:

from test_project.base import BaseCRUD

class TestCRUD(BaseCRUD):
    table = "test"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

koroviev-0.1.21.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distribution

koroviev-0.1.21-py3-none-any.whl (8.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page