From 6329caf4a0c18e71f319d0670b1f61c0d2890dbe Mon Sep 17 00:00:00 2001 From: Rottler Tamas Date: Sun, 11 Sep 2022 01:13:33 +0200 Subject: [PATCH] bugfix --- siteconf.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/siteconf.py b/siteconf.py index 5803d50..d5abb84 100755 --- a/siteconf.py +++ b/siteconf.py @@ -2,11 +2,12 @@ import os import re #from pprint import pprint -configuration = "{}/../site.conf".format(os.path.dirname(__file__)) +configuration = f"{os.path.dirname(__file__)}/../site.conf" site_conf = {} def read(): with open(configuration, "r") as cf: + site = None for line in cf: line = line.rstrip(); if r := re.match('#', line): @@ -18,6 +19,9 @@ def read(): site = r[1] site_conf[site] = {} elif r := re.match('([A-Za-z0-9_-]+)\s+(.+)', line): + if site == None: + print(f"configuration line before 1st block: {line}") + exit(1) site_conf[site][r[1]] = r[2] else: print(f"invalid line in site_conf: {line}")