mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-06-22 18:41:39 +02:00
jinja templating
This commit is contained in:
parent
4997a49eb7
commit
1e305b3c4c
2
.gitignore
vendored
2
.gitignore
vendored
@ -7,3 +7,5 @@ build/*
|
|||||||
.coverage
|
.coverage
|
||||||
.vscode/*
|
.vscode/*
|
||||||
__pycache__/*
|
__pycache__/*
|
||||||
|
.idea
|
||||||
|
venv
|
||||||
|
@ -7,6 +7,13 @@ import re
|
|||||||
|
|
||||||
from . import util
|
from . import util
|
||||||
from .settings import CACHE_DIR, CONF_DIR, MODULE_DIR
|
from .settings import CACHE_DIR, CONF_DIR, MODULE_DIR
|
||||||
|
from jinja2 import Template
|
||||||
|
|
||||||
|
|
||||||
|
def template_jinja(colors, input_file, output_file=None):
|
||||||
|
data = util.read_file_raw(input_file)
|
||||||
|
t = Template("".join(data))
|
||||||
|
util.save_file(t.render(**colors), output_file.replace(".jinja", ""))
|
||||||
|
|
||||||
|
|
||||||
def template(colors, input_file, output_file=None):
|
def template(colors, input_file, output_file=None):
|
||||||
@ -123,7 +130,11 @@ def every(colors, output_dir=CACHE_DIR):
|
|||||||
join = os.path.join # Minor optimization.
|
join = os.path.join # Minor optimization.
|
||||||
for file in [*os.scandir(template_dir),
|
for file in [*os.scandir(template_dir),
|
||||||
*os.scandir(template_dir_user)]:
|
*os.scandir(template_dir_user)]:
|
||||||
if file.name != ".DS_Store" and not file.name.endswith(".swp"):
|
if file.name == ".DS_Store" or file.name.endswith(".swp"):
|
||||||
|
continue
|
||||||
|
if file.name.endswith(".jinja"):
|
||||||
|
template_jinja(colors, file.path, join(output_dir, file.name))
|
||||||
|
else:
|
||||||
template(colors, file.path, join(output_dir, file.name))
|
template(colors, file.path, join(output_dir, file.name))
|
||||||
|
|
||||||
logging.info("Exported all files.")
|
logging.info("Exported all files.")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user