mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-16 04:02:15 +00:00
1a8e49d9ba
Allows making man1/conky.1 in builds reproducible. See https://reproducible-builds.org/ for why this is good and https://reproducible-builds.org/specs/source-date-epoch/ for the definition of this variable. Also use UTC to be independent of timezone.
47 lines
1.1 KiB
Python
Executable File
47 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import sys
|
|
import os
|
|
import time
|
|
import yaml
|
|
import datetime
|
|
|
|
base_path = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
with open(os.path.join(base_path, "config_settings.yaml")) as file:
|
|
config_settings = yaml.safe_load(file)
|
|
|
|
with open(os.path.join(base_path, "variables.yaml")) as file:
|
|
variables = yaml.safe_load(file)
|
|
|
|
with open(os.path.join(base_path, "lua.yaml")) as file:
|
|
lua = yaml.safe_load(file)
|
|
|
|
build_date = datetime.datetime.fromtimestamp(
|
|
int(os.environ.get('SOURCE_DATE_EPOCH', time.time())),
|
|
tz=datetime.timezone.utc,
|
|
)
|
|
data = {
|
|
"config_settings": config_settings,
|
|
"variables": variables,
|
|
"lua": lua,
|
|
"date": build_date.date().isoformat(),
|
|
"copyright_year": build_date.year,
|
|
}
|
|
|
|
from jinja2 import Environment, FileSystemLoader, select_autoescape
|
|
|
|
|
|
def reverse_format(param_list, format_string):
|
|
return format_string.format(param_list)
|
|
|
|
|
|
env = Environment(
|
|
loader=FileSystemLoader("."),
|
|
autoescape=select_autoescape(),
|
|
)
|
|
env.filters["reverse_format"] = reverse_format
|
|
|
|
template = env.get_template(sys.argv[1])
|
|
print(template.render(data))
|