summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorLex Neva <github.com@lexneva.name>2018-04-09 20:07:33 -0400
committerLex Neva <github.com@lexneva.name>2018-04-09 20:15:56 -0400
commit24ed1de2de1201cd3a8988de4360da5d79981e16 (patch)
treef893a53523c1d910bbba3d4c19a227a3f40afc40 /bin
parentdfbe6f9c0f12be693454390f5e92bb3dd06661cf (diff)
generator for input format INX files
Diffstat (limited to 'bin')
-rwxr-xr-xbin/gen-input-inx50
1 files changed, 38 insertions, 12 deletions
diff --git a/bin/gen-input-inx b/bin/gen-input-inx
index c88931ee..5d65acca 100755
--- a/bin/gen-input-inx
+++ b/bin/gen-input-inx
@@ -1,19 +1,45 @@
#!/usr/bin/env python
-import sys
-
-sys.path.append('embroidermodder/experimental/python/binding')
+import sys, os
+from os.path import dirname
from libembroidery import *
+from jinja2 import Environment, FileSystemLoader, select_autoescape
+
+
+def build_environment():
+ template_dir = os.path.join(dirname(dirname(os.path.realpath(__file__))), "templates")
+
+ return Environment(
+ loader = FileSystemLoader(template_dir),
+ autoescape = select_autoescape(['xml'])
+ )
+
+
+def libembroidery_input_formats():
+ formatList = embFormatList_create()
+ curFormat = formatList
+ while(curFormat):
+ extension = embFormat_extension(curFormat)
+ description = embFormat_description(curFormat)
+ writerState = embFormat_readerState(curFormat)
+
+ if writerState.strip() and embFormat_type(curFormat) != EMBFORMAT_OBJECTONLY:
+ # extension includes the dot, so we'll remove it
+ yield extension[1:], description
+
+ curFormat = curFormat.next
+
+
+def main():
+ env = build_environment()
+ template = env.get_template('embroider_input.inx')
-formatList = embFormatList_create()
-curFormat = formatList
-while(curFormat):
- extension = embFormat_extension(curFormat)
- description = embFormat_description(curFormat)
- writerState = embFormat_readerState(curFormat)
+ for format, description in libembroidery_input_formats():
+ inx = template.render(format=format, description=description)
- if writerState.strip() and embFormat_type(curFormat) != EMBFORMAT_OBJECTONLY:
- print extension
+ with open("embroider_input_%s.inx" % format.upper(), 'w') as inx_file:
+ inx_file.write(inx)
- curFormat = curFormat.next
+if __name__ == "__main__":
+ sys.exit(main())