summaryrefslogtreecommitdiff
path: root/template.py
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-03-06 00:13:00 +0100
committerFlorian Dold <florian.dold@gmail.com>2017-03-06 00:13:00 +0100
commitdf95abeb7a4a967553b08b3f4bbc5065aa4c63e2 (patch)
tree8e1f50a8de40cef06874a13d0402980eefd530da /template.py
parent9d4d87c7dc97d3b53e5cbe0ee14fe36d1dd11b4a (diff)
downloadwww-df95abeb7a4a967553b08b3f4bbc5065aa4c63e2.tar.gz
www-df95abeb7a4a967553b08b3f4bbc5065aa4c63e2.tar.bz2
www-df95abeb7a4a967553b08b3f4bbc5065aa4c63e2.zip
make dirs if they don't exist
Diffstat (limited to 'template.py')
-rwxr-xr-xtemplate.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/template.py b/template.py
index 179e32a7..ed8f47eb 100755
--- a/template.py
+++ b/template.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# This file is in the public domain.
#
# This script runs the jinga2 templating engine on an input template-file
@@ -15,6 +15,7 @@ import gettext
import jinja2
import glob
import codecs
+import os
env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.dirname(__file__)),
extensions=["jinja2.ext.i18n"],
@@ -51,5 +52,6 @@ for in_file in glob.glob("*.j2"):
content = tmpl.render(lang=locale, url=url, self_localized=self_localized, url_localized=url_localized)
out_name = "./" + locale + "/" + in_file.rstrip(".j2")
+ os.makedirs("./" + locale, exist_ok=True)
with codecs.open(out_name, "w", "utf-8") as f:
f.write(content)