summaryrefslogtreecommitdiff
path: root/bin/gen-input-inx
diff options
context:
space:
mode:
authorLex Neva <lexelby@users.noreply.github.com>2018-04-15 19:40:46 -0400
committerGitHub <noreply@github.com>2018-04-15 19:40:46 -0400
commitb134a8dafad390f9c197d9439669db7001f4e8d8 (patch)
tree338fd72785708189dbbdf7cd06f4f0f8f90717d9 /bin/gen-input-inx
parent69c64bf3a7619b070768d68ccecf62bb97306864 (diff)
parent28e2250d8c937e1c7dcd114b6392b1a0f90251da (diff)
Merge pull request #145 from lexelby/lexelby-embroidery-input
input extension for all libembroidery-supported formats
Diffstat (limited to 'bin/gen-input-inx')
-rwxr-xr-xbin/gen-input-inx45
1 files changed, 45 insertions, 0 deletions
diff --git a/bin/gen-input-inx b/bin/gen-input-inx
new file mode 100755
index 00000000..918adfb9
--- /dev/null
+++ b/bin/gen-input-inx
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+
+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 = True
+ )
+
+
+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')
+
+ for format, description in libembroidery_input_formats():
+ inx = template.render(format=format, description=description)
+
+ with open("inx/embroider_input_%s.inx" % format.upper(), 'w') as inx_file:
+ inx_file.write(inx)
+
+
+if __name__ == "__main__":
+ sys.exit(main())