summaryrefslogtreecommitdiffstats
path: root/config/utils
diff options
context:
space:
mode:
authorAlexandru Avadanii <Alexandru.Avadanii@enea.com>2018-03-05 17:58:01 +0100
committerAlexandru Avadanii <Alexandru.Avadanii@enea.com>2018-03-05 17:58:03 +0100
commit148a9edf9839cd8aa3d1295cb79f408819ad4cd1 (patch)
treeee9c43274d20fd416104bb2e78ff3c188329097a /config/utils
parent7f60d8840468aacb240dc342060d1d164d3c38ba (diff)
generate_config: minor code formatting updates
Change-Id: If0ee12287f4257f2de315bd6ad82edb709e24492 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
Diffstat (limited to 'config/utils')
-rwxr-xr-xconfig/utils/generate_config.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/config/utils/generate_config.py b/config/utils/generate_config.py
index f45f7888..11d42caf 100755
--- a/config/utils/generate_config.py
+++ b/config/utils/generate_config.py
@@ -18,6 +18,8 @@ import yaml
from jinja2 import Environment, FileSystemLoader
+LOADER = yaml.CSafeLoader if yaml.__with_libyaml__ else yaml.SafeLoader
+
PARSER = argparse.ArgumentParser()
PARSER.add_argument("--yaml", "-y", type=str, required=True)
PARSER.add_argument("--jinja2", "-j", type=str, required=True, action='append')
@@ -26,7 +28,6 @@ PARSER.add_argument("--batch", "-b", action='store_true')
PARSER.add_argument("--verbose", "-v", action='count')
ARGS = PARSER.parse_args()
-LOADER = yaml.CSafeLoader if yaml.__with_libyaml__ else yaml.SafeLoader
ARGS.jinja2 = [abspath(x) for x in ARGS.jinja2]
logging.basicConfig()
@@ -72,8 +73,9 @@ for _j2 in ARGS.jinja2:
# Render template and write generated conf to file or stdout
if ARGS.batch:
if _j2.endswith('.j2'):
+ destination_file = _j2[:-3] # Trim '.j2' suffix
LOGGER.info('Parsing {}'.format(_j2))
- with open(_j2[:-3], 'w') as _:
+ with open(destination_file, 'w') as _:
_.write(OUTPUT)
else:
LOGGER.warn('Skipping {}, name does not end in ".j2"'.format(_j2))