generate_config: Enable 'do' j2 extension 57/52957/1
authorAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Thu, 1 Mar 2018 19:57:23 +0000 (20:57 +0100)
committerAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Thu, 1 Mar 2018 19:58:16 +0000 (20:58 +0100)
'do' is useful to avoid hacks like {% set _ = x.update(...) %}.
Instead: {% do x.update(...) %}.

[1] http://jinja.pocoo.org/docs/2.10/extensions/

Change-Id: I886beb97e0383ba11b81aa21cf12b11ebc4b05b2
Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
config/utils/generate_config.py

index f1c395a..6adbb44 100755 (executable)
@@ -23,7 +23,10 @@ PARSER.add_argument("--yaml", "-y", type=str, required=True)
 PARSER.add_argument("--jinja2", "-j", type=str, required=True)
 ARGS = PARSER.parse_args()
 
-ENV = Environment(loader=FileSystemLoader(os.path.dirname(ARGS.jinja2)))
+ENV = Environment(
+    loader=FileSystemLoader(os.path.dirname(ARGS.jinja2)),
+    extensions=['jinja2.ext.do']
+)
 gen_config_lib.load_custom_filters(ENV)
 
 # Run `eyaml decrypt` on the whole file, but only if PDF data is encrypted