Skip to content

Commit

Permalink
env var for selection of template dir
Browse files Browse the repository at this point in the history
  • Loading branch information
halfow committed May 5, 2024
1 parent fff1701 commit 3bdb090
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions src/incubate/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
from importlib.metadata import version
from pathlib import Path
from random import choice
from os import environ
from functools import partial

from jinja2 import Environment, FileSystemLoader

template_path = Path(__file__).with_name("templates")
template_path = Path(environ.get(
"INCUBATE_TEMPLATE_PATH",
Path(__file__).with_name("templates"),
))

templates = Environment(
loader=FileSystemLoader(template_path),
Expand All @@ -23,31 +28,28 @@

projects = {project.stem: project for project in template_path.joinpath("projects").glob("*") if project.is_dir()}

with subprocess.Popen(["git", "config", "user.name"], stdout=subprocess.PIPE, encoding="utf-8") as process:
author = process.communicate()[0].strip()
# TODO: Add a fallback to the system username if git config is not set
run = partial(subprocess.run, encoding="utf-8", check=False, capture_output=True)
author = run(["git", "config", "user.name"]).stdout.strip()
email = run(["git", "config", "user.email"]).stdout.strip()

with subprocess.Popen(["git", "config", "user.email"], stdout=subprocess.PIPE, encoding="utf-8") as process:
email = process.communicate()[0].strip()
# TODO: Add a fallback to the system email if git config is not set

color = choice(["red", "green", "yellow", "blue", "magenta"])
ver = "v" + version("incubate")
logo = f"""
[grey0 on white]████████[/grey0 on white]
[grey0 on white]██ ██[/grey0 on white]
[grey0 on white]██▒▒▒▒ ██[/grey0 on white]
[grey0 on white]██▒▒▒▒▒▒ ▒▒▒▒██[/grey0 on white]
[grey0 on white]██ ▒▒▒▒ ▒▒▒▒▒▒██[/grey0 on white]
[grey0 on white]██ ▒▒▒▒██[/grey0 on white] ▄█ ▄▄ ▄▄ ▄█ ▄▄▄▄▀ ▄▄▄▄
[grey0 on white]██▒▒ ▒▒▒▒▒▒ ██[/grey0 on white] ██ █ █▀ ▀▄ ▄ █ █ █ █ ▀▀▀ █ ▐█ ▀
[grey0 on white]██ ▒▒▒▒▒▒▒▒▒▒ ██[/grey0 on white] ██ ██ █ █ ▀ █ █ █ ▀ ▄ █▄▄█ █ ▐█▀▀
[grey0 on white]██ ▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒██[/grey0 on white] ▐█ █ █ █ █▄ ▄▀ █ █ █ ▄▀ █ █ █ ▀█▄▄▄▀
[grey0 on white]██▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒██[/grey0 on white] ▐ █ █ █ ▀███▀ █▄ ▄█ ▀▀ █ ▀
[grey0 on white]██▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒██[/grey0 on white] █ ██ ▀▀▀ ▀
[grey0 on white]██▒▒ ██[/grey0 on white] ▀ [bold cyan]{ver:>30}[/bold cyan]
[grey0 on white]████ ████[/grey0 on white]
[grey0 on white]████████[/grey0 on white]
[grey0 on white]████████[/]
[grey0 on white]██ ██[/]
[grey0 on white]██▒▒▒▒ ██[/]
[grey0 on white]██▒▒▒▒▒▒ ▒▒▒▒██[/]
[grey0 on white]██ ▒▒▒▒ ▒▒▒▒▒▒██[/]
[grey0 on white]██ ▒▒▒▒██[/] ▄█ ▄▄ ▄▄ ▄█ ▄▄▄▄▀ ▄▄▄▄
[grey0 on white]██▒▒ ▒▒▒▒▒▒ ██[/] ██ █ █▀ ▀▄ ▄ █ █ █ █ ▀▀▀ █ ▐█ ▀
[grey0 on white]██ ▒▒▒▒▒▒▒▒▒▒ ██[/] ██ ██ █ █ ▀ █ █ █ ▀ ▄ █▄▄█ █ ▐█▀▀
[grey0 on white]██ ▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒██[/] ▐█ █ █ █ █▄ ▄▀ █ █ █ ▄▀ █ █ █ ▀█▄▄▄▀
[grey0 on white]██▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒██[/] ▐ █ █ █ ▀███▀ █▄ ▄█ ▀▀ █ ▀
[grey0 on white]██▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒██[/] █ ██ ▀▀▀ ▀
[grey0 on white]██▒▒ ██[/] ▀ [bold cyan]{ver:>30}[/bold cyan]
[grey0 on white]████ ████[/]
[grey0 on white]████████[/]
""".replace("▒", f"[{color}]█[/{color}]")

if __name__ == "__main__":
Expand Down

0 comments on commit 3bdb090

Please sign in to comment.