Skip to content

API

ogc template tag helpers

LINE_SEP module-attribute

LINE_SEP = '-'

run

run(
    exe: str, *args: str | None, **kwargs: bool | None
) -> str

Converts a sh.Command to its string reprsentation

Source code in ogc/templatetags.py
def run(exe: str, *args: str | None, **kwargs: bool | None) -> str:
    """Converts a `sh.Command` to its string reprsentation"""
    cmd = sh.Command(exe)
    kwargs_parsed = {k: v for k, v in kwargs.items() if not k.startswith("_ogc")}
    out = str(cmd.bake(*args, **kwargs_parsed))
    return out

header

header(msg: str) -> str

Prints header string

Source code in ogc/templatetags.py
def header(msg: str) -> str:
    """Prints header string"""
    out = [hr(), f"echo {msg}", hr()]
    return "\n".join(out)

hr

hr() -> str

Prints seperator

Source code in ogc/templatetags.py
def hr() -> str:
    """Prints seperator"""
    return f"echo {LINE_SEP * 79}"