diff options
| author | Lex Neva <github.com@lexneva.name> | 2018-08-19 22:14:10 -0400 |
|---|---|---|
| committer | Lex Neva <github.com@lexneva.name> | 2018-08-19 22:14:10 -0400 |
| commit | 512c3411648b24505165d555a04e82ba689f8aed (patch) | |
| tree | 3eb79343f2be57bace6e2f3e62cfe319d7fdb2f1 | |
| parent | a4d588e392c734c9e32bf4c06b2403ca32e7f1e2 (diff) | |
integrate inx generation into ink/stitch proper
55 files changed, 131 insertions, 638 deletions
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</_option>' % (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_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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>100 file input</_name> - <id>org.inkstitch.input.100</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <input> - <extension>.100</extension> - <mimetype>application/x-embroidery-100</mimetype> - <_filetypename>Ink/Stitch: Toyota Embroidery Format (.100)</_filetypename> - <_filetypetooltip>convert 100 file to Ink/Stitch manual-stitch paths</_filetypetooltip> - </input> - <param name="extension" type="string" gui-hidden="true">input</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>10O file input</_name> - <id>org.inkstitch.input.10o</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <input> - <extension>.10o</extension> - <mimetype>application/x-embroidery-10o</mimetype> - <_filetypename>Ink/Stitch: Toyota Embroidery Format (.10o)</_filetypename> - <_filetypetooltip>convert 10O file to Ink/Stitch manual-stitch paths</_filetypetooltip> - </input> - <param name="extension" type="string" gui-hidden="true">input</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>BRO file input</_name> - <id>org.inkstitch.input.bro</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <input> - <extension>.bro</extension> - <mimetype>application/x-embroidery-bro</mimetype> - <_filetypename>Ink/Stitch: Bits & Volts Embroidery Format (.bro)</_filetypename> - <_filetypetooltip>convert BRO file to Ink/Stitch manual-stitch paths</_filetypetooltip> - </input> - <param name="extension" type="string" gui-hidden="true">input</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>DSB file input</_name> - <id>org.inkstitch.input.dsb</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <input> - <extension>.dsb</extension> - <mimetype>application/x-embroidery-dsb</mimetype> - <_filetypename>Ink/Stitch: Tajima(Barudan) Embroidery Format (.dsb)</_filetypename> - <_filetypetooltip>convert DSB file to Ink/Stitch manual-stitch paths</_filetypetooltip> - </input> - <param name="extension" type="string" gui-hidden="true">input</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>DST file input</_name> - <id>org.inkstitch.input.dst</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <input> - <extension>.dst</extension> - <mimetype>application/x-embroidery-dst</mimetype> - <_filetypename>Ink/Stitch: Tajima Embroidery Format (.dst)</_filetypename> - <_filetypetooltip>convert DST file to Ink/Stitch manual-stitch paths</_filetypetooltip> - </input> - <param name="extension" type="string" gui-hidden="true">input</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>DSZ file input</_name> - <id>org.inkstitch.input.dsz</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <input> - <extension>.dsz</extension> - <mimetype>application/x-embroidery-dsz</mimetype> - <_filetypename>Ink/Stitch: ZSK USA Embroidery Format (.dsz)</_filetypename> - <_filetypetooltip>convert DSZ file to Ink/Stitch manual-stitch paths</_filetypetooltip> - </input> - <param name="extension" type="string" gui-hidden="true">input</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>EMD file input</_name> - <id>org.inkstitch.input.emd</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <input> - <extension>.emd</extension> - <mimetype>application/x-embroidery-emd</mimetype> - <_filetypename>Ink/Stitch: Elna Embroidery Format (.emd)</_filetypename> - <_filetypetooltip>convert EMD file to Ink/Stitch manual-stitch paths</_filetypetooltip> - </input> - <param name="extension" type="string" gui-hidden="true">input</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>EXP file input</_name> - <id>org.inkstitch.input.exp</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <input> - <extension>.exp</extension> - <mimetype>application/x-embroidery-exp</mimetype> - <_filetypename>Ink/Stitch: Melco Embroidery Format (.exp)</_filetypename> - <_filetypetooltip>convert EXP file to Ink/Stitch manual-stitch paths</_filetypetooltip> - </input> - <param name="extension" type="string" gui-hidden="true">input</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>INB file input</_name> - <id>org.inkstitch.input.inb</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <input> - <extension>.inb</extension> - <mimetype>application/x-embroidery-inb</mimetype> - <_filetypename>Ink/Stitch: Inbro Embroidery Format (.inb)</_filetypename> - <_filetypetooltip>convert INB file to Ink/Stitch manual-stitch paths</_filetypetooltip> - </input> - <param name="extension" type="string" gui-hidden="true">input</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>JEF file input</_name> - <id>org.inkstitch.input.jef</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <input> - <extension>.jef</extension> - <mimetype>application/x-embroidery-jef</mimetype> - <_filetypename>Ink/Stitch: Janome Embroidery Format (.jef)</_filetypename> - <_filetypetooltip>convert JEF file to Ink/Stitch manual-stitch paths</_filetypetooltip> - </input> - <param name="extension" type="string" gui-hidden="true">input</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>KSM file input</_name> - <id>org.inkstitch.input.ksm</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <input> - <extension>.ksm</extension> - <mimetype>application/x-embroidery-ksm</mimetype> - <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.ksm)</_filetypename> - <_filetypetooltip>convert KSM file to Ink/Stitch manual-stitch paths</_filetypetooltip> - </input> - <param name="extension" type="string" gui-hidden="true">input</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>PEC file input</_name> - <id>org.inkstitch.input.pec</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <input> - <extension>.pec</extension> - <mimetype>application/x-embroidery-pec</mimetype> - <_filetypename>Ink/Stitch: Brother Embroidery Format (.pec)</_filetypename> - <_filetypetooltip>convert PEC file to Ink/Stitch manual-stitch paths</_filetypetooltip> - </input> - <param name="extension" type="string" gui-hidden="true">input</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>PES file input</_name> - <id>org.inkstitch.input.pes</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <input> - <extension>.pes</extension> - <mimetype>application/x-embroidery-pes</mimetype> - <_filetypename>Ink/Stitch: Brother Embroidery Format (.pes)</_filetypename> - <_filetypetooltip>convert PES file to Ink/Stitch manual-stitch paths</_filetypetooltip> - </input> - <param name="extension" type="string" gui-hidden="true">input</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>SEW file input</_name> - <id>org.inkstitch.input.sew</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <input> - <extension>.sew</extension> - <mimetype>application/x-embroidery-sew</mimetype> - <_filetypename>Ink/Stitch: Janome Embroidery Format (.sew)</_filetypename> - <_filetypetooltip>convert SEW file to Ink/Stitch manual-stitch paths</_filetypetooltip> - </input> - <param name="extension" type="string" gui-hidden="true">input</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>SHV file input</_name> - <id>org.inkstitch.input.shv</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <input> - <extension>.shv</extension> - <mimetype>application/x-embroidery-shv</mimetype> - <_filetypename>Ink/Stitch: Husqvarna Viking Embroidery Format (.shv)</_filetypename> - <_filetypetooltip>convert SHV file to Ink/Stitch manual-stitch paths</_filetypetooltip> - </input> - <param name="extension" type="string" gui-hidden="true">input</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>STX file input</_name> - <id>org.inkstitch.input.stx</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <input> - <extension>.stx</extension> - <mimetype>application/x-embroidery-stx</mimetype> - <_filetypename>Ink/Stitch: Data Stitch Embroidery Format (.stx)</_filetypename> - <_filetypetooltip>convert STX file to Ink/Stitch manual-stitch paths</_filetypetooltip> - </input> - <param name="extension" type="string" gui-hidden="true">input</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>TAP file input</_name> - <id>org.inkstitch.input.tap</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <input> - <extension>.tap</extension> - <mimetype>application/x-embroidery-tap</mimetype> - <_filetypename>Ink/Stitch: Happy Embroidery Format (.tap)</_filetypename> - <_filetypetooltip>convert TAP file to Ink/Stitch manual-stitch paths</_filetypetooltip> - </input> - <param name="extension" type="string" gui-hidden="true">input</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>TBF file input</_name> - <id>org.inkstitch.input.tbf</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <input> - <extension>.tbf</extension> - <mimetype>application/x-embroidery-tbf</mimetype> - <_filetypename>Ink/Stitch: Tajima Embroidery Format (.tbf)</_filetypename> - <_filetypetooltip>convert TBF file to Ink/Stitch manual-stitch paths</_filetypetooltip> - </input> - <param name="extension" type="string" gui-hidden="true">input</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>U01 file input</_name> - <id>org.inkstitch.input.u01</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <input> - <extension>.u01</extension> - <mimetype>application/x-embroidery-u01</mimetype> - <_filetypename>Ink/Stitch: Barudan Embroidery Format (.u01)</_filetypename> - <_filetypetooltip>convert U01 file to Ink/Stitch manual-stitch paths</_filetypetooltip> - </input> - <param name="extension" type="string" gui-hidden="true">input</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>VP3 file input</_name> - <id>org.inkstitch.input.vp3</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <input> - <extension>.vp3</extension> - <mimetype>application/x-embroidery-vp3</mimetype> - <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.vp3)</_filetypename> - <_filetypetooltip>convert VP3 file to Ink/Stitch manual-stitch paths</_filetypetooltip> - </input> - <param name="extension" type="string" gui-hidden="true">input</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>XXX file input</_name> - <id>org.inkstitch.input.xxx</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <input> - <extension>.xxx</extension> - <mimetype>application/x-embroidery-xxx</mimetype> - <_filetypename>Ink/Stitch: Singer Embroidery Format (.xxx)</_filetypename> - <_filetypetooltip>convert XXX file to Ink/Stitch manual-stitch paths</_filetypetooltip> - </input> - <param name="extension" type="string" gui-hidden="true">input</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>DST file output</_name> - <id>org.inkstitch.output.dst</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <output> - <extension>.dst</extension> - <mimetype>application/x-embroidery-dst</mimetype> - <_filetypename>Ink/Stitch: Tajima Embroidery Format (.dst)</_filetypename> - <_filetypetooltip>Save design in DST format using Ink/Stitch</_filetypetooltip> - <dataloss>true</dataloss> - </output> - <param name="extension" type="string" gui-hidden="true">output</param> - <param name="format" type="string" gui-hidden="true">dst</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>EXP file output</_name> - <id>org.inkstitch.output.exp</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <output> - <extension>.exp</extension> - <mimetype>application/x-embroidery-exp</mimetype> - <_filetypename>Ink/Stitch: Melco Embroidery Format (.exp)</_filetypename> - <_filetypetooltip>Save design in EXP format using Ink/Stitch</_filetypetooltip> - <dataloss>true</dataloss> - </output> - <param name="extension" type="string" gui-hidden="true">output</param> - <param name="format" type="string" gui-hidden="true">exp</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>JEF file output</_name> - <id>org.inkstitch.output.jef</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <output> - <extension>.jef</extension> - <mimetype>application/x-embroidery-jef</mimetype> - <_filetypename>Ink/Stitch: Janome Embroidery Format (.jef)</_filetypename> - <_filetypetooltip>Save design in JEF format using Ink/Stitch</_filetypetooltip> - <dataloss>true</dataloss> - </output> - <param name="extension" type="string" gui-hidden="true">output</param> - <param name="format" type="string" gui-hidden="true">jef</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>PEC file output</_name> - <id>org.inkstitch.output.pec</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <output> - <extension>.pec</extension> - <mimetype>application/x-embroidery-pec</mimetype> - <_filetypename>Ink/Stitch: Brother Embroidery Format (.pec)</_filetypename> - <_filetypetooltip>Save design in PEC format using Ink/Stitch</_filetypetooltip> - <dataloss>true</dataloss> - </output> - <param name="extension" type="string" gui-hidden="true">output</param> - <param name="format" type="string" gui-hidden="true">pec</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>PES file output</_name> - <id>org.inkstitch.output.pes</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <output> - <extension>.pes</extension> - <mimetype>application/x-embroidery-pes</mimetype> - <_filetypename>Ink/Stitch: Brother Embroidery Format (.pes)</_filetypename> - <_filetypetooltip>Save design in PES format using Ink/Stitch</_filetypetooltip> - <dataloss>true</dataloss> - </output> - <param name="extension" type="string" gui-hidden="true">output</param> - <param name="format" type="string" gui-hidden="true">pes</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>VP3 file output</_name> - <id>org.inkstitch.output.vp3</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <output> - <extension>.vp3</extension> - <mimetype>application/x-embroidery-vp3</mimetype> - <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.vp3)</_filetypename> - <_filetypetooltip>Save design in VP3 format using Ink/Stitch</_filetypetooltip> - <dataloss>true</dataloss> - </output> - <param name="extension" type="string" gui-hidden="true">output</param> - <param name="format" type="string" gui-hidden="true">vp3</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension> 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>embroidery ZIP file output</_name> - <id>org.inkstitch.output.zip</id> - <dependency type="executable" location="extensions">inkstitch.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <output> - <extension>.zip</extension> - <mimetype>application/zip</mimetype> - <_filetypename>Ink/Stitch: ZIP export multiple formats (.zip)</_filetypename> - <_filetypetooltip>Create a ZIP with multiple embroidery file formats using Ink/Stitch</_filetypetooltip> - <dataloss>true</dataloss> - </output> - - <param name="format-pec" type="boolean" _gui-text=".PEC: Brother Embroidery Format">false</param> - - <param name="format-pes" type="boolean" _gui-text=".PES: Brother Embroidery Format">false</param> - - <param name="format-exp" type="boolean" _gui-text=".EXP: Melco Embroidery Format">false</param> - - <param name="format-dst" type="boolean" _gui-text=".DST: Tajima Embroidery Format">false</param> - - <param name="format-jef" type="boolean" _gui-text=".JEF: Janome Embroidery Format">false</param> - - <param name="format-vp3" type="boolean" _gui-text=".VP3: Pfaff Embroidery Format">false</param> - - <param name="extension" type="string" gui-hidden="true">zip</param> - <script> - <command reldir="extensions" interpreter="python">inkstitch.py</command> - </script> -</inkscape-extension>
\ No newline at end of file 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 <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\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/inx/inkstitch_convert_to_satin.inx b/templates/convert_to_satin.inx index d71b2081..d71b2081 100644 --- a/inx/inkstitch_convert_to_satin.inx +++ b/templates/convert_to_satin.inx diff --git a/inx/inkstitch_embroider.inx b/templates/embroider.inx index 70bc10b0..7c6544db 100644 --- a/inx/inkstitch_embroider.inx +++ b/templates/embroider.inx @@ -7,14 +7,12 @@ <param name="collapse_len_mm" type="float" min="0.0" max="10.0" _gui-text="Collapse length (mm)" _gui-description="Jump stitches smaller than this will be treated as normal stitches.">3.0</param> <param name="hide_layers" type="boolean" _gui-text="Hide other layers" _gui-description="Hide all other top-level layers when the embroidery layer is generated, in order to make stitching discernable.">true</param> <param name="output_format" type="optiongroup" _gui-text="Output file format" appearance="minimal"> - <_option value="dst">Tajima Embroidery Format (DST)</_option> - <_option value="exp">Melco Embroidery Format (EXP)</_option> - <_option value="jef">Janome Embroidery Format (JEF)</_option> - <_option value="pec">Brother Embroidery Format (PEC)</_option> - <_option value="pes">Brother Embroidery Format (PES)</_option> - <_option value="vp3">Pfaff Embroidery Format (VP3)</_option> - <_option value="csv">Comma-separated values (CSV) [DEBUG]</_option> - <_option value="svg">Scalable Vector Graphics (SVG) [DEBUG]</_option> + {% for format, description in formats %} + <_option value="{{ format }}">{{ description }} ({{ format | upper }})</_option> + {% endfor %} + {% for format, description in debug_formats %} + <_option value="{{ format }}">{{ description }} ({{ format | upper }}) [DEBUG]</_option> + {% endfor %} </param> <param name="path" type="string" _gui-text="Directory" _gui-description="Leave empty to save the output in Inkscape's extension directory."></param> <param name="extension" type="string" gui-hidden="true">embroider</param> diff --git a/inx/inkstitch_flip.inx b/templates/flip.inx index f129b8d9..f129b8d9 100644 --- a/inx/inkstitch_flip.inx +++ b/templates/flip.inx diff --git a/templates/embroider_input.inx b/templates/input.inx index 15ccdef8..15ccdef8 100644 --- a/templates/embroider_input.inx +++ b/templates/input.inx diff --git a/inx/inkstitch_install.inx b/templates/install.inx index 7275e13a..7275e13a 100644 --- a/inx/inkstitch_install.inx +++ b/templates/install.inx diff --git a/inx/inkstitch_layer_commands.inx b/templates/layer_commands.inx index 7eadd094..7eadd094 100644 --- a/inx/inkstitch_layer_commands.inx +++ b/templates/layer_commands.inx diff --git a/inx/inkstitch_attach_commands.inx b/templates/object_commands.inx index bba8602b..bba8602b 100644 --- a/inx/inkstitch_attach_commands.inx +++ b/templates/object_commands.inx diff --git a/templates/embroider_output.inx b/templates/output.inx index 4f971fb3..4f971fb3 100644 --- a/templates/embroider_output.inx +++ b/templates/output.inx diff --git a/inx/inkstitch_params.inx b/templates/params.inx index 7b3b4e63..7b3b4e63 100644 --- a/inx/inkstitch_params.inx +++ b/templates/params.inx diff --git a/inx/inkstitch_print.inx b/templates/print.inx index edc96a4c..edc96a4c 100644 --- a/inx/inkstitch_print.inx +++ b/templates/print.inx diff --git a/inx/inkstitch_simulate.inx b/templates/simulate.inx index 66f892d8..66f892d8 100644 --- a/inx/inkstitch_simulate.inx +++ b/templates/simulate.inx diff --git a/templates/embroider_zip_output.inx b/templates/zip.inx index 5d162357..c85e849f 100644 --- a/templates/embroider_zip_output.inx +++ b/templates/zip.inx @@ -11,9 +11,9 @@ <_filetypetooltip>Create a ZIP with multiple embroidery file formats using Ink/Stitch</_filetypetooltip> <dataloss>true</dataloss> </output> -{% for format, description in formats %} - <param name="format-{{format}}" type="boolean" _gui-text=".{{format | upper}}: {{description}}">false</param> -{% endfor %} + {% for format, description in formats %} + <param name="format-{{ format }}" type="boolean" _gui-text=".{{ format | upper }}: {{ description }}">false</param> + {% endfor %} <param name="extension" type="string" gui-hidden="true">zip</param> <script> <command reldir="extensions" interpreter="python">inkstitch.py</command> |
