A small library for rendering blueprints of projects
Project description
Hecto(graph)
A small library for rendering blueprints of projects.
- Works with local paths and git URLs.
- Your project can include any file and Hecto can dynamically replace values in any kind of text files.
- It generates a beautiful output and take care of not overwrite existing files, unless instructed to do so.
How to use
pip install hecto
from hecto import render_blueprint
# Create a project from a local path
render_blueprint('path/to/project/template', 'path/to/destination', context={"foo": "bar"})
# Or from a git URL.
# You can also use "gh:" as a shortcut of "https://github.com/"
# Or "gl:" as a shortcut of "https://gitlab.com/"
render_blueprint('https://github.com/jpsca/base36.git', 'path/to/destination')
render_blueprint('gh:jpsca/base36.git', 'path/to/destination')
render_blueprint('gl:jpsca/base36.git', 'path/to/destination')
How does it works
For each file, if the file has a .tt, .append, or .prepend extension,
even if the extension is not the last one, like *.tt.py, it will be treated
as a template file and rendered with the provided context.
.ttfiles will be rendered and saved to its destinations..appendfiles will be rendered and appended to its destinations..prependfiles will be rendered and prepended to its destinations.- Other files will be copied as-is.
To be able to work with regular Jinja files, the files are rendered using
[[ and ]] instead of {{ and }}; and [% and %] instead of {% and %}.
You can also use these delimiters in your file names.
If the files already exists and force is False, you will be asked for
confirmation before overwriting them.
API
render_blueprint(...)
def render_blueprint(
src: str | Path,
dst: str | Path,
context: dict[str, t.Any] | None = None,
*,
ignore: list[str] | None = None,
envops: dict | None = None,
force: bool = False,
) -> None:
"""
Arguments:
src:
Path of the folder to render from, or URL of a git-based repository.
dst:
Destination path for the blueprint.
context:
Context variables for Jinja2 templates.
ignore:
List of file patterns to ignore.
Default is (".DS_Store", "__pycache__", "*/__pycache__", "*/.DS_Store")
envops:
Jinja2 environment options.
force:
Whether to overwrite existing files without asking for confirmation.
"""
...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hecto-2.0.2.tar.gz.
File metadata
- Download URL: hecto-2.0.2.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
566ff4df30524bdb89775cce34ed1857fd76915bf1c24886118a57a4bda934a3
|
|
| MD5 |
1a7e8d0d80610450fdb1de40dd919380
|
|
| BLAKE2b-256 |
b50a82b93c628bb88e3901b25635df68a75d91bd389b49d4369bf01d069a7d56
|
File details
Details for the file hecto-2.0.2-py3-none-any.whl.
File metadata
- Download URL: hecto-2.0.2-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f227131487506439150ce26bef1c71ae0dd0b1e857e7eb807f01ea71bd4cfda2
|
|
| MD5 |
076db40c0bbf7627c13d86c123151a00
|
|
| BLAKE2b-256 |
65a52ea3f7f090ba0ed160c9cdb7f706edc2b35fdcdcb032c94bab36321cefbd
|