Commit 45a17bc7 authored by Jakub Jalowiec's avatar Jakub Jalowiec
Browse files

Fixing global dictionary processing

parent 2cabf6fb
...@@ -46,10 +46,8 @@ logging.info("File with default values: " + default_json) ...@@ -46,10 +46,8 @@ logging.info("File with default values: " + default_json)
with open(default_json, "r") as read_file: with open(default_json, "r") as read_file:
default = json.load(read_file) default = json.load(read_file)
global_values = default.get("global", dict()) global_values = default.get("global", dict())
for key in default: print("global_values: ")
if not key == "global": print(global_values)
for global_default_key in global_values:
default[key][global_default_key] = default[key].get(global_default_key, global_values[global_default_key])
with open(config_json, "r") as write_file: with open(config_json, "r") as write_file:
config = json.load(write_file) config = json.load(write_file)
...@@ -67,7 +65,9 @@ for directory, content in config.items(): ...@@ -67,7 +65,9 @@ for directory, content in config.items():
for template_name, files in content.items(): for template_name, files in content.items():
# if the key does not exist return an empty dictionary # if the key does not exist return an empty dictionary
dictionary = default.get(template_name, dict()) default_values = default.get(template_name, dict())
logging.info("Default values: ")
logging.info(str(default_values))
for target, custom_values in files.items(): for target, custom_values in files.items():
if(len(custom_values) > 0): if(len(custom_values) > 0):
logging.info("Filling up " + template_name + " with values from " + target + " dictionary and saving as " + directory + "/" + target + ".") logging.info("Filling up " + template_name + " with values from " + target + " dictionary and saving as " + directory + "/" + target + ".")
...@@ -80,9 +80,13 @@ for directory, content in config.items(): ...@@ -80,9 +80,13 @@ for directory, content in config.items():
else: else:
template_path = templates_dir + template_name template_path = templates_dir + template_name
t = templateEnv.get_template(template_path) t = templateEnv.get_template(template_path)
for key, value in custom_values.items(): logging.info("Custom values: ")
dictionary[key] = value logging.info(str(custom_values))
dictionary['directory'] = directory dictionary = global_values.copy()
dictionary.update(default_values)
dictionary.update(custom_values)
logging.info("Resulting gictionary: ")
logging.info(str(dictionary))
output = t.render(dictionary) output = t.render(dictionary)
with open(path + "/" + target, 'w') as filetowrite: with open(path + "/" + target, 'w') as filetowrite:
filetowrite.write(output) filetowrite.write(output)
......
...@@ -4,7 +4,7 @@ for test in */ ...@@ -4,7 +4,7 @@ for test in */
do do
cd "$test" cd "$test"
echo "Starting $test" echo "Starting $test"
python ../../fill-template.py -c ./config.json -d ./default.json -t ./ -l ERROR python ../../fill-template.py -c ./config.json -d ./default.json -t ./
# check return code of prepare-md.py # check return code of prepare-md.py
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
# prepare-md.py failed... # prepare-md.py failed...
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment