diff options
| author | Lex Neva <lexelby@users.noreply.github.com> | 2018-06-17 21:32:24 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-06-17 21:32:24 -0400 |
| commit | d3866deb4a686f96265a76f670db1386e9b459ba (patch) | |
| tree | 8a409901a19acc8f14252f430807c7964e62aadc /bin/gen-output-inx | |
| parent | 564f15cd55954afde358eed24809632e6ea9c2d7 (diff) | |
| parent | 0659bc294e943bcaa10f63966e667003623e6da4 (diff) | |
Merge pull request #198 from lexelby/lexelby-output-extension
output extensions
Diffstat (limited to 'bin/gen-output-inx')
| -rwxr-xr-x | bin/gen-output-inx | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/bin/gen-output-inx b/bin/gen-output-inx new file mode 100755 index 00000000..f167dbee --- /dev/null +++ b/bin/gen-output-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_output_formats(): + formatList = embFormatList_create() + curFormat = formatList + while(curFormat): + extension = embFormat_extension(curFormat) + description = embFormat_description(curFormat) + writer_state = embFormat_writerState(curFormat) + + if writer_state.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_output.inx') + + for format, description in libembroidery_output_formats(): + inx = template.render(format=format, description=description) + + with open("inx/inkstitch_output_%s.inx" % format.upper(), 'w') as inx_file: + inx_file.write(inx) + + +if __name__ == "__main__": + sys.exit(main()) |
