From 512c3411648b24505165d555a04e82ba689f8aed Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sun, 19 Aug 2018 22:14:10 -0400 Subject: integrate inx generation into ink/stitch proper --- bin/gen-input-inx | 36 ------------------------------------ bin/gen-output-format-option-list | 14 -------------- bin/gen-output-inx | 36 ------------------------------------ bin/gen-zip-inx | 35 ----------------------------------- bin/generate-inx-files | 10 ++++++++++ inx/inkstitch_attach_commands.inx | 22 ---------------------- inx/inkstitch_convert_to_satin.inx | 17 ----------------- inx/inkstitch_embroider.inx | 30 ------------------------------ inx/inkstitch_flip.inx | 17 ----------------- inx/inkstitch_input_100.inx | 17 ----------------- inx/inkstitch_input_10O.inx | 17 ----------------- inx/inkstitch_input_BRO.inx | 17 ----------------- inx/inkstitch_input_DSB.inx | 17 ----------------- inx/inkstitch_input_DST.inx | 17 ----------------- inx/inkstitch_input_DSZ.inx | 17 ----------------- inx/inkstitch_input_EMD.inx | 17 ----------------- inx/inkstitch_input_EXP.inx | 17 ----------------- inx/inkstitch_input_INB.inx | 17 ----------------- inx/inkstitch_input_JEF.inx | 17 ----------------- inx/inkstitch_input_KSM.inx | 17 ----------------- inx/inkstitch_input_PEC.inx | 17 ----------------- inx/inkstitch_input_PES.inx | 17 ----------------- inx/inkstitch_input_SEW.inx | 17 ----------------- inx/inkstitch_input_SHV.inx | 17 ----------------- inx/inkstitch_input_STX.inx | 17 ----------------- inx/inkstitch_input_TAP.inx | 17 ----------------- inx/inkstitch_input_TBF.inx | 17 ----------------- inx/inkstitch_input_U01.inx | 17 ----------------- inx/inkstitch_input_VP3.inx | 17 ----------------- inx/inkstitch_input_XXX.inx | 17 ----------------- inx/inkstitch_install.inx | 17 ----------------- inx/inkstitch_layer_commands.inx | 19 ------------------- inx/inkstitch_output_DST.inx | 19 ------------------- inx/inkstitch_output_EXP.inx | 19 ------------------- inx/inkstitch_output_JEF.inx | 19 ------------------- inx/inkstitch_output_PEC.inx | 19 ------------------- inx/inkstitch_output_PES.inx | 19 ------------------- inx/inkstitch_output_VP3.inx | 19 ------------------- inx/inkstitch_output_ZIP.inx | 31 ------------------------------- inx/inkstitch_params.inx | 17 ----------------- inx/inkstitch_print.inx | 17 ----------------- inx/inkstitch_simulate.inx | 17 ----------------- lib/extensions/__init__.py | 10 ++++++++++ lib/extensions/base.py | 5 +++++ lib/inx/__init__.py | 1 + lib/inx/extensions.py | 21 +++++++++++++++++++++ lib/inx/generate.py | 8 ++++++++ lib/inx/inputs.py | 18 ++++++++++++++++++ lib/inx/outputs.py | 18 ++++++++++++++++++ lib/inx/utils.py | 26 ++++++++++++++++++++++++++ messages.po | 8 ++++---- requirements.txt | 1 + templates/convert_to_satin.inx | 17 +++++++++++++++++ templates/embroider.inx | 28 ++++++++++++++++++++++++++++ templates/embroider_input.inx | 17 ----------------- templates/embroider_output.inx | 19 ------------------- templates/embroider_zip_output.inx | 21 --------------------- templates/flip.inx | 17 +++++++++++++++++ templates/input.inx | 17 +++++++++++++++++ templates/install.inx | 17 +++++++++++++++++ templates/layer_commands.inx | 19 +++++++++++++++++++ templates/object_commands.inx | 22 ++++++++++++++++++++++ templates/output.inx | 19 +++++++++++++++++++ templates/params.inx | 17 +++++++++++++++++ templates/print.inx | 17 +++++++++++++++++ templates/simulate.inx | 17 +++++++++++++++++ templates/zip.inx | 21 +++++++++++++++++++++ 67 files changed, 350 insertions(+), 857 deletions(-) delete mode 100755 bin/gen-input-inx delete mode 100755 bin/gen-output-format-option-list delete mode 100755 bin/gen-output-inx delete mode 100755 bin/gen-zip-inx create mode 100755 bin/generate-inx-files delete mode 100644 inx/inkstitch_attach_commands.inx delete mode 100644 inx/inkstitch_convert_to_satin.inx delete mode 100644 inx/inkstitch_embroider.inx delete mode 100644 inx/inkstitch_flip.inx delete mode 100644 inx/inkstitch_input_100.inx delete mode 100644 inx/inkstitch_input_10O.inx delete mode 100644 inx/inkstitch_input_BRO.inx delete mode 100644 inx/inkstitch_input_DSB.inx delete mode 100644 inx/inkstitch_input_DST.inx delete mode 100644 inx/inkstitch_input_DSZ.inx delete mode 100644 inx/inkstitch_input_EMD.inx delete mode 100644 inx/inkstitch_input_EXP.inx delete mode 100644 inx/inkstitch_input_INB.inx delete mode 100644 inx/inkstitch_input_JEF.inx delete mode 100644 inx/inkstitch_input_KSM.inx delete mode 100644 inx/inkstitch_input_PEC.inx delete mode 100644 inx/inkstitch_input_PES.inx delete mode 100644 inx/inkstitch_input_SEW.inx delete mode 100644 inx/inkstitch_input_SHV.inx delete mode 100644 inx/inkstitch_input_STX.inx delete mode 100644 inx/inkstitch_input_TAP.inx delete mode 100644 inx/inkstitch_input_TBF.inx delete mode 100644 inx/inkstitch_input_U01.inx delete mode 100644 inx/inkstitch_input_VP3.inx delete mode 100644 inx/inkstitch_input_XXX.inx delete mode 100644 inx/inkstitch_install.inx delete mode 100644 inx/inkstitch_layer_commands.inx delete mode 100644 inx/inkstitch_output_DST.inx delete mode 100644 inx/inkstitch_output_EXP.inx delete mode 100644 inx/inkstitch_output_JEF.inx delete mode 100644 inx/inkstitch_output_PEC.inx delete mode 100644 inx/inkstitch_output_PES.inx delete mode 100644 inx/inkstitch_output_VP3.inx delete mode 100644 inx/inkstitch_output_ZIP.inx delete mode 100644 inx/inkstitch_params.inx delete mode 100644 inx/inkstitch_print.inx delete mode 100644 inx/inkstitch_simulate.inx create mode 100644 lib/inx/__init__.py create mode 100755 lib/inx/extensions.py create mode 100644 lib/inx/generate.py create mode 100755 lib/inx/inputs.py create mode 100644 lib/inx/outputs.py create mode 100644 lib/inx/utils.py create mode 100644 templates/convert_to_satin.inx create mode 100644 templates/embroider.inx delete mode 100644 templates/embroider_input.inx delete mode 100644 templates/embroider_output.inx delete mode 100644 templates/embroider_zip_output.inx create mode 100644 templates/flip.inx create mode 100644 templates/input.inx create mode 100644 templates/install.inx create mode 100644 templates/layer_commands.inx create mode 100644 templates/object_commands.inx create mode 100644 templates/output.inx create mode 100644 templates/params.inx create mode 100644 templates/print.inx create mode 100644 templates/simulate.inx create mode 100644 templates/zip.inx diff --git a/bin/gen-input-inx b/bin/gen-input-inx deleted file mode 100755 index ae32b43f..00000000 --- a/bin/gen-input-inx +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env python - -import sys, os -from os.path import dirname -import pyembroidery -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 pyembroidery_input_formats(): - for format in pyembroidery.supported_formats(): - if 'reader' in format and format['category'] == 'embroidery': - yield format['extension'], format['description'] - - -def main(): - env = build_environment() - template = env.get_template('embroider_input.inx') - - for format, description in pyembroidery_input_formats(): - inx = template.render(format=format, description=description) - - with open("inx/inkstitch_input_%s.inx" % format.upper(), 'w') as inx_file: - print >> inx_file, inx - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/bin/gen-output-format-option-list b/bin/gen-output-format-option-list deleted file mode 100755 index 28a83976..00000000 --- a/bin/gen-output-format-option-list +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env python - -import sys -import pyembroidery - -formats = [format for format in pyembroidery.supported_formats() if 'writer' in format] -formats.sort(key=lambda format: (format['category'] != 'embroidery', format['extension'])) - -for format in formats: - tag = "" - if format['category'] != 'embroidery': - tag = " [DEBUG]" - - print '<_option value="%s">%s(%s)%s' % (format['extension'], format['description'], format['extension'].upper(), tag) diff --git a/bin/gen-output-inx b/bin/gen-output-inx deleted file mode 100755 index fbe2ad55..00000000 --- a/bin/gen-output-inx +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env python - -import sys, os -from os.path import dirname -import pyembroidery -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 pyembroidery_output_formats(): - for format in pyembroidery.supported_formats(): - if 'writer' in format and format['category'] == 'embroidery': - yield format['extension'], format['description'] - - -def main(): - env = build_environment() - template = env.get_template('embroider_output.inx') - - for format, description in pyembroidery_output_formats(): - inx = template.render(format=format, description=description) - - with open("inx/inkstitch_output_%s.inx" % format.upper(), 'w') as inx_file: - print >> inx_file, inx - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/bin/gen-zip-inx b/bin/gen-zip-inx deleted file mode 100755 index 40948786..00000000 --- a/bin/gen-zip-inx +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env python - -import sys, os -from os.path import dirname -import pyembroidery -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 pyembroidery_output_formats(): - for format in pyembroidery.supported_formats(): - if 'writer' in format and format['category'] == 'embroidery': - yield format['extension'], format['description'] - - -def main(): - env = build_environment() - template = env.get_template('embroider_zip_output.inx') - - inx = template.render(formats=pyembroidery_output_formats()) - - with open("inx/inkstitch_output_ZIP.inx", 'w') as inx_file: - inx_file.write(inx) - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/bin/generate-inx-files b/bin/generate-inx-files new file mode 100755 index 00000000..f7b7a801 --- /dev/null +++ b/bin/generate-inx-files @@ -0,0 +1,10 @@ +#!/usr/bin/env python + +import sys +import os +from os.path import dirname + +sys.path.append(os.path.join(dirname(dirname(__file__)))) +from lib.inx import generate_inx_files + +generate_inx_files() diff --git a/inx/inkstitch_attach_commands.inx b/inx/inkstitch_attach_commands.inx deleted file mode 100644 index bba8602b..00000000 --- a/inx/inkstitch_attach_commands.inx +++ /dev/null @@ -1,22 +0,0 @@ - - - <_name>Attach Commands - org.inkstitch.commands - inkstitch.py - inkex.py - false - false - false - false - false - object_commands - - all - - - - - - diff --git a/inx/inkstitch_convert_to_satin.inx b/inx/inkstitch_convert_to_satin.inx deleted file mode 100644 index d71b2081..00000000 --- a/inx/inkstitch_convert_to_satin.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>Convert Line to Satin - org.inkstitch.convert_to_satin - inkstitch.py - inkex.py - convert_to_satin - - all - - - - - - diff --git a/inx/inkstitch_embroider.inx b/inx/inkstitch_embroider.inx deleted file mode 100644 index 70bc10b0..00000000 --- a/inx/inkstitch_embroider.inx +++ /dev/null @@ -1,30 +0,0 @@ - - - <_name>Embroider - jonh.embroider - inkstitch.py - inkex.py - 3.0 - true - - <_option value="dst">Tajima Embroidery Format (DST) - <_option value="exp">Melco Embroidery Format (EXP) - <_option value="jef">Janome Embroidery Format (JEF) - <_option value="pec">Brother Embroidery Format (PEC) - <_option value="pes">Brother Embroidery Format (PES) - <_option value="vp3">Pfaff Embroidery Format (VP3) - <_option value="csv">Comma-separated values (CSV) [DEBUG] - <_option value="svg">Scalable Vector Graphics (SVG) [DEBUG] - - - embroider - - all - - - - - - diff --git a/inx/inkstitch_flip.inx b/inx/inkstitch_flip.inx deleted file mode 100644 index f129b8d9..00000000 --- a/inx/inkstitch_flip.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>Flip Satin Columns - org.inkstitch.flip_satins - inkstitch.py - inkex.py - flip - - all - - - - - - diff --git a/inx/inkstitch_input_100.inx b/inx/inkstitch_input_100.inx deleted file mode 100644 index def2011d..00000000 --- a/inx/inkstitch_input_100.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>100 file input - org.inkstitch.input.100 - inkstitch.py - inkex.py - - .100 - application/x-embroidery-100 - <_filetypename>Ink/Stitch: Toyota Embroidery Format (.100) - <_filetypetooltip>convert 100 file to Ink/Stitch manual-stitch paths - - input - - diff --git a/inx/inkstitch_input_10O.inx b/inx/inkstitch_input_10O.inx deleted file mode 100644 index 29b14397..00000000 --- a/inx/inkstitch_input_10O.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>10O file input - org.inkstitch.input.10o - inkstitch.py - inkex.py - - .10o - application/x-embroidery-10o - <_filetypename>Ink/Stitch: Toyota Embroidery Format (.10o) - <_filetypetooltip>convert 10O file to Ink/Stitch manual-stitch paths - - input - - diff --git a/inx/inkstitch_input_BRO.inx b/inx/inkstitch_input_BRO.inx deleted file mode 100644 index 928195a6..00000000 --- a/inx/inkstitch_input_BRO.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>BRO file input - org.inkstitch.input.bro - inkstitch.py - inkex.py - - .bro - application/x-embroidery-bro - <_filetypename>Ink/Stitch: Bits & Volts Embroidery Format (.bro) - <_filetypetooltip>convert BRO file to Ink/Stitch manual-stitch paths - - input - - diff --git a/inx/inkstitch_input_DSB.inx b/inx/inkstitch_input_DSB.inx deleted file mode 100644 index c78e1c2d..00000000 --- a/inx/inkstitch_input_DSB.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>DSB file input - org.inkstitch.input.dsb - inkstitch.py - inkex.py - - .dsb - application/x-embroidery-dsb - <_filetypename>Ink/Stitch: Tajima(Barudan) Embroidery Format (.dsb) - <_filetypetooltip>convert DSB file to Ink/Stitch manual-stitch paths - - input - - diff --git a/inx/inkstitch_input_DST.inx b/inx/inkstitch_input_DST.inx deleted file mode 100644 index b3eee601..00000000 --- a/inx/inkstitch_input_DST.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>DST file input - org.inkstitch.input.dst - inkstitch.py - inkex.py - - .dst - application/x-embroidery-dst - <_filetypename>Ink/Stitch: Tajima Embroidery Format (.dst) - <_filetypetooltip>convert DST file to Ink/Stitch manual-stitch paths - - input - - diff --git a/inx/inkstitch_input_DSZ.inx b/inx/inkstitch_input_DSZ.inx deleted file mode 100644 index 388aeda0..00000000 --- a/inx/inkstitch_input_DSZ.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>DSZ file input - org.inkstitch.input.dsz - inkstitch.py - inkex.py - - .dsz - application/x-embroidery-dsz - <_filetypename>Ink/Stitch: ZSK USA Embroidery Format (.dsz) - <_filetypetooltip>convert DSZ file to Ink/Stitch manual-stitch paths - - input - - diff --git a/inx/inkstitch_input_EMD.inx b/inx/inkstitch_input_EMD.inx deleted file mode 100644 index c05da24f..00000000 --- a/inx/inkstitch_input_EMD.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>EMD file input - org.inkstitch.input.emd - inkstitch.py - inkex.py - - .emd - application/x-embroidery-emd - <_filetypename>Ink/Stitch: Elna Embroidery Format (.emd) - <_filetypetooltip>convert EMD file to Ink/Stitch manual-stitch paths - - input - - diff --git a/inx/inkstitch_input_EXP.inx b/inx/inkstitch_input_EXP.inx deleted file mode 100644 index 2c5997d5..00000000 --- a/inx/inkstitch_input_EXP.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>EXP file input - org.inkstitch.input.exp - inkstitch.py - inkex.py - - .exp - application/x-embroidery-exp - <_filetypename>Ink/Stitch: Melco Embroidery Format (.exp) - <_filetypetooltip>convert EXP file to Ink/Stitch manual-stitch paths - - input - - diff --git a/inx/inkstitch_input_INB.inx b/inx/inkstitch_input_INB.inx deleted file mode 100644 index 7409a853..00000000 --- a/inx/inkstitch_input_INB.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>INB file input - org.inkstitch.input.inb - inkstitch.py - inkex.py - - .inb - application/x-embroidery-inb - <_filetypename>Ink/Stitch: Inbro Embroidery Format (.inb) - <_filetypetooltip>convert INB file to Ink/Stitch manual-stitch paths - - input - - diff --git a/inx/inkstitch_input_JEF.inx b/inx/inkstitch_input_JEF.inx deleted file mode 100644 index 364e969f..00000000 --- a/inx/inkstitch_input_JEF.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>JEF file input - org.inkstitch.input.jef - inkstitch.py - inkex.py - - .jef - application/x-embroidery-jef - <_filetypename>Ink/Stitch: Janome Embroidery Format (.jef) - <_filetypetooltip>convert JEF file to Ink/Stitch manual-stitch paths - - input - - diff --git a/inx/inkstitch_input_KSM.inx b/inx/inkstitch_input_KSM.inx deleted file mode 100644 index b01eb195..00000000 --- a/inx/inkstitch_input_KSM.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>KSM file input - org.inkstitch.input.ksm - inkstitch.py - inkex.py - - .ksm - application/x-embroidery-ksm - <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.ksm) - <_filetypetooltip>convert KSM file to Ink/Stitch manual-stitch paths - - input - - diff --git a/inx/inkstitch_input_PEC.inx b/inx/inkstitch_input_PEC.inx deleted file mode 100644 index 885c0125..00000000 --- a/inx/inkstitch_input_PEC.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>PEC file input - org.inkstitch.input.pec - inkstitch.py - inkex.py - - .pec - application/x-embroidery-pec - <_filetypename>Ink/Stitch: Brother Embroidery Format (.pec) - <_filetypetooltip>convert PEC file to Ink/Stitch manual-stitch paths - - input - - diff --git a/inx/inkstitch_input_PES.inx b/inx/inkstitch_input_PES.inx deleted file mode 100644 index 6faa06be..00000000 --- a/inx/inkstitch_input_PES.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>PES file input - org.inkstitch.input.pes - inkstitch.py - inkex.py - - .pes - application/x-embroidery-pes - <_filetypename>Ink/Stitch: Brother Embroidery Format (.pes) - <_filetypetooltip>convert PES file to Ink/Stitch manual-stitch paths - - input - - diff --git a/inx/inkstitch_input_SEW.inx b/inx/inkstitch_input_SEW.inx deleted file mode 100644 index a7661c97..00000000 --- a/inx/inkstitch_input_SEW.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>SEW file input - org.inkstitch.input.sew - inkstitch.py - inkex.py - - .sew - application/x-embroidery-sew - <_filetypename>Ink/Stitch: Janome Embroidery Format (.sew) - <_filetypetooltip>convert SEW file to Ink/Stitch manual-stitch paths - - input - - diff --git a/inx/inkstitch_input_SHV.inx b/inx/inkstitch_input_SHV.inx deleted file mode 100644 index 7aad470c..00000000 --- a/inx/inkstitch_input_SHV.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>SHV file input - org.inkstitch.input.shv - inkstitch.py - inkex.py - - .shv - application/x-embroidery-shv - <_filetypename>Ink/Stitch: Husqvarna Viking Embroidery Format (.shv) - <_filetypetooltip>convert SHV file to Ink/Stitch manual-stitch paths - - input - - diff --git a/inx/inkstitch_input_STX.inx b/inx/inkstitch_input_STX.inx deleted file mode 100644 index 3f1a3065..00000000 --- a/inx/inkstitch_input_STX.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>STX file input - org.inkstitch.input.stx - inkstitch.py - inkex.py - - .stx - application/x-embroidery-stx - <_filetypename>Ink/Stitch: Data Stitch Embroidery Format (.stx) - <_filetypetooltip>convert STX file to Ink/Stitch manual-stitch paths - - input - - diff --git a/inx/inkstitch_input_TAP.inx b/inx/inkstitch_input_TAP.inx deleted file mode 100644 index bf299130..00000000 --- a/inx/inkstitch_input_TAP.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>TAP file input - org.inkstitch.input.tap - inkstitch.py - inkex.py - - .tap - application/x-embroidery-tap - <_filetypename>Ink/Stitch: Happy Embroidery Format (.tap) - <_filetypetooltip>convert TAP file to Ink/Stitch manual-stitch paths - - input - - diff --git a/inx/inkstitch_input_TBF.inx b/inx/inkstitch_input_TBF.inx deleted file mode 100644 index e2b72ec9..00000000 --- a/inx/inkstitch_input_TBF.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>TBF file input - org.inkstitch.input.tbf - inkstitch.py - inkex.py - - .tbf - application/x-embroidery-tbf - <_filetypename>Ink/Stitch: Tajima Embroidery Format (.tbf) - <_filetypetooltip>convert TBF file to Ink/Stitch manual-stitch paths - - input - - diff --git a/inx/inkstitch_input_U01.inx b/inx/inkstitch_input_U01.inx deleted file mode 100644 index befadd5b..00000000 --- a/inx/inkstitch_input_U01.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>U01 file input - org.inkstitch.input.u01 - inkstitch.py - inkex.py - - .u01 - application/x-embroidery-u01 - <_filetypename>Ink/Stitch: Barudan Embroidery Format (.u01) - <_filetypetooltip>convert U01 file to Ink/Stitch manual-stitch paths - - input - - diff --git a/inx/inkstitch_input_VP3.inx b/inx/inkstitch_input_VP3.inx deleted file mode 100644 index b39f630a..00000000 --- a/inx/inkstitch_input_VP3.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>VP3 file input - org.inkstitch.input.vp3 - inkstitch.py - inkex.py - - .vp3 - application/x-embroidery-vp3 - <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.vp3) - <_filetypetooltip>convert VP3 file to Ink/Stitch manual-stitch paths - - input - - diff --git a/inx/inkstitch_input_XXX.inx b/inx/inkstitch_input_XXX.inx deleted file mode 100644 index 6e8e501e..00000000 --- a/inx/inkstitch_input_XXX.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>XXX file input - org.inkstitch.input.xxx - inkstitch.py - inkex.py - - .xxx - application/x-embroidery-xxx - <_filetypename>Ink/Stitch: Singer Embroidery Format (.xxx) - <_filetypetooltip>convert XXX file to Ink/Stitch manual-stitch paths - - input - - diff --git a/inx/inkstitch_install.inx b/inx/inkstitch_install.inx deleted file mode 100644 index 7275e13a..00000000 --- a/inx/inkstitch_install.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>Install add-ons for Inkscape - org.inkstitch.install - inkstitch.py - inkex.py - install - - all - - - - - - diff --git a/inx/inkstitch_layer_commands.inx b/inx/inkstitch_layer_commands.inx deleted file mode 100644 index 7eadd094..00000000 --- a/inx/inkstitch_layer_commands.inx +++ /dev/null @@ -1,19 +0,0 @@ - - - <_name>Add Layer Commands - org.inkstitch.layer_commands - inkstitch.py - inkex.py - Commands will be added to the currently-selected layer. - false - layer_commands - - all - - - - - - diff --git a/inx/inkstitch_output_DST.inx b/inx/inkstitch_output_DST.inx deleted file mode 100644 index fa034f40..00000000 --- a/inx/inkstitch_output_DST.inx +++ /dev/null @@ -1,19 +0,0 @@ - - - <_name>DST file output - org.inkstitch.output.dst - inkstitch.py - inkex.py - - .dst - application/x-embroidery-dst - <_filetypename>Ink/Stitch: Tajima Embroidery Format (.dst) - <_filetypetooltip>Save design in DST format using Ink/Stitch - true - - output - dst - - diff --git a/inx/inkstitch_output_EXP.inx b/inx/inkstitch_output_EXP.inx deleted file mode 100644 index 853bab9f..00000000 --- a/inx/inkstitch_output_EXP.inx +++ /dev/null @@ -1,19 +0,0 @@ - - - <_name>EXP file output - org.inkstitch.output.exp - inkstitch.py - inkex.py - - .exp - application/x-embroidery-exp - <_filetypename>Ink/Stitch: Melco Embroidery Format (.exp) - <_filetypetooltip>Save design in EXP format using Ink/Stitch - true - - output - exp - - diff --git a/inx/inkstitch_output_JEF.inx b/inx/inkstitch_output_JEF.inx deleted file mode 100644 index 74b752fc..00000000 --- a/inx/inkstitch_output_JEF.inx +++ /dev/null @@ -1,19 +0,0 @@ - - - <_name>JEF file output - org.inkstitch.output.jef - inkstitch.py - inkex.py - - .jef - application/x-embroidery-jef - <_filetypename>Ink/Stitch: Janome Embroidery Format (.jef) - <_filetypetooltip>Save design in JEF format using Ink/Stitch - true - - output - jef - - diff --git a/inx/inkstitch_output_PEC.inx b/inx/inkstitch_output_PEC.inx deleted file mode 100644 index 6d76b165..00000000 --- a/inx/inkstitch_output_PEC.inx +++ /dev/null @@ -1,19 +0,0 @@ - - - <_name>PEC file output - org.inkstitch.output.pec - inkstitch.py - inkex.py - - .pec - application/x-embroidery-pec - <_filetypename>Ink/Stitch: Brother Embroidery Format (.pec) - <_filetypetooltip>Save design in PEC format using Ink/Stitch - true - - output - pec - - diff --git a/inx/inkstitch_output_PES.inx b/inx/inkstitch_output_PES.inx deleted file mode 100644 index b821225a..00000000 --- a/inx/inkstitch_output_PES.inx +++ /dev/null @@ -1,19 +0,0 @@ - - - <_name>PES file output - org.inkstitch.output.pes - inkstitch.py - inkex.py - - .pes - application/x-embroidery-pes - <_filetypename>Ink/Stitch: Brother Embroidery Format (.pes) - <_filetypetooltip>Save design in PES format using Ink/Stitch - true - - output - pes - - diff --git a/inx/inkstitch_output_VP3.inx b/inx/inkstitch_output_VP3.inx deleted file mode 100644 index 11843420..00000000 --- a/inx/inkstitch_output_VP3.inx +++ /dev/null @@ -1,19 +0,0 @@ - - - <_name>VP3 file output - org.inkstitch.output.vp3 - inkstitch.py - inkex.py - - .vp3 - application/x-embroidery-vp3 - <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.vp3) - <_filetypetooltip>Save design in VP3 format using Ink/Stitch - true - - output - vp3 - - diff --git a/inx/inkstitch_output_ZIP.inx b/inx/inkstitch_output_ZIP.inx deleted file mode 100644 index 81f17b23..00000000 --- a/inx/inkstitch_output_ZIP.inx +++ /dev/null @@ -1,31 +0,0 @@ - - - <_name>embroidery ZIP file output - org.inkstitch.output.zip - inkstitch.py - inkex.py - - .zip - application/zip - <_filetypename>Ink/Stitch: ZIP export multiple formats (.zip) - <_filetypetooltip>Create a ZIP with multiple embroidery file formats using Ink/Stitch - true - - - false - - false - - false - - false - - false - - false - - zip - - \ No newline at end of file diff --git a/inx/inkstitch_params.inx b/inx/inkstitch_params.inx deleted file mode 100644 index 7b3b4e63..00000000 --- a/inx/inkstitch_params.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>Params - jonh.embroider.params - inkstitch.py - inkex.py - params - - all - - - - - - diff --git a/inx/inkstitch_print.inx b/inx/inkstitch_print.inx deleted file mode 100644 index edc96a4c..00000000 --- a/inx/inkstitch_print.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>Print - jonh.embroider.print - inkstitch.py - inkex.py - print - - all - - - - - - diff --git a/inx/inkstitch_simulate.inx b/inx/inkstitch_simulate.inx deleted file mode 100644 index 66f892d8..00000000 --- a/inx/inkstitch_simulate.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>Simulate - jonh.embroider.simulate - inkstitch.py - inkex.py - simulate - - all - - - - - - diff --git a/lib/extensions/__init__.py b/lib/extensions/__init__.py index 6c8db318..1606795c 100644 --- a/lib/extensions/__init__.py +++ b/lib/extensions/__init__.py @@ -10,3 +10,13 @@ from flip import Flip from object_commands import ObjectCommands from layer_commands import LayerCommands from convert_to_satin import ConvertToSatin + +from base import InkstitchExtension +import inspect + +extensions = [] +for item in locals().values(): + if inspect.isclass(item) and \ + issubclass(item, InkstitchExtension) and \ + item is not InkstitchExtension: + extensions.append(item) diff --git a/lib/extensions/base.py b/lib/extensions/base.py index 571e3c2d..1794b68c 100644 --- a/lib/extensions/base.py +++ b/lib/extensions/base.py @@ -3,6 +3,7 @@ import re import json from copy import deepcopy from collections import MutableMapping +from stringcase import snakecase from ..svg.tags import * from ..elements import AutoFill, Fill, Stroke, SatinColumn, Polyline, EmbroideryElement @@ -98,6 +99,10 @@ class InkStitchMetadata(MutableMapping): class InkstitchExtension(inkex.Effect): """Base class for Inkstitch extensions. Not intended for direct use.""" + @classmethod + def name(cls): + return snakecase(cls.__name__) + def hide_all_layers(self): for g in self.document.getroot().findall(SVG_GROUP_TAG): if g.get(INKSCAPE_GROUPMODE) == "layer": diff --git a/lib/inx/__init__.py b/lib/inx/__init__.py new file mode 100644 index 00000000..32b8bfae --- /dev/null +++ b/lib/inx/__init__.py @@ -0,0 +1 @@ +from generate import generate_inx_files diff --git a/lib/inx/extensions.py b/lib/inx/extensions.py new file mode 100755 index 00000000..ba206d8f --- /dev/null +++ b/lib/inx/extensions.py @@ -0,0 +1,21 @@ +import pyembroidery + +from .utils import build_environment, write_inx_file +from .outputs import pyembroidery_output_formats +from ..extensions import extensions + + +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: + 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())) diff --git a/lib/inx/generate.py b/lib/inx/generate.py new file mode 100644 index 00000000..4773a92d --- /dev/null +++ b/lib/inx/generate.py @@ -0,0 +1,8 @@ +from .inputs import generate_input_inx_files +from .outputs import generate_output_inx_files +from .extensions import generate_extension_inx_files + +def generate_inx_files(): + generate_input_inx_files() + generate_output_inx_files() + generate_extension_inx_files() diff --git a/lib/inx/inputs.py b/lib/inx/inputs.py new file mode 100755 index 00000000..d40ffeaf --- /dev/null +++ b/lib/inx/inputs.py @@ -0,0 +1,18 @@ +import pyembroidery + +from .utils import build_environment, write_inx_file + + +def pyembroidery_input_formats(): + for format in pyembroidery.supported_formats(): + if 'reader' in format and format['category'] == 'embroidery': + yield format['extension'], format['description'] + + +def generate_input_inx_files(): + env = build_environment() + template = env.get_template('input.inx') + + for format, description in pyembroidery_input_formats(): + name = "input_%s" % format.upper() + write_inx_file(name, template.render(format=format, description=description)) diff --git a/lib/inx/outputs.py b/lib/inx/outputs.py new file mode 100644 index 00000000..aef0c8b5 --- /dev/null +++ b/lib/inx/outputs.py @@ -0,0 +1,18 @@ +import pyembroidery + +from .utils import build_environment, write_inx_file + + +def pyembroidery_output_formats(): + for format in pyembroidery.supported_formats(): + if 'writer' in format and format['category'] == 'embroidery': + yield format['extension'], format['description'] + + +def generate_output_inx_files(): + env = build_environment() + template = env.get_template('output.inx') + + for format, description in pyembroidery_output_formats(): + name = "output_%s" % format.upper() + write_inx_file(name, template.render(format=format, description=description)) 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 diff --git a/messages.po b/messages.po index 30ceee9e..5de56d8f 100644 --- a/messages.po +++ b/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2018-08-17 23:02-0400\n" +"POT-Creation-Date: 2018-08-19 22:14-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -369,15 +369,15 @@ msgid "" "be dashed to indicate running stitch. Any kind of dash will work." msgstr "" -#: lib/extensions/base.py:108 +#: lib/extensions/base.py:113 msgid "No embroiderable paths selected." msgstr "" -#: lib/extensions/base.py:110 +#: lib/extensions/base.py:115 msgid "No embroiderable paths found in document." msgstr "" -#: lib/extensions/base.py:111 +#: lib/extensions/base.py:116 msgid "Tip: use Path -> Object to Path to convert non-paths." msgstr "" diff --git a/requirements.txt b/requirements.txt index 8fbea7cd..84bb1d51 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,6 +9,7 @@ numpy jinja2 requests colormath +stringcase # We're not ready for flask 1.0 yet. Logging changed, among othe things. flask==0.* diff --git a/templates/convert_to_satin.inx b/templates/convert_to_satin.inx new file mode 100644 index 00000000..d71b2081 --- /dev/null +++ b/templates/convert_to_satin.inx @@ -0,0 +1,17 @@ + + + <_name>Convert Line to Satin + org.inkstitch.convert_to_satin + inkstitch.py + inkex.py + convert_to_satin + + all + + + + + + diff --git a/templates/embroider.inx b/templates/embroider.inx new file mode 100644 index 00000000..7c6544db --- /dev/null +++ b/templates/embroider.inx @@ -0,0 +1,28 @@ + + + <_name>Embroider + jonh.embroider + inkstitch.py + inkex.py + 3.0 + true + + {% for format, description in formats %} + <_option value="{{ format }}">{{ description }} ({{ format | upper }}) + {% endfor %} + {% for format, description in debug_formats %} + <_option value="{{ format }}">{{ description }} ({{ format | upper }}) [DEBUG] + {% endfor %} + + + embroider + + all + + + + + + diff --git a/templates/embroider_input.inx b/templates/embroider_input.inx deleted file mode 100644 index 15ccdef8..00000000 --- a/templates/embroider_input.inx +++ /dev/null @@ -1,17 +0,0 @@ - - - <_name>{{ format | upper }} file input - org.inkstitch.input.{{ format }} - inkstitch.py - inkex.py - - .{{ format }} - application/x-embroidery-{{ format }} - <_filetypename>Ink/Stitch: {{ description }} (.{{ format }}) - <_filetypetooltip>convert {{ format | upper }} file to Ink/Stitch manual-stitch paths - - input - - diff --git a/templates/embroider_output.inx b/templates/embroider_output.inx deleted file mode 100644 index 4f971fb3..00000000 --- a/templates/embroider_output.inx +++ /dev/null @@ -1,19 +0,0 @@ - - - <_name>{{ format | upper }} file output - org.inkstitch.output.{{ format }} - inkstitch.py - inkex.py - - .{{ format }} - application/x-embroidery-{{ format }} - <_filetypename>Ink/Stitch: {{ description }} (.{{ format }}) - <_filetypetooltip>Save design in {{ format | upper }} format using Ink/Stitch - true - - output - {{ format }} - - diff --git a/templates/embroider_zip_output.inx b/templates/embroider_zip_output.inx deleted file mode 100644 index 5d162357..00000000 --- a/templates/embroider_zip_output.inx +++ /dev/null @@ -1,21 +0,0 @@ - - - <_name>embroidery ZIP file output - org.inkstitch.output.zip - inkstitch.py - inkex.py - - .zip - application/zip - <_filetypename>Ink/Stitch: ZIP export multiple formats (.zip) - <_filetypetooltip>Create a ZIP with multiple embroidery file formats using Ink/Stitch - true - -{% for format, description in formats %} - false -{% endfor %} - zip - - diff --git a/templates/flip.inx b/templates/flip.inx new file mode 100644 index 00000000..f129b8d9 --- /dev/null +++ b/templates/flip.inx @@ -0,0 +1,17 @@ + + + <_name>Flip Satin Columns + org.inkstitch.flip_satins + inkstitch.py + inkex.py + flip + + all + + + + + + diff --git a/templates/input.inx b/templates/input.inx new file mode 100644 index 00000000..15ccdef8 --- /dev/null +++ b/templates/input.inx @@ -0,0 +1,17 @@ + + + <_name>{{ format | upper }} file input + org.inkstitch.input.{{ format }} + inkstitch.py + inkex.py + + .{{ format }} + application/x-embroidery-{{ format }} + <_filetypename>Ink/Stitch: {{ description }} (.{{ format }}) + <_filetypetooltip>convert {{ format | upper }} file to Ink/Stitch manual-stitch paths + + input + + diff --git a/templates/install.inx b/templates/install.inx new file mode 100644 index 00000000..7275e13a --- /dev/null +++ b/templates/install.inx @@ -0,0 +1,17 @@ + + + <_name>Install add-ons for Inkscape + org.inkstitch.install + inkstitch.py + inkex.py + install + + all + + + + + + diff --git a/templates/layer_commands.inx b/templates/layer_commands.inx new file mode 100644 index 00000000..7eadd094 --- /dev/null +++ b/templates/layer_commands.inx @@ -0,0 +1,19 @@ + + + <_name>Add Layer Commands + org.inkstitch.layer_commands + inkstitch.py + inkex.py + Commands will be added to the currently-selected layer. + false + layer_commands + + all + + + + + + diff --git a/templates/object_commands.inx b/templates/object_commands.inx new file mode 100644 index 00000000..bba8602b --- /dev/null +++ b/templates/object_commands.inx @@ -0,0 +1,22 @@ + + + <_name>Attach Commands + org.inkstitch.commands + inkstitch.py + inkex.py + false + false + false + false + false + object_commands + + all + + + + + + diff --git a/templates/output.inx b/templates/output.inx new file mode 100644 index 00000000..4f971fb3 --- /dev/null +++ b/templates/output.inx @@ -0,0 +1,19 @@ + + + <_name>{{ format | upper }} file output + org.inkstitch.output.{{ format }} + inkstitch.py + inkex.py + + .{{ format }} + application/x-embroidery-{{ format }} + <_filetypename>Ink/Stitch: {{ description }} (.{{ format }}) + <_filetypetooltip>Save design in {{ format | upper }} format using Ink/Stitch + true + + output + {{ format }} + + diff --git a/templates/params.inx b/templates/params.inx new file mode 100644 index 00000000..7b3b4e63 --- /dev/null +++ b/templates/params.inx @@ -0,0 +1,17 @@ + + + <_name>Params + jonh.embroider.params + inkstitch.py + inkex.py + params + + all + + + + + + diff --git a/templates/print.inx b/templates/print.inx new file mode 100644 index 00000000..edc96a4c --- /dev/null +++ b/templates/print.inx @@ -0,0 +1,17 @@ + + + <_name>Print + jonh.embroider.print + inkstitch.py + inkex.py + print + + all + + + + + + diff --git a/templates/simulate.inx b/templates/simulate.inx new file mode 100644 index 00000000..66f892d8 --- /dev/null +++ b/templates/simulate.inx @@ -0,0 +1,17 @@ + + + <_name>Simulate + jonh.embroider.simulate + inkstitch.py + inkex.py + simulate + + all + + + + + + diff --git a/templates/zip.inx b/templates/zip.inx new file mode 100644 index 00000000..c85e849f --- /dev/null +++ b/templates/zip.inx @@ -0,0 +1,21 @@ + + + <_name>embroidery ZIP file output + org.inkstitch.output.zip + inkstitch.py + inkex.py + + .zip + application/zip + <_filetypename>Ink/Stitch: ZIP export multiple formats (.zip) + <_filetypetooltip>Create a ZIP with multiple embroidery file formats using Ink/Stitch + true + + {% for format, description in formats %} + false + {% endfor %} + zip + + -- cgit v1.2.3