Skip to main content

A small library for rendering projects templates

Project description

Hecto(graph)

A library for rendering projects templates.

  • 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 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.

  • .tt files will be rendered and saved to its destinations.
  • .append files will be rendered and appended to its destinations.
  • .prepend files 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.
        envops:
            Jinja2 environment options.
        force:
            Whether to overwrite existing files without asking for confirmation.

    """
    ...

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

hecto-2.0.0.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hecto-2.0.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file hecto-2.0.0.tar.gz.

File metadata

  • Download URL: hecto-2.0.0.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.14

File hashes

Hashes for hecto-2.0.0.tar.gz
Algorithm Hash digest
SHA256 aabcaed6a83768bbf62229e769c38f6d1ecde86f786f509db21b9c66bde09b1e
MD5 8bec3492245756777467896cc032786d
BLAKE2b-256 c7b1ce9e7055e5acd30101368d1b3cd4d836ca1391246bc101a43fc5f7a8324b

See more details on using hashes here.

File details

Details for the file hecto-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: hecto-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.14

File hashes

Hashes for hecto-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3df108b65d640c63a0a8f3e88f147c3e785fc9ad3685ba3fc8deda8f9c454f12
MD5 3a0df53d656605683de6a2c50edb4b6e
BLAKE2b-256 ff0c7aa89754587ce60b586d6ee3f2240f26287f214d2b6976026e3b2b563416

See more details on using hashes here.

Supported by

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