summaryrefslogtreecommitdiff
path: root/lib/inx/utils.py
diff options
context:
space:
mode:
authorLex Neva <github.com@lexneva.name>2018-08-19 22:14:10 -0400
committerLex Neva <github.com@lexneva.name>2018-08-19 22:14:10 -0400
commit512c3411648b24505165d555a04e82ba689f8aed (patch)
tree3eb79343f2be57bace6e2f3e62cfe319d7fdb2f1 /lib/inx/utils.py
parenta4d588e392c734c9e32bf4c06b2403ca32e7f1e2 (diff)
integrate inx generation into ink/stitch proper
Diffstat (limited to 'lib/inx/utils.py')
-rw-r--r--lib/inx/utils.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/inx/utils.py b/lib/inx/utils.py
new file mode 100644
index 00000000..da0a4614
--- /dev/null
+++ b/lib/inx/utils.py
@@ -0,0 +1,26 @@
+import os
+from os.path import dirname
+from jinja2 import Environment, FileSystemLoader
+
+from ..i18n import translation as inkstitch_translation
+
+
+_top_path = dirname(dirname(dirname(os.path.realpath(__file__))))
+inx_path = os.path.join(_top_path, "inx")
+template_path = os.path.join(_top_path, "templates")
+
+def build_environment():
+ env = Environment(
+ loader = FileSystemLoader(template_path),
+ autoescape = True,
+ extensions=['jinja2.ext.i18n']
+ )
+
+ env.install_gettext_translations(inkstitch_translation)
+
+ return env
+
+def write_inx_file(name, contents):
+ inx_file_name = "inkstitch_%s.inx" % name
+ with open(os.path.join(inx_path, inx_file_name), 'w') as inx_file:
+ print >> inx_file, contents