summaryrefslogtreecommitdiff
path: root/lib/inx/extensions.py
diff options
context:
space:
mode:
authorLex Neva <github.com@lexneva.name>2018-08-25 11:47:48 -0400
committerLex Neva <github.com@lexneva.name>2018-08-25 11:47:48 -0400
commit11d3cea80caeb9738a2eb02473801487c2acba3b (patch)
tree13510f23e5041628ef96997f14d852482ff04000 /lib/inx/extensions.py
parentc5bd1878846c17309c99ad7554d4645088de9629 (diff)
parent6a16e90081e619eac5921bd8614c0c46dc83f852 (diff)
Merge remote-tracking branch 'origin/master' into simulator-timeline
Diffstat (limited to 'lib/inx/extensions.py')
-rwxr-xr-xlib/inx/extensions.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/inx/extensions.py b/lib/inx/extensions.py
new file mode 100755
index 00000000..d1a0c7f3
--- /dev/null
+++ b/lib/inx/extensions.py
@@ -0,0 +1,43 @@
+import pyembroidery
+
+from .utils import build_environment, write_inx_file
+from .outputs import pyembroidery_output_formats
+from ..extensions import extensions, Input, Output
+from ..commands import LAYER_COMMANDS, OBJECT_COMMANDS, GLOBAL_COMMANDS, COMMANDS
+
+
+def layer_commands():
+ # We purposefully avoid using commands.get_command_description() here. We
+ # want to call _() on the description inside the actual template so that
+ # we use the translation language selected in build_environment().
+ return [(command, COMMANDS[command]) for command in LAYER_COMMANDS]
+
+
+def global_commands():
+ return [(command, COMMANDS[command]) for command in GLOBAL_COMMANDS]
+
+
+def object_commands():
+ return [(command, COMMANDS[command]) for command in OBJECT_COMMANDS]
+
+
+def pyembroidery_debug_formats():
+ for format in pyembroidery.supported_formats():
+ if 'writer' in format and format['category'] != 'embroidery':
+ yield format['extension'], format['description']
+
+
+def generate_extension_inx_files():
+ env = build_environment()
+
+ for extension in extensions:
+ if extension is Input or extension is Output:
+ continue
+
+ name = extension.name()
+ template = env.get_template('%s.inx' % name)
+ write_inx_file(name, template.render(formats=pyembroidery_output_formats(),
+ debug_formats=pyembroidery_debug_formats(),
+ layer_commands=layer_commands(),
+ object_commands=object_commands(),
+ global_commands=global_commands()))