From 12caf5a526eb0f72627f6849ba96895dd505ec18 Mon Sep 17 00:00:00 2001 From: Andreas HABEGGER Date: Sun, 19 Nov 2023 22:36:34 +0100 Subject: FC: YAML multifile read; Added global variable to configure properties file --- sitegen/site.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sitegen/site.py b/sitegen/site.py index e2b20c0..6139d1c 100644 --- a/sitegen/site.py +++ b/sitegen/site.py @@ -34,6 +34,8 @@ import sitegen.i18nfix as i18nfix from sitegen.timeutil import time_rfc822, time_now, conv_date_rfc822 +PROPERTIES_YML = "properties.yml" + def html2text(html_str): class extractText(html.parser.HTMLParser): def __init__(self): @@ -195,9 +197,16 @@ class SiteGenerator: env.filters["extract_body"] = extract_body env.newstyle_gettext = True self.env = env + # NOTE : read-in properties.yml and afterwards all *.yml in properties.d + properties = {} yaml = YAML(typ="safe") - site_configfile = self.root / "www.yml" - self.config = yaml.load(site_configfile) + yaml.preserve_quotes = True + properties.update(yaml.load(self.root/PROPERTIES_YML)) + properties_dir = PROPERTIES_YML.removesuffix('.yml') + '.d' + for filepath in Path(self.root/properties_dir).glob('*.yml'): + properties.update(yaml.load(filepath)) + self.config = properties + self.baseurl = os.environ.get("BASEURL") if not self.baseurl: self.baseurl = self.config["siteconf"].get("baseurl") -- cgit v1.2.3