From 13016f50ecace38a93f7d8e55bdad8b21fb0d2c7 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Fri, 17 Aug 2018 20:55:43 -0400 Subject: group symbol+connector and label with command description --- lib/extensions/object_commands.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'lib/extensions') diff --git a/lib/extensions/object_commands.py b/lib/extensions/object_commands.py index 27a07969..e9ee6063 100644 --- a/lib/extensions/object_commands.py +++ b/lib/extensions/object_commands.py @@ -7,14 +7,15 @@ from random import random from shapely import geometry as shgeo from .commands import CommandsExtension +from ..commands import OBJECT_COMMANDS, get_command_description from ..i18n import _ from ..elements import SatinColumn -from ..svg.tags import SVG_GROUP_TAG, SVG_USE_TAG, SVG_PATH_TAG, INKSCAPE_GROUPMODE, XLINK_HREF, CONNECTION_START, CONNECTION_END, CONNECTOR_TYPE +from ..svg.tags import * from ..svg import get_correction_transform class ObjectCommands(CommandsExtension): - COMMANDS = ["fill_start", "fill_end", "stop", "trim", "ignore_object"] + COMMANDS = OBJECT_COMMANDS def add_connector(self, symbol, element): # I'd like it if I could position the connector endpoint nicely but inkscape just @@ -27,14 +28,16 @@ class ObjectCommands(CommandsExtension): "id": self.uniqueId("connector"), "d": "M %s,%s %s,%s" % (start_pos[0], start_pos[1], end_pos.x, end_pos.y), "style": "stroke:#000000;stroke-width:1px;stroke-opacity:0.5;fill:none;", - "transform": get_correction_transform(symbol), CONNECTION_START: "#%s" % symbol.get('id'), CONNECTION_END: "#%s" % element.node.get('id'), CONNECTOR_TYPE: "polyline", + + # l10n: the name of the line that connects a command to the object it applies to + INKSCAPE_LABEL: _("connector") } ) - symbol.getparent().insert(symbol.getparent().index(symbol), path) + symbol.getparent().insert(0, path) def get_command_pos(self, element, index, total): # Put command symbols 30 pixels out from the shape, spaced evenly around it. @@ -71,7 +74,15 @@ class ObjectCommands(CommandsExtension): pos = self.get_command_pos(element, i, len(commands)) - symbol = inkex.etree.SubElement(element.node.getparent(), SVG_USE_TAG, + group = inkex.etree.SubElement(element.node.getparent(), SVG_GROUP_TAG, + { + "id": self.uniqueId("group"), + INKSCAPE_LABEL: _("Ink/Stitch Command") + ": %s" % get_command_description(command), + "transform": get_correction_transform(element.node) + } + ) + + symbol = inkex.etree.SubElement(group, SVG_USE_TAG, { "id": self.uniqueId("use"), XLINK_HREF: "#inkstitch_%s" % command, @@ -79,7 +90,9 @@ class ObjectCommands(CommandsExtension): "width": "100%", "x": str(pos.x), "y": str(pos.y), - "transform": get_correction_transform(element.node) + + # l10n: the name of a command symbol (example: scissors icon for trim command) + INKSCAPE_LABEL: _("command marker"), } ) -- cgit v1.3.1 From 8a0ed9b9658306341d19e3ca32ee01c641063937 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Fri, 17 Aug 2018 23:02:27 -0400 Subject: add description for layer commands too --- lib/extensions/layer_commands.py | 6 ++++-- messages.po | 12 ++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'lib/extensions') diff --git a/lib/extensions/layer_commands.py b/lib/extensions/layer_commands.py index 88170f66..576af044 100644 --- a/lib/extensions/layer_commands.py +++ b/lib/extensions/layer_commands.py @@ -3,13 +3,14 @@ import sys import inkex from .commands import CommandsExtension +from ..commands import LAYER_COMMANDS, get_command_description from ..i18n import _ -from ..svg.tags import SVG_USE_TAG, XLINK_HREF +from ..svg.tags import * from ..svg import get_correction_transform class LayerCommands(CommandsExtension): - COMMANDS = ["ignore_layer"] + COMMANDS = LAYER_COMMANDS def ensure_current_layer(self): # if no layer is selected, inkex defaults to the root, which isn't @@ -37,6 +38,7 @@ class LayerCommands(CommandsExtension): node = inkex.etree.SubElement(self.current_layer, SVG_USE_TAG, { "id": self.uniqueId("use"), + INKSCAPE_LABEL: _("Ink/Stitch Command") + ": %s" % get_command_description(command), XLINK_HREF: "#inkstitch_%s" % command, "height": "100%", "width": "100%", diff --git a/messages.po b/messages.po index 7350d2a2..30ceee9e 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 22:45-0400\n" +"POT-Creation-Date: 2018-08-17 23:02-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -458,19 +458,19 @@ msgstr "" msgid "Ink/Stitch Add-ons Installer" msgstr "" -#: lib/extensions/layer_commands.py:28 +#: lib/extensions/layer_commands.py:29 msgid "Please choose one or more commands to add." msgstr "" +#: lib/extensions/layer_commands.py:41 lib/extensions/object_commands.py:80 +msgid "Ink/Stitch Command" +msgstr "" + #. : the name of the line that connects a command to the object it applies to #: lib/extensions/object_commands.py:36 msgid "connector" msgstr "" -#: lib/extensions/object_commands.py:80 -msgid "Ink/Stitch Command" -msgstr "" - #. : the name of a command symbol (example: scissors icon for trim command) #: lib/extensions/object_commands.py:95 msgid "command marker" -- cgit v1.3.1 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 (limited to 'lib/extensions') 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.3.1 From 038875f876d79d0f1e971886fe42f5bee4f9f31e Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Tue, 21 Aug 2018 20:32:50 -0400 Subject: autopep8 --- lib/commands.py | 11 +++- lib/elements/auto_fill.py | 60 +++++++++---------- lib/elements/element.py | 4 +- lib/elements/fill.py | 59 +++++++++---------- lib/elements/polyline.py | 10 ++-- lib/elements/satin_column.py | 72 +++++++++++------------ lib/elements/stroke.py | 64 ++++++++++----------- lib/extensions/__init__.py | 2 +- lib/extensions/base.py | 12 ++-- lib/extensions/convert_to_satin.py | 27 ++++----- lib/extensions/flip.py | 1 + lib/extensions/input.py | 11 ++-- lib/extensions/install.py | 16 +++--- lib/extensions/layer_commands.py | 20 +++---- lib/extensions/object_commands.py | 58 +++++++++---------- lib/extensions/output.py | 1 + lib/extensions/print_pdf.py | 84 +++++++++++++-------------- lib/i18n.py | 5 ++ lib/inx/generate.py | 1 + lib/inx/utils.py | 7 ++- lib/output.py | 24 ++++---- lib/stitch_plan/stitch.py | 18 +++--- lib/stitches/auto_fill.py | 31 +++++----- lib/stitches/fill.py | 2 + lib/svg/path.py | 3 + lib/svg/realistic_rendering.py | 1 + lib/svg/svg.py | 38 +++++++------ lib/svg/units.py | 21 ++++--- lib/threads/catalog.py | 2 + lib/threads/color.py | 1 + lib/utils/cache.py | 2 + lib/utils/geometry.py | 3 +- lib/utils/inkscape.py | 1 + lib/utils/io.py | 2 + messages.po | 114 ++++++++++++++++++------------------- stub.py | 2 +- 36 files changed, 416 insertions(+), 374 deletions(-) (limited to 'lib/extensions') diff --git a/lib/commands.py b/lib/commands.py index 214b5f40..7764539c 100644 --- a/lib/commands.py +++ b/lib/commands.py @@ -26,8 +26,9 @@ COMMANDS = { "ignore_layer": N_("Ignore layer (do not stitch any objects in this layer)") } -OBJECT_COMMANDS = [ "fill_start", "fill_end", "stop", "trim", "ignore_object" ] -LAYER_COMMANDS = [ "ignore_layer" ] +OBJECT_COMMANDS = ["fill_start", "fill_end", "stop", "trim", "ignore_object"] +LAYER_COMMANDS = ["ignore_layer"] + class CommandParseError(Exception): pass @@ -50,7 +51,7 @@ class BaseCommand(object): else: raise CommandParseError("symbol is not an Ink/Stitch command") - def get_node_by_url(self,url): + def get_node_by_url(self, url): # url will be #path12345. Find the corresponding object. if url is None: raise CommandParseError("url is None") @@ -116,6 +117,7 @@ class StandaloneCommand(BaseCommand): self.parse_symbol() + def get_command_description(command): return _(COMMANDS[command]) @@ -138,6 +140,7 @@ def find_commands(node): return commands + def layer_commands(layer, command): """Find standalone (unconnected) command symbols in this layer.""" @@ -150,6 +153,7 @@ def layer_commands(layer, command): return commands + def standalone_commands(svg): """Find all unconnected command symbols in the SVG.""" @@ -165,5 +169,6 @@ def standalone_commands(svg): return commands + def is_command(node): return CONNECTION_START in node.attrib or CONNECTION_END in node.attrib diff --git a/lib/elements/auto_fill.py b/lib/elements/auto_fill.py index 79220a86..cfee6d7d 100644 --- a/lib/elements/auto_fill.py +++ b/lib/elements/auto_fill.py @@ -31,11 +31,11 @@ class AutoFill(Fill): @property @param('running_stitch_length_mm', - _('Running stitch length (traversal between sections)'), - tooltip=_('Length of stitches around the outline of the fill region used when moving from section to section.'), - unit='mm', - type='float', - default=1.5) + _('Running stitch length (traversal between sections)'), + tooltip=_('Length of stitches around the outline of the fill region used when moving from section to section.'), + unit='mm', + type='float', + default=1.5) def running_stitch_length(self): return max(self.get_float_param("running_stitch_length_mm", 1.5), 0.01) @@ -46,11 +46,11 @@ class AutoFill(Fill): @property @param('fill_underlay_angle', - _('Fill angle'), - tooltip=_('default: fill angle + 90 deg'), - unit='deg', - group=_('AutoFill Underlay'), - type='float') + _('Fill angle'), + tooltip=_('default: fill angle + 90 deg'), + unit='deg', + group=_('AutoFill Underlay'), + type='float') @cache def fill_underlay_angle(self): underlay_angle = self.get_float_param("fill_underlay_angle") @@ -62,43 +62,43 @@ class AutoFill(Fill): @property @param('fill_underlay_row_spacing_mm', - _('Row spacing'), - tooltip=_('default: 3x fill row spacing'), - unit='mm', - group=_('AutoFill Underlay'), - type='float') + _('Row spacing'), + tooltip=_('default: 3x fill row spacing'), + unit='mm', + group=_('AutoFill Underlay'), + type='float') @cache def fill_underlay_row_spacing(self): return self.get_float_param("fill_underlay_row_spacing_mm") or self.row_spacing * 3 @property @param('fill_underlay_max_stitch_length_mm', - _('Max stitch length'), - tooltip=_('default: equal to fill max stitch length'), - unit='mm', - group=_('AutoFill Underlay'), type='float') + _('Max stitch length'), + tooltip=_('default: equal to fill max stitch length'), + unit='mm', + group=_('AutoFill Underlay'), type='float') @cache def fill_underlay_max_stitch_length(self): return self.get_float_param("fill_underlay_max_stitch_length_mm") or self.max_stitch_length @property @param('fill_underlay_inset_mm', - _('Inset'), - tooltip=_('Shrink the shape before doing underlay, to prevent underlay from showing around the outside of the fill.'), - unit='mm', - group=_('AutoFill Underlay'), - type='float', - default=0) + _('Inset'), + tooltip=_('Shrink the shape before doing underlay, to prevent underlay from showing around the outside of the fill.'), + unit='mm', + group=_('AutoFill Underlay'), + type='float', + default=0) def fill_underlay_inset(self): return self.get_float_param('fill_underlay_inset_mm', 0) @property @param('expand_mm', - _('Expand'), - tooltip=_('Expand the shape before fill stitching, to compensate for gaps between shapes.'), - unit='mm', - type='float', - default=0) + _('Expand'), + tooltip=_('Expand the shape before fill stitching, to compensate for gaps between shapes.'), + unit='mm', + type='float', + default=0) def expand(self): return self.get_float_param('expand_mm', 0) diff --git a/lib/elements/element.py b/lib/elements/element.py index ebca90a4..5ca70cf6 100644 --- a/lib/elements/element.py +++ b/lib/elements/element.py @@ -157,7 +157,7 @@ class EmbroideryElement(object): doc_width, doc_height = get_doc_size(svg) viewbox = svg.get('viewBox', '0 0 %s %s' % (doc_width, doc_height)) viewbox = viewbox.strip().replace(',', ' ').split() - return doc_width / float(viewbox[2]) + return doc_width / float(viewbox[2]) @property @cache @@ -230,7 +230,7 @@ class EmbroideryElement(object): return commands[0] elif len(commands) > 1: raise ValueError(_("%(id)s has more than one command of type '%(command)s' linked to it") % - dict(id=self.node.get(id), command=command)) + dict(id=self.node.get(id), command=command)) else: return None diff --git a/lib/elements/fill.py b/lib/elements/fill.py index 394f523e..672f4db8 100644 --- a/lib/elements/fill.py +++ b/lib/elements/fill.py @@ -16,21 +16,21 @@ class Fill(EmbroideryElement): @property @param('auto_fill', - _('Manually routed fill stitching'), - tooltip=_('AutoFill is the default method for generating fill stitching.'), - type='toggle', - inverse=True, - default=True) + _('Manually routed fill stitching'), + tooltip=_('AutoFill is the default method for generating fill stitching.'), + type='toggle', + inverse=True, + default=True) def auto_fill(self): return self.get_boolean_param('auto_fill', True) @property @param('angle', - _('Angle of lines of stitches'), - tooltip=_('The angle increases in a counter-clockwise direction. 0 is horizontal. Negative angles are allowed.'), - unit='deg', - type='float', - default=0) + _('Angle of lines of stitches'), + tooltip=_('The angle increases in a counter-clockwise direction. 0 is horizontal. Negative angles are allowed.'), + unit='deg', + type='float', + default=0) @cache def angle(self): return math.radians(self.get_float_param('angle', 0)) @@ -41,21 +41,22 @@ class Fill(EmbroideryElement): return self.get_style("fill", "#000000") @property - @param('flip', - _('Flip fill (start right-to-left)'), - tooltip=_('The flip option can help you with routing your stitch path. When you enable flip, stitching goes from right-to-left instead of left-to-right.'), - type='boolean', - default=False) + @param( + 'flip', + _('Flip fill (start right-to-left)'), + tooltip=_('The flip option can help you with routing your stitch path. When you enable flip, stitching goes from right-to-left instead of left-to-right.'), + type='boolean', + default=False) def flip(self): return self.get_boolean_param("flip", False) @property @param('row_spacing_mm', - _('Spacing between rows'), - tooltip=_('Distance between rows of stitches.'), - unit='mm', - type='float', - default=0.25) + _('Spacing between rows'), + tooltip=_('Distance between rows of stitches.'), + unit='mm', + type='float', + default=0.25) def row_spacing(self): return max(self.get_float_param("row_spacing_mm", 0.25), 0.1 * PIXELS_PER_MM) @@ -65,20 +66,20 @@ class Fill(EmbroideryElement): @property @param('max_stitch_length_mm', - _('Maximum fill stitch length'), - tooltip=_('The length of each stitch in a row. Shorter stitch may be used at the start or end of a row.'), - unit='mm', - type='float', - default=3.0) + _('Maximum fill stitch length'), + tooltip=_('The length of each stitch in a row. Shorter stitch may be used at the start or end of a row.'), + unit='mm', + type='float', + default=3.0) def max_stitch_length(self): return max(self.get_float_param("max_stitch_length_mm", 3.0), 0.1 * PIXELS_PER_MM) @property @param('staggers', - _('Stagger rows this many times before repeating'), - tooltip=_('Setting this dictates how many rows apart the stitches will be before they fall in the same column position.'), - type='int', - default=4) + _('Stagger rows this many times before repeating'), + tooltip=_('Setting this dictates how many rows apart the stitches will be before they fall in the same column position.'), + type='int', + default=4) def staggers(self): return self.get_int_param("staggers", 4) diff --git a/lib/elements/polyline.py b/lib/elements/polyline.py index b9ffdc0b..d3242795 100644 --- a/lib/elements/polyline.py +++ b/lib/elements/polyline.py @@ -21,13 +21,13 @@ class Polyline(EmbroideryElement): @property def points(self): - # example: "1,2 0,0 1.5,3 4,2" + # example: "1,2 0,0 1.5,3 4,2" - points = self.node.get('points') - points = points.split(" ") - points = [[float(coord) for coord in point.split(",")] for point in points] + points = self.node.get('points') + points = points.split(" ") + points = [[float(coord) for coord in point.split(",")] for point in points] - return points + return points @property @cache diff --git a/lib/elements/satin_column.py b/lib/elements/satin_column.py index 834509fd..e13e1118 100644 --- a/lib/elements/satin_column.py +++ b/lib/elements/satin_column.py @@ -29,22 +29,23 @@ class SatinColumn(EmbroideryElement): @property @param('zigzag_spacing_mm', - _('Zig-zag spacing (peak-to-peak)'), - tooltip=_('Peak-to-peak distance between zig-zags.'), - unit='mm', - type='float', - default=0.4) + _('Zig-zag spacing (peak-to-peak)'), + tooltip=_('Peak-to-peak distance between zig-zags.'), + unit='mm', + type='float', + default=0.4) def zigzag_spacing(self): # peak-to-peak distance between zigzags return max(self.get_float_param("zigzag_spacing_mm", 0.4), 0.01) @property - @param('pull_compensation_mm', - _('Pull compensation'), - tooltip=_('Satin stitches pull the fabric together, resulting in a column narrower than you draw in Inkscape. This setting expands each pair of needle penetrations outward from the center of the satin column.'), - unit='mm', - type='float', - default=0) + @param( + 'pull_compensation_mm', + _('Pull compensation'), + tooltip=_('Satin stitches pull the fabric together, resulting in a column narrower than you draw in Inkscape. This setting expands each pair of needle penetrations outward from the center of the satin column.'), + unit='mm', + type='float', + default=0) def pull_compensation(self): # In satin stitch, the stitches have a tendency to pull together and # narrow the entire column. We can compensate for this by stitching @@ -65,12 +66,12 @@ class SatinColumn(EmbroideryElement): @property @param('contour_underlay_inset_mm', - _('Contour underlay inset amount'), - tooltip=_('Shrink the outline, to prevent the underlay from showing around the outside of the satin column.'), - unit='mm', - group=_('Contour Underlay'), - type='float', - default=0.4) + _('Contour underlay inset amount'), + tooltip=_('Shrink the outline, to prevent the underlay from showing around the outside of the satin column.'), + unit='mm', + group=_('Contour Underlay'), + type='float', + default=0.4) def contour_underlay_inset(self): # how far inside the edge of the column to stitch the underlay return self.get_float_param("contour_underlay_inset_mm", 0.4) @@ -94,23 +95,23 @@ class SatinColumn(EmbroideryElement): @property @param('zigzag_underlay_spacing_mm', - _('Zig-Zag spacing (peak-to-peak)'), - tooltip=_('Distance between peaks of the zig-zags.'), - unit='mm', - group=_('Zig-zag Underlay'), - type='float', - default=3) + _('Zig-Zag spacing (peak-to-peak)'), + tooltip=_('Distance between peaks of the zig-zags.'), + unit='mm', + group=_('Zig-zag Underlay'), + type='float', + default=3) def zigzag_underlay_spacing(self): return max(self.get_float_param("zigzag_underlay_spacing_mm", 3), 0.01) @property @param('zigzag_underlay_inset_mm', - _('Inset amount'), - tooltip=_('default: half of contour underlay inset'), - unit='mm', - group=_('Zig-zag Underlay'), - type='float', - default="") + _('Inset amount'), + tooltip=_('default: half of contour underlay inset'), + unit='mm', + group=_('Zig-zag Underlay'), + type='float', + default="") def zigzag_underlay_inset(self): # how far in from the edge of the satin the points in the zigzags # should be @@ -147,7 +148,6 @@ class SatinColumn(EmbroideryElement): else: return self.flatten_beziers_with_rungs() - def flatten_beziers_with_rungs(self): input_paths = [self.flatten([path]) for path in self.csp] input_paths = [shgeo.LineString(path[0]) for path in input_paths] @@ -176,16 +176,17 @@ class SatinColumn(EmbroideryElement): #print >> dbg, "rails and rungs", [str(rail) for rail in rails], [str(rung) for rung in rungs] if len(linestrings.geoms) < len(rungs.geoms) + 1: - self.fatal(_("satin column: One or more of the rungs doesn't intersect both rails.") + " " + _("Each rail should intersect both rungs once.")) + self.fatal(_("satin column: One or more of the rungs doesn't intersect both rails.") + + " " + _("Each rail should intersect both rungs once.")) elif len(linestrings.geoms) > len(rungs.geoms) + 1: - self.fatal(_("satin column: One or more of the rungs intersects the rails more than once.") + " " + _("Each rail should intersect both rungs once.")) + self.fatal(_("satin column: One or more of the rungs intersects the rails more than once.") + + " " + _("Each rail should intersect both rungs once.")) paths = [[Point(*coord) for coord in ls.coords] for ls in linestrings.geoms] result.append(paths) return zip(*result) - def simple_flatten_beziers(self): # Given a pair of paths made up of bezier segments, flatten # each individual bezier segment into line segments that approximate @@ -223,8 +224,8 @@ class SatinColumn(EmbroideryElement): if len(self.csp) == 2: if len(self.csp[0]) != len(self.csp[1]): - self.fatal(_("satin column: object %(id)s has two paths with an unequal number of points (%(length1)d and %(length2)d)") % \ - dict(id=node_id, length1=len(self.csp[0]), length2=len(self.csp[1]))) + self.fatal(_("satin column: object %(id)s has two paths with an unequal number of points (%(length1)d and %(length2)d)") % + dict(id=node_id, length1=len(self.csp[0]), length2=len(self.csp[1]))) def offset_points(self, pos1, pos2, offset_px): # Expand or contract two points about their midpoint. This is @@ -443,7 +444,6 @@ class SatinColumn(EmbroideryElement): return patch - def to_patches(self, last_patch): # Stitch a variable-width satin column, zig-zagging between two paths. diff --git a/lib/elements/stroke.py b/lib/elements/stroke.py index e84d5e79..183ef23b 100644 --- a/lib/elements/stroke.py +++ b/lib/elements/stroke.py @@ -28,44 +28,45 @@ class Stroke(EmbroideryElement): @property @param('running_stitch_length_mm', - _('Running stitch length'), - tooltip=_('Length of stitches in running stitch mode.'), - unit='mm', - type='float', - default=1.5, - sort_index=3) + _('Running stitch length'), + tooltip=_('Length of stitches in running stitch mode.'), + unit='mm', + type='float', + default=1.5, + sort_index=3) def running_stitch_length(self): return max(self.get_float_param("running_stitch_length_mm", 1.5), 0.01) @property - @param('bean_stitch_repeats', - _('Bean stitch number of repeats'), - tooltip=_('Backtrack each stitch this many times. A value of 1 would triple each stitch (forward, back, forward). A value of 2 would quintuple each stitch, etc. Only applies to running stitch.'), - type='int', - default=0, - sort_index=2) + @param( + 'bean_stitch_repeats', + _('Bean stitch number of repeats'), + tooltip=_('Backtrack each stitch this many times. A value of 1 would triple each stitch (forward, back, forward). A value of 2 would quintuple each stitch, etc. Only applies to running stitch.'), + type='int', + default=0, + sort_index=2) def bean_stitch_repeats(self): return self.get_int_param("bean_stitch_repeats", 0) @property @param('zigzag_spacing_mm', - _('Zig-zag spacing (peak-to-peak)'), - tooltip=_('Length of stitches in zig-zag mode.'), - unit='mm', - type='float', - default=0.4, - sort_index=3) + _('Zig-zag spacing (peak-to-peak)'), + tooltip=_('Length of stitches in zig-zag mode.'), + unit='mm', + type='float', + default=0.4, + sort_index=3) @cache def zigzag_spacing(self): return max(self.get_float_param("zigzag_spacing_mm", 0.4), 0.01) @property @param('repeats', - _('Repeats'), - tooltip=_('Defines how many times to run down and back along the path.'), - type='int', - default="1", - sort_index=1) + _('Repeats'), + tooltip=_('Defines how many times to run down and back along the path.'), + type='int', + default="1", + sort_index=1) def repeats(self): return self.get_int_param("repeats", 1) @@ -86,11 +87,11 @@ class Stroke(EmbroideryElement): @property @param('manual_stitch', - _('Manual stitch placement'), - tooltip=_("Stitch every node in the path. Stitch length and zig-zag spacing are ignored."), - type='boolean', - default=False, - sort_index=0) + _('Manual stitch placement'), + tooltip=_("Stitch every node in the path. Stitch length and zig-zag spacing are ignored."), + type='boolean', + default=False, + sort_index=0) def manual_stitch_mode(self): return self.get_boolean_param('manual_stitch') @@ -121,9 +122,9 @@ class Stroke(EmbroideryElement): global warned_about_legacy_running_stitch if not warned_about_legacy_running_stitch: warned_about_legacy_running_stitch = True - print >> sys.stderr, _("Legacy running stitch setting detected!\n\nIt looks like you're using a stroke " + \ - "smaller than 0.5 units to indicate a running stitch, which is deprecated. Instead, please set " + \ - "your stroke to be dashed to indicate running stitch. Any kind of dash will work.") + print >> sys.stderr, _("Legacy running stitch setting detected!\n\nIt looks like you're using a stroke " + + "smaller than 0.5 units to indicate a running stitch, which is deprecated. Instead, please set " + + "your stroke to be dashed to indicate running stitch. Any kind of dash will work.") # still allow the deprecated setting to work in order to support old files return True @@ -174,7 +175,6 @@ class Stroke(EmbroideryElement): return Patch(self.color, stitches) - def to_patches(self, last_patch): patches = [] diff --git a/lib/extensions/__init__.py b/lib/extensions/__init__.py index 1606795c..b865db4c 100644 --- a/lib/extensions/__init__.py +++ b/lib/extensions/__init__.py @@ -19,4 +19,4 @@ for item in locals().values(): if inspect.isclass(item) and \ issubclass(item, InkstitchExtension) and \ item is not InkstitchExtension: - extensions.append(item) + extensions.append(item) diff --git a/lib/extensions/base.py b/lib/extensions/base.py index 1794b68c..07eaa40c 100644 --- a/lib/extensions/base.py +++ b/lib/extensions/base.py @@ -109,11 +109,11 @@ class InkstitchExtension(inkex.Effect): g.set("style", "display:none") def no_elements_error(self): - if self.selected: - inkex.errormsg(_("No embroiderable paths selected.")) - else: - inkex.errormsg(_("No embroiderable paths found in document.")) - inkex.errormsg(_("Tip: use Path -> Object to Path to convert non-paths.")) + if self.selected: + inkex.errormsg(_("No embroiderable paths selected.")) + else: + inkex.errormsg(_("No embroiderable paths found in document.")) + inkex.errormsg(_("Tip: use Path -> Object to Path to convert non-paths.")) def descendants(self, node, selected=False): nodes = [] @@ -176,7 +176,6 @@ class InkstitchExtension(inkex.Effect): return classes - def get_elements(self): self.elements = [] for node in self.get_nodes(): @@ -212,7 +211,6 @@ class InkstitchExtension(inkex.Effect): return svg_filename - def parse(self): """Override inkex.Effect to add Ink/Stitch xml namespace""" diff --git a/lib/extensions/convert_to_satin.py b/lib/extensions/convert_to_satin.py index dd5a9bc2..d27e42cc 100644 --- a/lib/extensions/convert_to_satin.py +++ b/lib/extensions/convert_to_satin.py @@ -51,7 +51,9 @@ class ConvertToSatin(InkstitchExtension): try: rails, rungs = self.path_to_satin(path, element.stroke_width, style_args) except SelfIntersectionError: - inkex.errormsg(_("Cannot convert %s to a satin column because it intersects itself. Try breaking it up into multiple paths.") % element.node.get('id')) + inkex.errormsg( + _("Cannot convert %s to a satin column because it intersects itself. Try breaking it up into multiple paths.") % + element.node.get('id')) # revert any changes we've made self.document = deepcopy(self.original_document) @@ -84,7 +86,7 @@ class ConvertToSatin(InkstitchExtension): """Convert svg line join style to shapely parallel offset arguments.""" args = { - 'join_style': shgeo.JOIN_STYLE.round + 'join_style': shgeo.JOIN_STYLE.round } element_join_style = element.get_style('stroke-linejoin') @@ -113,7 +115,7 @@ class ConvertToSatin(InkstitchExtension): # path intersects itself, when taking its stroke width into consideration. See # the last example for parallel_offset() in the Shapely documentation: # https://shapely.readthedocs.io/en/latest/manual.html#object.parallel_offset - raise SelfIntersectionError() + raise SelfIntersectionError() # for whatever reason, shapely returns a right-side offset's coordinates in reverse left_rail = list(left_rail.coords) @@ -244,7 +246,7 @@ class ConvertToSatin(InkstitchExtension): # millimeters before this one. if last_rung_center is not None and \ (rung_center - last_rung_center).length() < 2 * PIXELS_PER_MM: - continue + continue else: last_rung_center = rung_center @@ -269,7 +271,6 @@ class ConvertToSatin(InkstitchExtension): return rungs - def satin_to_svg_node(self, rails, rungs, correction_transform): d = "" for path in chain(rails, rungs): @@ -279,11 +280,11 @@ class ConvertToSatin(InkstitchExtension): d += " " return inkex.etree.Element(SVG_PATH_TAG, - { - "id": self.uniqueId("path"), - "style": "stroke:#000000;stroke-width:1px;fill:none", - "transform": correction_transform, - "d": d, - "embroider_satin_column": "true", - } - ) + { + "id": self.uniqueId("path"), + "style": "stroke:#000000;stroke-width:1px;fill:none", + "transform": correction_transform, + "d": d, + "embroider_satin_column": "true", + } + ) diff --git a/lib/extensions/flip.py b/lib/extensions/flip.py index d8d78cb5..5bea510f 100644 --- a/lib/extensions/flip.py +++ b/lib/extensions/flip.py @@ -7,6 +7,7 @@ from .base import InkstitchExtension from ..i18n import _ from ..elements import SatinColumn + class Flip(InkstitchExtension): def subpath_to_linestring(self, subpath): return shgeo.LineString() diff --git a/lib/extensions/input.py b/lib/extensions/input.py index cb5ac452..e450bef6 100644 --- a/lib/extensions/input.py +++ b/lib/extensions/input.py @@ -28,12 +28,11 @@ class Input(object): trim=(command == pyembroidery.TRIM)) extents = stitch_plan.extents - svg = etree.Element("svg", nsmap=inkex.NSS, attrib= - { - "width": str(extents[0] * 2), - "height": str(extents[1] * 2), - "viewBox": "0 0 %s %s" % (extents[0] * 2, extents[1] * 2), - }) + svg = etree.Element("svg", nsmap=inkex.NSS, attrib={ + "width": str(extents[0] * 2), + "height": str(extents[1] * 2), + "viewBox": "0 0 %s %s" % (extents[0] * 2, extents[1] * 2), + }) render_stitch_plan(svg, stitch_plan) # rename the Stitch Plan layer so that it doesn't get overwritten by Embroider diff --git a/lib/extensions/install.py b/lib/extensions/install.py index 42a92113..2863bef0 100644 --- a/lib/extensions/install.py +++ b/lib/extensions/install.py @@ -28,22 +28,21 @@ class InstallerFrame(wx.Frame): text_sizer = wx.BoxSizer(wx.HORIZONTAL) text = _('Ink/Stitch can install files ("add-ons") that make it easier to use Inkscape to create machine embroidery designs. These add-ons will be installed:') + \ - "\n\n • " + _("thread manufacturer color palettes") + \ - "\n • " + _("Ink/Stitch visual commands (Object -> Symbols...)") + "\n\n • " + _("thread manufacturer color palettes") + "\n • " + _("Ink/Stitch visual commands (Object -> Symbols...)") static_text = wx.StaticText(panel, label=text) font = wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL) static_text.SetFont(font) - text_sizer.Add(static_text, proportion=0, flag=wx.ALL|wx.EXPAND, border=10) - sizer.Add(text_sizer, proportion=3, flag=wx.ALL|wx.EXPAND, border=0) + text_sizer.Add(static_text, proportion=0, flag=wx.ALL | wx.EXPAND, border=10) + sizer.Add(text_sizer, proportion=3, flag=wx.ALL | wx.EXPAND, border=0) buttons_sizer = wx.BoxSizer(wx.HORIZONTAL) install_button = wx.Button(panel, wx.ID_ANY, _("Install")) install_button.SetBitmap(wx.ArtProvider.GetBitmap(wx.ART_TICK_MARK)) - buttons_sizer.Add(install_button, proportion=0, flag=wx.ALIGN_RIGHT|wx.ALL, border=5) + buttons_sizer.Add(install_button, proportion=0, flag=wx.ALIGN_RIGHT | wx.ALL, border=5) cancel_button = wx.Button(panel, wx.ID_CANCEL, _("Cancel")) - buttons_sizer.Add(cancel_button, proportion=0, flag=wx.ALIGN_RIGHT|wx.ALL, border=5) - sizer.Add(buttons_sizer, proportion=1, flag=wx.ALIGN_RIGHT|wx.ALIGN_BOTTOM) + buttons_sizer.Add(cancel_button, proportion=0, flag=wx.ALIGN_RIGHT | wx.ALL, border=5) + sizer.Add(buttons_sizer, proportion=1, flag=wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM) panel.SetSizer(sizer) panel.Layout() @@ -63,7 +62,7 @@ class InstallerFrame(wx.Frame): try: self.install_addons('palettes') self.install_addons('symbols') - except Exception, e: + except Exception as e: wx.MessageDialog(self, _('Inkscape add-on installation failed') + ': \n' + traceback.format_exc(), _('Installation Failed'), @@ -97,6 +96,7 @@ class InstallerFrame(wx.Frame): for palette_file in files: shutil.copy(palette_file, dest) + class Install(inkex.Effect): def effect(self): app = wx.App() diff --git a/lib/extensions/layer_commands.py b/lib/extensions/layer_commands.py index 576af044..b9be2b27 100644 --- a/lib/extensions/layer_commands.py +++ b/lib/extensions/layer_commands.py @@ -36,15 +36,15 @@ class LayerCommands(CommandsExtension): self.ensure_symbol(command) node = inkex.etree.SubElement(self.current_layer, SVG_USE_TAG, - { - "id": self.uniqueId("use"), - INKSCAPE_LABEL: _("Ink/Stitch Command") + ": %s" % get_command_description(command), - XLINK_HREF: "#inkstitch_%s" % command, - "height": "100%", - "width": "100%", - "x": str(i * 20), - "y": "-10", - "transform": correction_transform - }) + { + "id": self.uniqueId("use"), + INKSCAPE_LABEL: _("Ink/Stitch Command") + ": %s" % get_command_description(command), + XLINK_HREF: "#inkstitch_%s" % command, + "height": "100%", + "width": "100%", + "x": str(i * 20), + "y": "-10", + "transform": correction_transform + }) namedview = self.document.xpath("//sodipodi:namedview", namespaces=inkex.NSS) diff --git a/lib/extensions/object_commands.py b/lib/extensions/object_commands.py index e9ee6063..483f2a0a 100644 --- a/lib/extensions/object_commands.py +++ b/lib/extensions/object_commands.py @@ -24,18 +24,18 @@ class ObjectCommands(CommandsExtension): end_pos = element.shape.centroid path = inkex.etree.Element(SVG_PATH_TAG, - { - "id": self.uniqueId("connector"), - "d": "M %s,%s %s,%s" % (start_pos[0], start_pos[1], end_pos.x, end_pos.y), - "style": "stroke:#000000;stroke-width:1px;stroke-opacity:0.5;fill:none;", - CONNECTION_START: "#%s" % symbol.get('id'), - CONNECTION_END: "#%s" % element.node.get('id'), - CONNECTOR_TYPE: "polyline", - - # l10n: the name of the line that connects a command to the object it applies to - INKSCAPE_LABEL: _("connector") - } - ) + { + "id": self.uniqueId("connector"), + "d": "M %s,%s %s,%s" % (start_pos[0], start_pos[1], end_pos.x, end_pos.y), + "style": "stroke:#000000;stroke-width:1px;stroke-opacity:0.5;fill:none;", + CONNECTION_START: "#%s" % symbol.get('id'), + CONNECTION_END: "#%s" % element.node.get('id'), + CONNECTOR_TYPE: "polyline", + + # l10n: the name of the line that connects a command to the object it applies to + INKSCAPE_LABEL: _("connector") + } + ) symbol.getparent().insert(0, path) @@ -75,26 +75,26 @@ class ObjectCommands(CommandsExtension): pos = self.get_command_pos(element, i, len(commands)) group = inkex.etree.SubElement(element.node.getparent(), SVG_GROUP_TAG, - { - "id": self.uniqueId("group"), - INKSCAPE_LABEL: _("Ink/Stitch Command") + ": %s" % get_command_description(command), - "transform": get_correction_transform(element.node) - } + { + "id": self.uniqueId("group"), + INKSCAPE_LABEL: _("Ink/Stitch Command") + ": %s" % get_command_description(command), + "transform": get_correction_transform(element.node) + } ) symbol = inkex.etree.SubElement(group, SVG_USE_TAG, - { - "id": self.uniqueId("use"), - XLINK_HREF: "#inkstitch_%s" % command, - "height": "100%", - "width": "100%", - "x": str(pos.x), - "y": str(pos.y), - - # l10n: the name of a command symbol (example: scissors icon for trim command) - INKSCAPE_LABEL: _("command marker"), - } - ) + { + "id": self.uniqueId("use"), + XLINK_HREF: "#inkstitch_%s" % command, + "height": "100%", + "width": "100%", + "x": str(pos.x), + "y": str(pos.y), + + # l10n: the name of a command symbol (example: scissors icon for trim command) + INKSCAPE_LABEL: _("command marker"), + } + ) self.add_connector(symbol, element) diff --git a/lib/extensions/output.py b/lib/extensions/output.py index f3bb0a80..090cd3a9 100644 --- a/lib/extensions/output.py +++ b/lib/extensions/output.py @@ -11,6 +11,7 @@ from ..stitch_plan import patches_to_stitch_plan from ..svg import render_stitch_plan, PIXELS_PER_MM from ..utils.io import save_stdout + class Output(InkstitchExtension): def __init__(self, *args, **kwargs): InkstitchExtension.__init__(self) diff --git a/lib/extensions/print_pdf.py b/lib/extensions/print_pdf.py index 6e2eff58..ee3dc316 100644 --- a/lib/extensions/print_pdf.py +++ b/lib/extensions/print_pdf.py @@ -44,7 +44,7 @@ def load_defaults(): with open(defaults_path(), 'r') as defaults_file: defaults = json.load(defaults_file) return defaults - except: + except BaseException: return {} @@ -196,11 +196,11 @@ class PrintPreviewServer(Thread): threads = [] for color_block in self.stitch_plan: threads.append({ - 'hex': color_block.color.hex_digits, - 'name': color_block.color.name, - 'manufacturer': color_block.color.manufacturer, - 'number': color_block.color.number, - }) + 'hex': color_block.color.hex_digits, + 'name': color_block.color.name, + 'manufacturer': color_block.color.manufacturer, + 'number': color_block.color.number, + }) return jsonify(threads) @@ -225,10 +225,10 @@ class PrintPreviewServer(Thread): break if self.last_request_time is not None and \ - (time.time() - self.last_request_time) > 3: - self.stop() - break - except: + (time.time() - self.last_request_time) > 3: + self.stop() + break + except BaseException: # seems like sometimes this thread blows up during shutdown pass @@ -244,7 +244,7 @@ class PrintPreviewServer(Thread): while True: try: self.app.run(self.host, self.port, threaded=True) - except socket.error, e: + except socket.error as e: if e.errno == errno.EADDRINUSE: self.port += 1 continue @@ -265,11 +265,11 @@ class PrintInfoFrame(wx.Frame): text = wx.StaticText(panel, label=_("A print preview has been opened in your web browser. This window will stay open in order to communicate with the JavaScript code running in your browser.\n\nThis window will close after you close the print preview in your browser, or you can close it manually if necessary.")) font = wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.NORMAL) text.SetFont(font) - sizer.Add(text, proportion=1, flag=wx.ALL|wx.EXPAND, border=20) + sizer.Add(text, proportion=1, flag=wx.ALL | wx.EXPAND, border=20) stop_button = wx.Button(panel, id=wx.ID_CLOSE) stop_button.Bind(wx.EVT_BUTTON, self.close_button_clicked) - sizer.Add(stop_button, proportion=0, flag=wx.ALIGN_CENTER|wx.ALL, border=10) + sizer.Add(stop_button, proportion=0, flag=wx.ALIGN_CENTER | wx.ALL, border=10) panel.SetSizer(sizer) panel.Layout() @@ -289,13 +289,13 @@ class PrintInfoFrame(wx.Frame): class Print(InkstitchExtension): def build_environment(self): - if getattr( sys, 'frozen', False ) : + if getattr(sys, 'frozen', False): template_dir = os.path.join(sys._MEIPASS, "print", "templates") else: template_dir = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..", "print", "templates")) env = Environment( - loader = FileSystemLoader(template_dir), + loader=FileSystemLoader(template_dir), autoescape=select_autoescape(['html', 'xml']), extensions=['jinja2.ext.i18n'] ) @@ -308,8 +308,8 @@ class Print(InkstitchExtension): def strip_namespaces(self, svg): # namespace prefixes seem to trip up HTML, so get rid of them for element in svg.iter(): - if element.tag[0]=='{': - element.tag = element.tag[element.tag.index('}',1) + 1:] + if element.tag[0] == '{': + element.tag = element.tag[element.tag.index('}', 1) + 1:] def render_svgs(self, stitch_plan, realistic=False): svg = deepcopy(self.document).getroot() @@ -352,25 +352,25 @@ class Print(InkstitchExtension): template = env.get_template('index.html') return template.render( - view = {'client_overview': False, 'client_detailedview': False, 'operator_overview': True, 'operator_detailedview': True}, - logo = {'src' : '', 'title' : 'LOGO'}, - date = date.today(), - client = "", - job = { - 'title': '', - 'num_colors': stitch_plan.num_colors, - 'num_color_blocks': len(stitch_plan), - 'num_stops': stitch_plan.num_stops, - 'num_trims': stitch_plan.num_trims, - 'dimensions': stitch_plan.dimensions_mm, - 'num_stitches': stitch_plan.num_stitches, - 'estimated_time': '', # TODO - 'estimated_thread': '', # TODO - }, - svg_overview = overview_svg, - color_blocks = stitch_plan.color_blocks, - palettes = ThreadCatalog().palette_names(), - selected_palette = selected_palette, + view={'client_overview': False, 'client_detailedview': False, 'operator_overview': True, 'operator_detailedview': True}, + logo={'src': '', 'title': 'LOGO'}, + date=date.today(), + client="", + job={ + 'title': '', + 'num_colors': stitch_plan.num_colors, + 'num_color_blocks': len(stitch_plan), + 'num_stops': stitch_plan.num_stops, + 'num_trims': stitch_plan.num_trims, + 'dimensions': stitch_plan.dimensions_mm, + 'num_stitches': stitch_plan.num_stitches, + 'estimated_time': '', # TODO + 'estimated_thread': '', # TODO + }, + svg_overview=overview_svg, + color_blocks=stitch_plan.color_blocks, + palettes=ThreadCatalog().palette_names(), + selected_palette=selected_palette, ) def effect(self): @@ -396,12 +396,12 @@ class Print(InkstitchExtension): html = self.render_html(stitch_plan, overview_svg, palette) print_server = PrintPreviewServer( - html=html, - metadata=self.get_inkstitch_metadata(), - stitch_plan=stitch_plan, - realistic_overview_svg=realistic_overview_svg, - realistic_color_block_svgs=realistic_color_block_svgs - ) + html=html, + metadata=self.get_inkstitch_metadata(), + stitch_plan=stitch_plan, + realistic_overview_svg=realistic_overview_svg, + realistic_color_block_svgs=realistic_color_block_svgs + ) print_server.start() time.sleep(1) diff --git a/lib/i18n.py b/lib/i18n.py index 419c03dc..045fa1b2 100644 --- a/lib/i18n.py +++ b/lib/i18n.py @@ -9,8 +9,11 @@ locale_dir = None # Use N_ to mark a string for translation but _not_ immediately translate it. # reference: https://docs.python.org/3/library/gettext.html#deferred-translations # Makefile configures pybabel to treat N_() the same as _() + + def N_(message): return message + def _set_locale_dir(): global locale_dir @@ -22,11 +25,13 @@ def _set_locale_dir(): locale_dir = os.path.join(locale_dir, 'locales') + def localize(languages=None): global translation, _ translation = gettext.translation("inkstitch", locale_dir, fallback=True) _ = translation.gettext + _set_locale_dir() localize() diff --git a/lib/inx/generate.py b/lib/inx/generate.py index f9ed799b..1cf347f2 100644 --- a/lib/inx/generate.py +++ b/lib/inx/generate.py @@ -5,6 +5,7 @@ from .outputs import generate_output_inx_files from .extensions import generate_extension_inx_files from .utils import iterate_inx_locales, inx_path + def generate_inx_files(): for locale in iterate_inx_locales(): generate_input_inx_files() diff --git a/lib/inx/utils.py b/lib/inx/utils.py index 6103f360..6670cfcb 100644 --- a/lib/inx/utils.py +++ b/lib/inx/utils.py @@ -13,10 +13,11 @@ template_path = os.path.join(_top_path, "templates") current_translation = default_translation current_locale = "en_US" + def build_environment(): env = Environment( - loader = FileSystemLoader(template_path), - autoescape = True, + loader=FileSystemLoader(template_path), + autoescape=True, extensions=['jinja2.ext.i18n'] ) @@ -25,11 +26,13 @@ def build_environment(): return env + def write_inx_file(name, contents): inx_file_name = "inkstitch_%s_%s.inx" % (name, current_locale) with open(os.path.join(inx_path, inx_file_name), 'w') as inx_file: print >> inx_file, contents + def iterate_inx_locales(): global current_translation, current_locale diff --git a/lib/output.py b/lib/output.py index 0d7f9918..eed665ed 100644 --- a/lib/output.py +++ b/lib/output.py @@ -19,6 +19,7 @@ def get_command(stitch): else: return pyembroidery.NEEDLE_AT + def _string_to_floats(string): floats = string.split(',') return [float(num) for num in floats] @@ -32,7 +33,7 @@ def get_origin(svg): all_guides = namedview.findall(inkex.addNS('guide', 'sodipodi')) label_attribute = inkex.addNS('label', 'inkscape') guides = [guide for guide in all_guides - if guide.get(label_attribute, "").startswith("embroidery origin")] + if guide.get(label_attribute, "").startswith("embroidery origin")] # document size used below doc_size = list(get_doc_size(svg)) @@ -57,7 +58,6 @@ def get_origin(svg): position = Point(*_string_to_floats(guide.get('position'))) position.y = doc_size[1] - position.y - # This one baffles me. I think inkscape might have gotten the order of # their vector wrong? parts = _string_to_floats(guide.get('orientation')) @@ -98,17 +98,17 @@ def write_embroidery_file(file_path, stitch_plan, svg): # also multiply by 10 to get tenths of a millimeter as required by pyembroidery scale = 10 / PIXELS_PER_MM - settings = { - # correct for the origin - "translate": -origin, + settings = { + # correct for the origin + "translate": -origin, - # convert from pixels to millimeters - # also multiply by 10 to get tenths of a millimeter as required by pyembroidery - "scale": (scale, scale), + # convert from pixels to millimeters + # also multiply by 10 to get tenths of a millimeter as required by pyembroidery + "scale": (scale, scale), - # This forces a jump at the start of the design and after each trim, - # even if we're close enough not to need one. - "full_jump": True, - } + # This forces a jump at the start of the design and after each trim, + # even if we're close enough not to need one. + "full_jump": True, + } pyembroidery.write(pattern, file_path, settings) diff --git a/lib/stitch_plan/stitch.py b/lib/stitch_plan/stitch.py index 5230efec..5fe10fb8 100644 --- a/lib/stitch_plan/stitch.py +++ b/lib/stitch_plan/stitch.py @@ -15,15 +15,15 @@ class Stitch(Point): def __repr__(self): return "Stitch(%s, %s, %s, %s, %s, %s, %s, %s%s)" % (self.x, - self.y, - self.color, - "JUMP" if self.jump else " ", - "TRIM" if self.trim else " ", - "STOP" if self.stop else " ", - "NO TIES" if self.no_ties else " ", - "FAKE " if self.fake_color_change else "", - "COLOR CHANGE" if self.color_change else " " - ) + self.y, + self.color, + "JUMP" if self.jump else " ", + "TRIM" if self.trim else " ", + "STOP" if self.stop else " ", + "NO TIES" if self.no_ties else " ", + "FAKE " if self.fake_color_change else "", + "COLOR CHANGE" if self.color_change else " " + ) def copy(self): return Stitch(self.x, self.y, self.color, self.jump, self.stop, self.trim, self.color_change, self.no_ties) diff --git a/lib/stitches/auto_fill.py b/lib/stitches/auto_fill.py index 097ab1d9..e777d026 100644 --- a/lib/stitches/auto_fill.py +++ b/lib/stitches/auto_fill.py @@ -15,6 +15,7 @@ from ..utils.geometry import Point as InkstitchPoint, cut class MaxQueueLengthExceeded(Exception): pass + class PathEdge(object): OUTLINE_KEYS = ("outline", "extra", "initial") SEGMENT_KEY = "segment" @@ -39,6 +40,7 @@ class PathEdge(object): def is_segment(self): return self.key == self.SEGMENT_KEY + def auto_fill(shape, angle, row_spacing, end_row_spacing, max_stitch_length, running_stitch_length, staggers, starting_point, ending_point=None): stitches = [] @@ -65,7 +67,7 @@ def which_outline(shape, coords): point = shapely.geometry.Point(*coords) outlines = enumerate(list(shape.boundary)) - closest = min(outlines, key=lambda (index, outline): outline.distance(point)) + closest = min(outlines, key=lambda index_outline: index_outline[1].distance(point)) return closest[0] @@ -129,11 +131,11 @@ def build_graph(shape, segments, angle, row_spacing): # Tag each node with its index and projection. graph.add_node(node, index=outline_index, projection=outline_projection) - nodes = list(graph.nodes(data=True)) # returns a list of tuples: [(node, {data}), (node, {data}) ...] + nodes = list(graph.nodes(data=True)) # returns a list of tuples: [(node, {data}), (node, {data}) ...] nodes.sort(key=lambda node: (node[1]['index'], node[1]['projection'])) for outline_index, nodes in groupby(nodes, key=lambda node: node[1]['index']): - nodes = [ node for node, data in nodes ] + nodes = [node for node, data in nodes] # heuristic: change the order I visit the nodes in the outline if necessary. # If the start and endpoints are in the same row, I can't tell which row @@ -163,7 +165,6 @@ def build_graph(shape, segments, angle, row_spacing): if i % 2 == edge_set: graph.add_edge(node1, node2, key="extra") - if not networkx.is_eulerian(graph): raise Exception(_("Unable to autofill. This most often happens because your shape is made up of multiple sections that aren't connected.")) @@ -193,13 +194,13 @@ def bfs_for_loop(graph, starting_node, max_queue_length=2000): # get a list of neighbors paired with the key of the edge I can follow to get there neighbors = [ - (node, key) - for node, adj in graph.adj[ending_node].iteritems() - for key in adj - ] + (node, key) + for node, adj in graph.adj[ending_node].iteritems() + for key in adj + ] # heuristic: try grating segments first - neighbors.sort(key=lambda (dest, key): key == "segment", reverse=True) + neighbors.sort(key=lambda dest_key: dest_key[1] == "segment", reverse=True) for next_node, key in neighbors: # skip if I've already followed this edge @@ -295,6 +296,7 @@ def insert_loop(path, loop): path[i:i] = loop + def nearest_node_on_outline(graph, point, outline_index=0): point = shapely.geometry.Point(*point) outline_nodes = [node for node, data in graph.nodes(data=True) if data['index'] == outline_index] @@ -302,16 +304,18 @@ def nearest_node_on_outline(graph, point, outline_index=0): return nearest + def get_outline_nodes(graph, outline_index=0): - outline_nodes = [(node, data['projection']) \ - for node, data \ - in graph.nodes(data=True) \ + outline_nodes = [(node, data['projection']) + for node, data + in graph.nodes(data=True) if data['index'] == outline_index] - outline_nodes.sort(key=lambda (node, projection): projection) + outline_nodes.sort(key=lambda node_projection: node_projection[1]) outline_nodes = [node for node, data in outline_nodes] return outline_nodes + def find_initial_path(graph, starting_point, ending_point=None): starting_node = nearest_node_on_outline(graph, starting_point) @@ -340,6 +344,7 @@ def find_initial_path(graph, starting_point, ending_point=None): return path + def find_stitch_path(graph, segments, starting_point=None, ending_point=None): """find a path that visits every grating segment exactly once diff --git a/lib/stitches/fill.py b/lib/stitches/fill.py index 14971cb4..ac8b52ee 100644 --- a/lib/stitches/fill.py +++ b/lib/stitches/fill.py @@ -37,6 +37,7 @@ def adjust_stagger(stitch, angle, row_spacing, max_stitch_length, staggers): return stitch - offset * east(angle) + def stitch_row(stitches, beg, end, angle, row_spacing, max_stitch_length, staggers): # We want our stitches to look like this: # @@ -163,6 +164,7 @@ def intersect_region_with_grating(shape, angle, row_spacing, end_row_spacing=Non return rows + def section_to_stitches(group_of_segments, angle, row_spacing, max_stitch_length, staggers): stitches = [] first_segment = True diff --git a/lib/svg/path.py b/lib/svg/path.py index 0a8dcb74..51100e38 100644 --- a/lib/svg/path.py +++ b/lib/svg/path.py @@ -3,6 +3,7 @@ import cubicsuperpath from .units import get_viewbox_transform + def apply_transforms(path, node): transform = get_node_transform(node) @@ -11,6 +12,7 @@ def apply_transforms(path, node): return path + def get_node_transform(node): # start with the identity transform transform = [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]] @@ -26,6 +28,7 @@ def get_node_transform(node): return transform + def get_correction_transform(node, child=False): """Get a transform to apply to new siblings or children of this SVG node""" diff --git a/lib/svg/realistic_rendering.py b/lib/svg/realistic_rendering.py index e31534da..5af7e9a6 100644 --- a/lib/svg/realistic_rendering.py +++ b/lib/svg/realistic_rendering.py @@ -102,6 +102,7 @@ realistic_filter = """ """ + def realistic_stitch(start, end): """Generate a stitch vector path given a start and end point.""" diff --git a/lib/svg/svg.py b/lib/svg/svg.py index 48b1343a..b1cc91d9 100644 --- a/lib/svg/svg.py +++ b/lib/svg/svg.py @@ -1,4 +1,6 @@ -import simpletransform, simplestyle, inkex +import simpletransform +import simplestyle +import inkex from .units import get_viewbox_transform from .tags import SVG_GROUP_TAG, INKSCAPE_LABEL, INKSCAPE_GROUPMODE, SVG_PATH_TAG, SVG_DEFS_TAG @@ -11,13 +13,13 @@ def color_block_to_point_lists(color_block): point_lists = [[]] for stitch in color_block: - if stitch.trim: - if point_lists[-1]: - point_lists.append([]) - continue + if stitch.trim: + if point_lists[-1]: + point_lists.append([]) + continue - if not stitch.jump and not stitch.color_change: - point_lists[-1].append(stitch.as_tuple()) + if not stitch.jump and not stitch.color_change: + point_lists[-1].append(stitch.as_tuple()) return point_lists @@ -51,13 +53,14 @@ def color_block_to_realistic_stitches(color_block, svg): 'stroke': 'none', 'filter': 'url(#realistic-stitch-filter)' }), - 'd': realistic_stitch(start, point), - 'transform': get_correction_transform(svg) - })) + 'd': realistic_stitch(start, point), + 'transform': get_correction_transform(svg) + })) start = point return paths + def color_block_to_paths(color_block, svg): paths = [] # We could emit just a single path with one subpath per point list, but @@ -68,13 +71,13 @@ def color_block_to_paths(color_block, svg): SVG_PATH_TAG, {'style': simplestyle.formatStyle( {'stroke': color, - 'stroke-width': "0.4", - 'fill': 'none'}), - 'd': "M" + " ".join(" ".join(str(coord) for coord in point) for point in point_list), - 'transform': get_correction_transform(svg), - 'embroider_manual_stitch': 'true', - 'embroider_trim_after': 'true', - })) + 'stroke-width': "0.4", + 'fill': 'none'}), + 'd': "M" + " ".join(" ".join(str(coord) for coord in point) for point in point_list), + 'transform': get_correction_transform(svg), + 'embroider_manual_stitch': 'true', + 'embroider_trim_after': 'true', + })) # no need to trim at the end of a thread color if paths: @@ -82,6 +85,7 @@ def color_block_to_paths(color_block, svg): return paths + def render_stitch_plan(svg, stitch_plan, realistic=False): layer = svg.find(".//*[@id='__inkstitch_stitch_plan__']") if layer is None: diff --git a/lib/svg/units.py b/lib/svg/units.py index 126027bc..585afab4 100644 --- a/lib/svg/units.py +++ b/lib/svg/units.py @@ -6,8 +6,9 @@ from ..utils import cache PIXELS_PER_MM = 96 / 25.4 # cribbed from inkscape-silhouette -def parse_length_with_units( str ): + +def parse_length_with_units(str): ''' Parse an SVG value which may or may not have units attached This version is greatly simplified in that it only allows: no units, @@ -39,8 +40,8 @@ def parse_length_with_units( str ): u = '%' s = s[:-1] try: - v = float( s ) - except: + v = float(s) + except BaseException: raise ValueError(_("parseLengthWithUnits: unknown unit %s") % s) return v, u @@ -53,16 +54,16 @@ def convert_length(length): return value if units == 'pt': - value /= 72 - units = 'in' + value /= 72 + units = 'in' if units == 'pc': - value /= 6 - units = 'in' + value /= 6 + units = 'in' if units == 'cm': - value *= 10 - units = 'mm' + value *= 10 + units = 'mm' if units == 'mm': value = value / 25.4 @@ -75,6 +76,7 @@ def convert_length(length): raise ValueError(_("Unknown unit: %s") % units) + @cache def get_viewbox(svg): return svg.get('viewBox').strip().replace(',', ' ').split() @@ -96,6 +98,7 @@ def get_doc_size(svg): return doc_width, doc_height + @cache def get_viewbox_transform(node): # somewhat cribbed from inkscape-silhouette diff --git a/lib/threads/catalog.py b/lib/threads/catalog.py index d9981dc6..ece2f8ac 100644 --- a/lib/threads/catalog.py +++ b/lib/threads/catalog.py @@ -85,8 +85,10 @@ class _ThreadCatalog(Sequence): if palette.name == name: return palette + _catalog = None + def ThreadCatalog(): """Singleton _ThreadCatalog factory""" diff --git a/lib/threads/color.py b/lib/threads/color.py index cc6c0c48..8c596e44 100644 --- a/lib/threads/color.py +++ b/lib/threads/color.py @@ -3,6 +3,7 @@ import re import colorsys from pyembroidery.EmbThread import EmbThread + class ThreadColor(object): hex_str_re = re.compile('#([0-9a-z]{3}|[0-9a-z]{6})', re.I) diff --git a/lib/utils/cache.py b/lib/utils/cache.py index 38fe8f2c..3a2636f2 100644 --- a/lib/utils/cache.py +++ b/lib/utils/cache.py @@ -4,5 +4,7 @@ except ImportError: from backports.functools_lru_cache import lru_cache # simplify use of lru_cache decorator + + def cache(*args, **kwargs): return lru_cache(maxsize=None)(*args, **kwargs) diff --git a/lib/utils/geometry.py b/lib/utils/geometry.py index bfdcd3c0..eb1a28fa 100644 --- a/lib/utils/geometry.py +++ b/lib/utils/geometry.py @@ -17,7 +17,7 @@ def cut(line, distance): last_point = p if traveled == distance: return [ - LineString(coords[:i+1]), + LineString(coords[:i + 1]), LineString(coords[i:])] if traveled > distance: cp = line.interpolate(distance) @@ -25,6 +25,7 @@ def cut(line, distance): LineString(coords[:i] + [(cp.x, cp.y)]), LineString([(cp.x, cp.y)] + coords[i:])] + def cut_path(points, length): """Return a subsection of at the start of the path that is length units long. diff --git a/lib/utils/inkscape.py b/lib/utils/inkscape.py index 2d0298bc..a650da69 100644 --- a/lib/utils/inkscape.py +++ b/lib/utils/inkscape.py @@ -1,6 +1,7 @@ from os.path import realpath, expanduser, join as path_join import sys + def guess_inkscape_config_path(): if getattr(sys, 'frozen', None): path = realpath(path_join(sys._MEIPASS, "..", "..", "..")) diff --git a/lib/utils/io.py b/lib/utils/io.py index e5a246f3..f51f629c 100644 --- a/lib/utils/io.py +++ b/lib/utils/io.py @@ -19,6 +19,8 @@ def restore_stderr(): # It's probably possible to generalize this code, but when I tried, # the result was incredibly unreadable. + + def save_stdout(): null = open(os.devnull, 'w') sys.stdout_dup = os.dup(sys.stdout.fileno()) diff --git a/messages.po b/messages.po index 074159c4..a5abfb66 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-20 20:42-0400\n" +"POT-Creation-Date: 2018-08-21 20:32-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -146,45 +146,45 @@ msgid "" "Negative angles are allowed." msgstr "" -#: lib/elements/fill.py:45 +#: lib/elements/fill.py:46 msgid "Flip fill (start right-to-left)" msgstr "" -#: lib/elements/fill.py:46 +#: lib/elements/fill.py:47 msgid "" "The flip option can help you with routing your stitch path. When you " "enable flip, stitching goes from right-to-left instead of left-to-right." msgstr "" -#: lib/elements/fill.py:54 +#: lib/elements/fill.py:55 msgid "Spacing between rows" msgstr "" -#: lib/elements/fill.py:55 +#: lib/elements/fill.py:56 msgid "Distance between rows of stitches." msgstr "" -#: lib/elements/fill.py:68 +#: lib/elements/fill.py:69 msgid "Maximum fill stitch length" msgstr "" -#: lib/elements/fill.py:69 +#: lib/elements/fill.py:70 msgid "" "The length of each stitch in a row. Shorter stitch may be used at the " "start or end of a row." msgstr "" -#: lib/elements/fill.py:78 +#: lib/elements/fill.py:79 msgid "Stagger rows this many times before repeating" msgstr "" -#: lib/elements/fill.py:79 +#: lib/elements/fill.py:80 msgid "" "Setting this dictates how many rows apart the stitches will be before " "they fall in the same column position." msgstr "" -#: lib/elements/fill.py:112 +#: lib/elements/fill.py:113 #, python-format msgid "" "shape %s is so small that it cannot be filled with stitches. Please make" @@ -203,7 +203,7 @@ msgstr "" msgid "\"E\" stitch" msgstr "" -#: lib/elements/satin_column.py:32 lib/elements/stroke.py:52 +#: lib/elements/satin_column.py:32 lib/elements/stroke.py:53 msgid "Zig-zag spacing (peak-to-peak)" msgstr "" @@ -211,74 +211,74 @@ msgstr "" msgid "Peak-to-peak distance between zig-zags." msgstr "" -#: lib/elements/satin_column.py:43 +#: lib/elements/satin_column.py:44 msgid "Pull compensation" msgstr "" -#: lib/elements/satin_column.py:44 +#: lib/elements/satin_column.py:45 msgid "" "Satin stitches pull the fabric together, resulting in a column narrower " "than you draw in Inkscape. This setting expands each pair of needle " "penetrations outward from the center of the satin column." msgstr "" -#: lib/elements/satin_column.py:55 +#: lib/elements/satin_column.py:56 msgid "Contour underlay" msgstr "" -#: lib/elements/satin_column.py:55 lib/elements/satin_column.py:62 -#: lib/elements/satin_column.py:71 +#: lib/elements/satin_column.py:56 lib/elements/satin_column.py:63 +#: lib/elements/satin_column.py:72 msgid "Contour Underlay" msgstr "" -#: lib/elements/satin_column.py:62 lib/elements/satin_column.py:86 +#: lib/elements/satin_column.py:63 lib/elements/satin_column.py:87 msgid "Stitch length" msgstr "" -#: lib/elements/satin_column.py:68 +#: lib/elements/satin_column.py:69 msgid "Contour underlay inset amount" msgstr "" -#: lib/elements/satin_column.py:69 +#: lib/elements/satin_column.py:70 msgid "" "Shrink the outline, to prevent the underlay from showing around the " "outside of the satin column." msgstr "" -#: lib/elements/satin_column.py:79 +#: lib/elements/satin_column.py:80 msgid "Center-walk underlay" msgstr "" -#: lib/elements/satin_column.py:79 lib/elements/satin_column.py:86 +#: lib/elements/satin_column.py:80 lib/elements/satin_column.py:87 msgid "Center-Walk Underlay" msgstr "" -#: lib/elements/satin_column.py:91 +#: lib/elements/satin_column.py:92 msgid "Zig-zag underlay" msgstr "" -#: lib/elements/satin_column.py:91 lib/elements/satin_column.py:100 -#: lib/elements/satin_column.py:111 +#: lib/elements/satin_column.py:92 lib/elements/satin_column.py:101 +#: lib/elements/satin_column.py:112 msgid "Zig-zag Underlay" msgstr "" -#: lib/elements/satin_column.py:97 +#: lib/elements/satin_column.py:98 msgid "Zig-Zag spacing (peak-to-peak)" msgstr "" -#: lib/elements/satin_column.py:98 +#: lib/elements/satin_column.py:99 msgid "Distance between peaks of the zig-zags." msgstr "" -#: lib/elements/satin_column.py:108 +#: lib/elements/satin_column.py:109 msgid "Inset amount" msgstr "" -#: lib/elements/satin_column.py:109 +#: lib/elements/satin_column.py:110 msgid "default: half of contour underlay inset" msgstr "" -#: lib/elements/satin_column.py:146 +#: lib/elements/satin_column.py:147 #, python-format msgid "satin column: %(id)s: at least two subpaths required (%(num)d found)" msgstr "" @@ -293,22 +293,22 @@ msgstr "" msgid "satin column: One or more of the rungs doesn't intersect both rails." msgstr "" -#: lib/elements/satin_column.py:179 lib/elements/satin_column.py:181 +#: lib/elements/satin_column.py:180 lib/elements/satin_column.py:183 msgid "Each rail should intersect both rungs once." msgstr "" -#: lib/elements/satin_column.py:181 +#: lib/elements/satin_column.py:182 msgid "" "satin column: One or more of the rungs intersects the rails more than " "once." msgstr "" -#: lib/elements/satin_column.py:222 +#: lib/elements/satin_column.py:223 #, python-format msgid "satin column: object %s has a fill (but should not)" msgstr "" -#: lib/elements/satin_column.py:226 +#: lib/elements/satin_column.py:227 #, python-format msgid "" "satin column: object %(id)s has two paths with an unequal number of " @@ -327,40 +327,40 @@ msgstr "" msgid "Length of stitches in running stitch mode." msgstr "" -#: lib/elements/stroke.py:42 +#: lib/elements/stroke.py:43 msgid "Bean stitch number of repeats" msgstr "" -#: lib/elements/stroke.py:43 +#: lib/elements/stroke.py:44 msgid "" "Backtrack each stitch this many times. A value of 1 would triple each " "stitch (forward, back, forward). A value of 2 would quintuple each " "stitch, etc. Only applies to running stitch." msgstr "" -#: lib/elements/stroke.py:53 +#: lib/elements/stroke.py:54 msgid "Length of stitches in zig-zag mode." msgstr "" -#: lib/elements/stroke.py:64 +#: lib/elements/stroke.py:65 msgid "Repeats" msgstr "" -#: lib/elements/stroke.py:65 +#: lib/elements/stroke.py:66 msgid "Defines how many times to run down and back along the path." msgstr "" -#: lib/elements/stroke.py:89 +#: lib/elements/stroke.py:90 msgid "Manual stitch placement" msgstr "" -#: lib/elements/stroke.py:90 +#: lib/elements/stroke.py:91 msgid "" "Stitch every node in the path. Stitch length and zig-zag spacing are " "ignored." msgstr "" -#: lib/elements/stroke.py:124 +#: lib/elements/stroke.py:125 msgid "" "Legacy running stitch setting detected!\n" "\n" @@ -391,7 +391,7 @@ msgstr "" msgid "Only simple lines may be converted to satin columns." msgstr "" -#: lib/extensions/convert_to_satin.py:54 +#: lib/extensions/convert_to_satin.py:55 #, python-format msgid "" "Cannot convert %s to a satin column because it intersects itself. Try " @@ -405,7 +405,7 @@ msgid "" "Seeing a 'no such option' message? Please restart Inkscape to fix." msgstr "" -#: lib/extensions/flip.py:35 +#: lib/extensions/flip.py:36 msgid "Please select one or more satin columns to flip." msgstr "" @@ -420,37 +420,37 @@ msgstr "" msgid "thread manufacturer color palettes" msgstr "" -#: lib/extensions/install.py:32 +#: lib/extensions/install.py:31 msgid "Ink/Stitch visual commands (Object -> Symbols...)" msgstr "" -#: lib/extensions/install.py:41 +#: lib/extensions/install.py:40 msgid "Install" msgstr "" -#: lib/extensions/install.py:44 lib/extensions/params.py:380 +#: lib/extensions/install.py:43 lib/extensions/params.py:380 msgid "Cancel" msgstr "" -#: lib/extensions/install.py:58 +#: lib/extensions/install.py:57 msgid "Choose Inkscape directory" msgstr "" -#: lib/extensions/install.py:68 +#: lib/extensions/install.py:67 msgid "Inkscape add-on installation failed" msgstr "" -#: lib/extensions/install.py:69 +#: lib/extensions/install.py:68 msgid "Installation Failed" msgstr "" -#: lib/extensions/install.py:73 +#: lib/extensions/install.py:72 msgid "" "Inkscape add-on files have been installed. Please restart Inkscape to " "load the new add-ons." msgstr "" -#: lib/extensions/install.py:74 +#: lib/extensions/install.py:73 msgid "Installation Completed" msgstr "" @@ -611,7 +611,7 @@ msgstr "" #. If you translate this string, that will tell Ink/Stitch to #. generate menu items for this language in Inkscape's "Extensions" #. menu. -#: lib/inx/utils.py:43 +#: lib/inx/utils.py:46 msgid "Generate INX files" msgstr "" @@ -663,28 +663,28 @@ msgstr "" msgid "Stitch #" msgstr "" -#: lib/stitches/auto_fill.py:168 +#: lib/stitches/auto_fill.py:169 msgid "" "Unable to autofill. This most often happens because your shape is made " "up of multiple sections that aren't connected." msgstr "" -#: lib/stitches/auto_fill.py:393 +#: lib/stitches/auto_fill.py:398 msgid "" "Unexpected error while generating fill stitches. Please send your SVG " "file to lexelby@github." msgstr "" -#: lib/svg/svg.py:90 +#: lib/svg/svg.py:94 msgid "Stitch Plan" msgstr "" -#: lib/svg/units.py:44 +#: lib/svg/units.py:45 #, python-format msgid "parseLengthWithUnits: unknown unit %s" msgstr "" -#: lib/svg/units.py:76 +#: lib/svg/units.py:77 #, python-format msgid "Unknown unit: %s" msgstr "" diff --git a/stub.py b/stub.py index 9c316b99..6daaf5ae 100644 --- a/stub.py +++ b/stub.py @@ -34,7 +34,7 @@ args[0] = binary_path try: extension = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = extension.communicate() -except: +except BaseException: print >> sys.stderr, "Unexpected error launching Ink/Stitch." print >> sys.stderr, "If you're having trouble, please file an issue here, including the text below: https://github.com/inkstitch/inkstitch/issues\n" print >> sys.stderr, "Tried to launch:", binary_path -- cgit v1.3.1 From 94f391ab4262b5e1c8dace0263467a0ec1f17058 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Tue, 21 Aug 2018 20:50:14 -0400 Subject: more pep8 fixes --- lib/elements/fill.py | 3 +- lib/elements/satin_column.py | 5 ++- lib/elements/stroke.py | 4 +- lib/extensions/install.py | 6 ++- lib/extensions/print_pdf.py | 5 ++- lib/stitch_plan/stitch_plan.py | 4 +- lib/stitches/fill.py | 2 +- messages.po | 96 +++++++++++++++++++++--------------------- stub.py | 3 +- 9 files changed, 69 insertions(+), 59 deletions(-) (limited to 'lib/extensions') diff --git a/lib/elements/fill.py b/lib/elements/fill.py index 672f4db8..77284414 100644 --- a/lib/elements/fill.py +++ b/lib/elements/fill.py @@ -44,7 +44,8 @@ class Fill(EmbroideryElement): @param( 'flip', _('Flip fill (start right-to-left)'), - tooltip=_('The flip option can help you with routing your stitch path. When you enable flip, stitching goes from right-to-left instead of left-to-right.'), + tooltip=_('The flip option can help you with routing your stitch path. ' + 'When you enable flip, stitching goes from right-to-left instead of left-to-right.'), type='boolean', default=False) def flip(self): diff --git a/lib/elements/satin_column.py b/lib/elements/satin_column.py index e13e1118..9927a606 100644 --- a/lib/elements/satin_column.py +++ b/lib/elements/satin_column.py @@ -42,7 +42,8 @@ class SatinColumn(EmbroideryElement): @param( 'pull_compensation_mm', _('Pull compensation'), - tooltip=_('Satin stitches pull the fabric together, resulting in a column narrower than you draw in Inkscape. This setting expands each pair of needle penetrations outward from the center of the satin column.'), + tooltip=_('Satin stitches pull the fabric together, resulting in a column narrower than you draw in Inkscape. ' + 'This setting expands each pair of needle penetrations outward from the center of the satin column.'), unit='mm', type='float', default=0) @@ -174,7 +175,7 @@ class SatinColumn(EmbroideryElement): # handle null intersections here? linestrings = shops.split(rail, rungs) - #print >> dbg, "rails and rungs", [str(rail) for rail in rails], [str(rung) for rung in rungs] + # print >> dbg, "rails and rungs", [str(rail) for rail in rails], [str(rung) for rung in rungs] if len(linestrings.geoms) < len(rungs.geoms) + 1: self.fatal(_("satin column: One or more of the rungs doesn't intersect both rails.") + " " + _("Each rail should intersect both rungs once.")) diff --git a/lib/elements/stroke.py b/lib/elements/stroke.py index 183ef23b..3ae2b143 100644 --- a/lib/elements/stroke.py +++ b/lib/elements/stroke.py @@ -41,7 +41,9 @@ class Stroke(EmbroideryElement): @param( 'bean_stitch_repeats', _('Bean stitch number of repeats'), - tooltip=_('Backtrack each stitch this many times. A value of 1 would triple each stitch (forward, back, forward). A value of 2 would quintuple each stitch, etc. Only applies to running stitch.'), + tooltip=_('Backtrack each stitch this many times. ' + 'A value of 1 would triple each stitch (forward, back, forward). ' + 'A value of 2 would quintuple each stitch, etc. Only applies to running stitch.'), type='int', default=0, sort_index=2) diff --git a/lib/extensions/install.py b/lib/extensions/install.py index 2863bef0..0745eddc 100644 --- a/lib/extensions/install.py +++ b/lib/extensions/install.py @@ -27,8 +27,10 @@ class InstallerFrame(wx.Frame): text_sizer = wx.BoxSizer(wx.HORIZONTAL) - text = _('Ink/Stitch can install files ("add-ons") that make it easier to use Inkscape to create machine embroidery designs. These add-ons will be installed:') + \ - "\n\n • " + _("thread manufacturer color palettes") + "\n • " + _("Ink/Stitch visual commands (Object -> Symbols...)") + text = (_('Ink/Stitch can install files ("add-ons") that make it easier to use Inkscape to create machine embroidery designs. ' + 'These add-ons will be installed:') + + "\n\n • " + _("thread manufacturer color palettes") + + "\n • " + _("Ink/Stitch visual commands (Object -> Symbols...)")) static_text = wx.StaticText(panel, label=text) font = wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL) diff --git a/lib/extensions/print_pdf.py b/lib/extensions/print_pdf.py index ee3dc316..90ca83ae 100644 --- a/lib/extensions/print_pdf.py +++ b/lib/extensions/print_pdf.py @@ -262,7 +262,10 @@ class PrintInfoFrame(wx.Frame): panel = wx.Panel(self) sizer = wx.BoxSizer(wx.VERTICAL) - text = wx.StaticText(panel, label=_("A print preview has been opened in your web browser. This window will stay open in order to communicate with the JavaScript code running in your browser.\n\nThis window will close after you close the print preview in your browser, or you can close it manually if necessary.")) + message = _("A print preview has been opened in your web browser. " + "This window will stay open in order to communicate with the JavaScript code running in your browser.\n\n" + "This window will close after you close the print preview in your browser, or you can close it manually if necessary.") + text = wx.StaticText(panel, label=message) font = wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.NORMAL) text.SetFont(font) sizer.Add(text, proportion=1, flag=wx.ALL | wx.EXPAND, border=20) diff --git a/lib/stitch_plan/stitch_plan.py b/lib/stitch_plan/stitch_plan.py index 682ea09f..c713b42e 100644 --- a/lib/stitch_plan/stitch_plan.py +++ b/lib/stitch_plan/stitch_plan.py @@ -209,8 +209,8 @@ class ColorBlock(object): # Don't consider jumps, stops, color changes, or trims as candidates for filtering pass else: - l = (stitch - stitches[-1]).length() - if l <= 0.1 * PIXELS_PER_MM: + length = (stitch - stitches[-1]).length() + if length <= 0.1 * PIXELS_PER_MM: # duplicate stitch, skip this one continue diff --git a/lib/stitches/fill.py b/lib/stitches/fill.py index ac8b52ee..b6b97e1b 100644 --- a/lib/stitches/fill.py +++ b/lib/stitches/fill.py @@ -120,7 +120,7 @@ def intersect_region_with_grating(shape, angle, row_spacing, end_row_spacing=Non height = abs(end - start) - #print >> dbg, "grating:", start, end, height, row_spacing, end_row_spacing + # print >> dbg, "grating:", start, end, height, row_spacing, end_row_spacing # offset start slightly so that rows are always an even multiple of # row_spacing_px from the origin. This makes it so that abutting diff --git a/messages.po b/messages.po index a5abfb66..94de4c34 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-21 20:32-0400\n" +"POT-Creation-Date: 2018-08-21 20:50-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -156,35 +156,35 @@ msgid "" "enable flip, stitching goes from right-to-left instead of left-to-right." msgstr "" -#: lib/elements/fill.py:55 +#: lib/elements/fill.py:56 msgid "Spacing between rows" msgstr "" -#: lib/elements/fill.py:56 +#: lib/elements/fill.py:57 msgid "Distance between rows of stitches." msgstr "" -#: lib/elements/fill.py:69 +#: lib/elements/fill.py:70 msgid "Maximum fill stitch length" msgstr "" -#: lib/elements/fill.py:70 +#: lib/elements/fill.py:71 msgid "" "The length of each stitch in a row. Shorter stitch may be used at the " "start or end of a row." msgstr "" -#: lib/elements/fill.py:79 +#: lib/elements/fill.py:80 msgid "Stagger rows this many times before repeating" msgstr "" -#: lib/elements/fill.py:80 +#: lib/elements/fill.py:81 msgid "" "Setting this dictates how many rows apart the stitches will be before " "they fall in the same column position." msgstr "" -#: lib/elements/fill.py:113 +#: lib/elements/fill.py:114 #, python-format msgid "" "shape %s is so small that it cannot be filled with stitches. Please make" @@ -203,7 +203,7 @@ msgstr "" msgid "\"E\" stitch" msgstr "" -#: lib/elements/satin_column.py:32 lib/elements/stroke.py:53 +#: lib/elements/satin_column.py:32 lib/elements/stroke.py:55 msgid "Zig-zag spacing (peak-to-peak)" msgstr "" @@ -222,93 +222,93 @@ msgid "" "penetrations outward from the center of the satin column." msgstr "" -#: lib/elements/satin_column.py:56 +#: lib/elements/satin_column.py:57 msgid "Contour underlay" msgstr "" -#: lib/elements/satin_column.py:56 lib/elements/satin_column.py:63 -#: lib/elements/satin_column.py:72 +#: lib/elements/satin_column.py:57 lib/elements/satin_column.py:64 +#: lib/elements/satin_column.py:73 msgid "Contour Underlay" msgstr "" -#: lib/elements/satin_column.py:63 lib/elements/satin_column.py:87 +#: lib/elements/satin_column.py:64 lib/elements/satin_column.py:88 msgid "Stitch length" msgstr "" -#: lib/elements/satin_column.py:69 +#: lib/elements/satin_column.py:70 msgid "Contour underlay inset amount" msgstr "" -#: lib/elements/satin_column.py:70 +#: lib/elements/satin_column.py:71 msgid "" "Shrink the outline, to prevent the underlay from showing around the " "outside of the satin column." msgstr "" -#: lib/elements/satin_column.py:80 +#: lib/elements/satin_column.py:81 msgid "Center-walk underlay" msgstr "" -#: lib/elements/satin_column.py:80 lib/elements/satin_column.py:87 +#: lib/elements/satin_column.py:81 lib/elements/satin_column.py:88 msgid "Center-Walk Underlay" msgstr "" -#: lib/elements/satin_column.py:92 +#: lib/elements/satin_column.py:93 msgid "Zig-zag underlay" msgstr "" -#: lib/elements/satin_column.py:92 lib/elements/satin_column.py:101 -#: lib/elements/satin_column.py:112 +#: lib/elements/satin_column.py:93 lib/elements/satin_column.py:102 +#: lib/elements/satin_column.py:113 msgid "Zig-zag Underlay" msgstr "" -#: lib/elements/satin_column.py:98 +#: lib/elements/satin_column.py:99 msgid "Zig-Zag spacing (peak-to-peak)" msgstr "" -#: lib/elements/satin_column.py:99 +#: lib/elements/satin_column.py:100 msgid "Distance between peaks of the zig-zags." msgstr "" -#: lib/elements/satin_column.py:109 +#: lib/elements/satin_column.py:110 msgid "Inset amount" msgstr "" -#: lib/elements/satin_column.py:110 +#: lib/elements/satin_column.py:111 msgid "default: half of contour underlay inset" msgstr "" -#: lib/elements/satin_column.py:147 +#: lib/elements/satin_column.py:148 #, python-format msgid "satin column: %(id)s: at least two subpaths required (%(num)d found)" msgstr "" -#: lib/elements/satin_column.py:172 +#: lib/elements/satin_column.py:173 msgid "" "One or more rails crosses itself, and this is not allowed. Please split " "into multiple satin columns." msgstr "" -#: lib/elements/satin_column.py:179 +#: lib/elements/satin_column.py:180 msgid "satin column: One or more of the rungs doesn't intersect both rails." msgstr "" -#: lib/elements/satin_column.py:180 lib/elements/satin_column.py:183 +#: lib/elements/satin_column.py:181 lib/elements/satin_column.py:184 msgid "Each rail should intersect both rungs once." msgstr "" -#: lib/elements/satin_column.py:182 +#: lib/elements/satin_column.py:183 msgid "" "satin column: One or more of the rungs intersects the rails more than " "once." msgstr "" -#: lib/elements/satin_column.py:223 +#: lib/elements/satin_column.py:224 #, python-format msgid "satin column: object %s has a fill (but should not)" msgstr "" -#: lib/elements/satin_column.py:227 +#: lib/elements/satin_column.py:228 #, python-format msgid "" "satin column: object %(id)s has two paths with an unequal number of " @@ -338,29 +338,29 @@ msgid "" "stitch, etc. Only applies to running stitch." msgstr "" -#: lib/elements/stroke.py:54 +#: lib/elements/stroke.py:56 msgid "Length of stitches in zig-zag mode." msgstr "" -#: lib/elements/stroke.py:65 +#: lib/elements/stroke.py:67 msgid "Repeats" msgstr "" -#: lib/elements/stroke.py:66 +#: lib/elements/stroke.py:68 msgid "Defines how many times to run down and back along the path." msgstr "" -#: lib/elements/stroke.py:90 +#: lib/elements/stroke.py:92 msgid "Manual stitch placement" msgstr "" -#: lib/elements/stroke.py:91 +#: lib/elements/stroke.py:93 msgid "" "Stitch every node in the path. Stitch length and zig-zag spacing are " "ignored." msgstr "" -#: lib/elements/stroke.py:125 +#: lib/elements/stroke.py:127 msgid "" "Legacy running stitch setting detected!\n" "\n" @@ -416,45 +416,45 @@ msgid "" "installed:" msgstr "" -#: lib/extensions/install.py:31 +#: lib/extensions/install.py:32 msgid "thread manufacturer color palettes" msgstr "" -#: lib/extensions/install.py:31 +#: lib/extensions/install.py:33 msgid "Ink/Stitch visual commands (Object -> Symbols...)" msgstr "" -#: lib/extensions/install.py:40 +#: lib/extensions/install.py:42 msgid "Install" msgstr "" -#: lib/extensions/install.py:43 lib/extensions/params.py:380 +#: lib/extensions/install.py:45 lib/extensions/params.py:380 msgid "Cancel" msgstr "" -#: lib/extensions/install.py:57 +#: lib/extensions/install.py:59 msgid "Choose Inkscape directory" msgstr "" -#: lib/extensions/install.py:67 +#: lib/extensions/install.py:69 msgid "Inkscape add-on installation failed" msgstr "" -#: lib/extensions/install.py:68 +#: lib/extensions/install.py:70 msgid "Installation Failed" msgstr "" -#: lib/extensions/install.py:72 +#: lib/extensions/install.py:74 msgid "" "Inkscape add-on files have been installed. Please restart Inkscape to " "load the new add-ons." msgstr "" -#: lib/extensions/install.py:73 +#: lib/extensions/install.py:75 msgid "Installation Completed" msgstr "" -#: lib/extensions/install.py:103 +#: lib/extensions/install.py:105 msgid "Ink/Stitch Add-ons Installer" msgstr "" @@ -596,7 +596,7 @@ msgid "" " or you can close it manually if necessary." msgstr "" -#: lib/extensions/print_pdf.py:411 +#: lib/extensions/print_pdf.py:414 msgid "Ink/Stitch Print" msgstr "" diff --git a/stub.py b/stub.py index 6daaf5ae..3d873196 100644 --- a/stub.py +++ b/stub.py @@ -36,7 +36,8 @@ try: stdout, stderr = extension.communicate() except BaseException: print >> sys.stderr, "Unexpected error launching Ink/Stitch." - print >> sys.stderr, "If you're having trouble, please file an issue here, including the text below: https://github.com/inkstitch/inkstitch/issues\n" + print >> sys.stderr, "If you're having trouble, please file an issue here, including the text below:" + print >> sys.stderr, " https://github.com/inkstitch/inkstitch/issues\n" print >> sys.stderr, "Tried to launch:", binary_path print >> sys.stderr, "Arguments:", args print >> sys.stderr, "Debugging information:\n" -- cgit v1.3.1 From 908f2cd7727e939b87e3f57c1d3a189705de4c94 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Tue, 21 Aug 2018 21:43:09 -0400 Subject: pyflakes fixes --- lib/elements/element.py | 2 -- lib/elements/fill.py | 2 +- lib/elements/polyline.py | 3 +- lib/extensions/base.py | 4 +-- lib/extensions/commands.py | 1 - lib/extensions/convert_to_satin.py | 1 + lib/extensions/embroider.py | 3 -- lib/extensions/flip.py | 1 - lib/extensions/input.py | 6 +--- lib/extensions/install.py | 9 ++---- lib/extensions/layer_commands.py | 8 ++--- lib/extensions/object_commands.py | 8 +---- lib/extensions/output.py | 5 +-- lib/extensions/print_pdf.py | 6 ++-- lib/extensions/zip.py | 5 +-- lib/inx/generate.py | 4 +-- lib/inx/utils.py | 2 +- lib/stitches/auto_fill.py | 3 -- lib/stitches/fill.py | 5 +-- lib/svg/path.py | 1 - lib/svg/realistic_rendering.py | 2 +- lib/svg/units.py | 1 + lib/threads/palette.py | 7 ++-- lib/utils/geometry.py | 2 +- messages.po | 66 +++++++++++++++++++------------------- 25 files changed, 59 insertions(+), 98 deletions(-) (limited to 'lib/extensions') diff --git a/lib/elements/element.py b/lib/elements/element.py index 5ca70cf6..4edb00c0 100644 --- a/lib/elements/element.py +++ b/lib/elements/element.py @@ -1,6 +1,5 @@ import sys from copy import deepcopy -from shapely import geometry as shgeo from ..i18n import _ from ..utils import cache @@ -8,7 +7,6 @@ from ..svg import PIXELS_PER_MM, convert_length, get_doc_size, apply_transforms from ..commands import find_commands # inkscape-provided utilities -import simpletransform import simplestyle import cubicsuperpath from cspsubdiv import cspsubdiv diff --git a/lib/elements/fill.py b/lib/elements/fill.py index 77284414..626573e6 100644 --- a/lib/elements/fill.py +++ b/lib/elements/fill.py @@ -5,7 +5,7 @@ from .element import param, EmbroideryElement, Patch from ..i18n import _ from ..svg import PIXELS_PER_MM from ..utils import cache -from ..stitches import running_stitch, auto_fill, legacy_fill +from ..stitches import legacy_fill class Fill(EmbroideryElement): diff --git a/lib/elements/polyline.py b/lib/elements/polyline.py index d3242795..5bfe5022 100644 --- a/lib/elements/polyline.py +++ b/lib/elements/polyline.py @@ -1,7 +1,6 @@ from shapely import geometry as shgeo -from .element import param, EmbroideryElement, Patch -from ..i18n import _ +from .element import EmbroideryElement, Patch from ..utils.geometry import Point from ..utils import cache diff --git a/lib/extensions/base.py b/lib/extensions/base.py index 07eaa40c..22bc82db 100644 --- a/lib/extensions/base.py +++ b/lib/extensions/base.py @@ -5,10 +5,10 @@ from copy import deepcopy from collections import MutableMapping from stringcase import snakecase -from ..svg.tags import * +from ..svg.tags import SVG_GROUP_TAG, INKSCAPE_GROUPMODE, SVG_DEFS_TAG, EMBROIDERABLE_TAGS, SVG_POLYLINE_TAG from ..elements import AutoFill, Fill, Stroke, SatinColumn, Polyline, EmbroideryElement -from ..utils import cache from ..commands import is_command, layer_commands +from ..i18n import _ SVG_METADATA_TAG = inkex.addNS("metadata", "svg") diff --git a/lib/extensions/commands.py b/lib/extensions/commands.py index e3bfabfe..fb6f7874 100644 --- a/lib/extensions/commands.py +++ b/lib/extensions/commands.py @@ -1,5 +1,4 @@ import os -import sys import inkex from copy import deepcopy diff --git a/lib/extensions/convert_to_satin.py b/lib/extensions/convert_to_satin.py index d27e42cc..ef4ac557 100644 --- a/lib/extensions/convert_to_satin.py +++ b/lib/extensions/convert_to_satin.py @@ -11,6 +11,7 @@ from ..svg.tags import SVG_PATH_TAG from ..svg import get_correction_transform, PIXELS_PER_MM from ..elements import Stroke from ..utils import Point +from ..i18n import _ class SelfIntersectionError(Exception): diff --git a/lib/extensions/embroider.py b/lib/extensions/embroider.py index 1e994e27..921201d6 100644 --- a/lib/extensions/embroider.py +++ b/lib/extensions/embroider.py @@ -1,7 +1,4 @@ -import sys -import traceback import os -import inkex from .base import InkstitchExtension from ..i18n import _ diff --git a/lib/extensions/flip.py b/lib/extensions/flip.py index 5bea510f..65dbdc1f 100644 --- a/lib/extensions/flip.py +++ b/lib/extensions/flip.py @@ -1,4 +1,3 @@ -import sys import inkex import cubicsuperpath from shapely import geometry as shgeo diff --git a/lib/extensions/input.py b/lib/extensions/input.py index e450bef6..975ba838 100644 --- a/lib/extensions/input.py +++ b/lib/extensions/input.py @@ -1,15 +1,11 @@ import os -from os.path import realpath, dirname, join as path_join -import sys from inkex import etree import inkex import pyembroidery from ..svg import PIXELS_PER_MM, render_stitch_plan from ..svg.tags import INKSCAPE_LABEL -from ..i18n import _ -from ..stitch_plan import StitchPlan, ColorBlock -from ..utils.io import save_stdout +from ..stitch_plan import StitchPlan class Input(object): diff --git a/lib/extensions/install.py b/lib/extensions/install.py index 0745eddc..314843f4 100644 --- a/lib/extensions/install.py +++ b/lib/extensions/install.py @@ -3,17 +3,12 @@ import sys import traceback import os -from os.path import realpath, dirname from glob import glob -from threading import Thread -import socket -import errno -import time -import logging import wx import inkex from ..utils import guess_inkscape_config_path, get_bundled_dir +from ..i18n import _ class InstallerFrame(wx.Frame): @@ -64,7 +59,7 @@ class InstallerFrame(wx.Frame): try: self.install_addons('palettes') self.install_addons('symbols') - except Exception as e: + except Exception: wx.MessageDialog(self, _('Inkscape add-on installation failed') + ': \n' + traceback.format_exc(), _('Installation Failed'), diff --git a/lib/extensions/layer_commands.py b/lib/extensions/layer_commands.py index b9be2b27..8210c7c6 100644 --- a/lib/extensions/layer_commands.py +++ b/lib/extensions/layer_commands.py @@ -1,11 +1,9 @@ -import os -import sys import inkex from .commands import CommandsExtension from ..commands import LAYER_COMMANDS, get_command_description from ..i18n import _ -from ..svg.tags import * +from ..svg.tags import SVG_USE_TAG, INKSCAPE_LABEL, XLINK_HREF from ..svg import get_correction_transform @@ -35,7 +33,7 @@ class LayerCommands(CommandsExtension): for i, command in enumerate(commands): self.ensure_symbol(command) - node = inkex.etree.SubElement(self.current_layer, SVG_USE_TAG, + inkex.etree.SubElement(self.current_layer, SVG_USE_TAG, { "id": self.uniqueId("use"), INKSCAPE_LABEL: _("Ink/Stitch Command") + ": %s" % get_command_description(command), @@ -46,5 +44,3 @@ class LayerCommands(CommandsExtension): "y": "-10", "transform": correction_transform }) - - namedview = self.document.xpath("//sodipodi:namedview", namespaces=inkex.NSS) diff --git a/lib/extensions/object_commands.py b/lib/extensions/object_commands.py index 483f2a0a..e678890d 100644 --- a/lib/extensions/object_commands.py +++ b/lib/extensions/object_commands.py @@ -1,16 +1,10 @@ -import os -import sys import inkex -import simpletransform -import cubicsuperpath from random import random -from shapely import geometry as shgeo from .commands import CommandsExtension from ..commands import OBJECT_COMMANDS, get_command_description from ..i18n import _ -from ..elements import SatinColumn -from ..svg.tags import * +from ..svg.tags import SVG_PATH_TAG, CONNECTION_START, CONNECTION_END, CONNECTOR_TYPE, INKSCAPE_LABEL, SVG_GROUP_TAG, SVG_USE_TAG, XLINK_HREF from ..svg import get_correction_transform diff --git a/lib/extensions/output.py b/lib/extensions/output.py index 090cd3a9..9ffa82a3 100644 --- a/lib/extensions/output.py +++ b/lib/extensions/output.py @@ -1,15 +1,12 @@ import sys -import traceback import os -import inkex import tempfile from .base import InkstitchExtension from ..i18n import _ from ..output import write_embroidery_file from ..stitch_plan import patches_to_stitch_plan -from ..svg import render_stitch_plan, PIXELS_PER_MM -from ..utils.io import save_stdout +from ..svg import PIXELS_PER_MM class Output(InkstitchExtension): diff --git a/lib/extensions/print_pdf.py b/lib/extensions/print_pdf.py index 90ca83ae..47b89061 100644 --- a/lib/extensions/print_pdf.py +++ b/lib/extensions/print_pdf.py @@ -1,5 +1,4 @@ import sys -import traceback import os from threading import Thread import socket @@ -13,15 +12,14 @@ import json import inkex from jinja2 import Environment, FileSystemLoader, select_autoescape from datetime import date -import base64 from flask import Flask, request, Response, send_from_directory, jsonify import webbrowser import requests from .base import InkstitchExtension from ..i18n import _, translation as inkstitch_translation -from ..svg import PIXELS_PER_MM, render_stitch_plan -from ..svg.tags import SVG_GROUP_TAG, INKSCAPE_GROUPMODE +from ..svg import render_stitch_plan +from ..svg.tags import INKSCAPE_GROUPMODE from ..stitch_plan import patches_to_stitch_plan from ..threads import ThreadCatalog diff --git a/lib/extensions/zip.py b/lib/extensions/zip.py index 02f29e8a..2376f79a 100644 --- a/lib/extensions/zip.py +++ b/lib/extensions/zip.py @@ -1,7 +1,5 @@ import sys -import traceback import os -import inkex import tempfile from zipfile import ZipFile import pyembroidery @@ -10,8 +8,7 @@ from .base import InkstitchExtension from ..i18n import _ from ..output import write_embroidery_file from ..stitch_plan import patches_to_stitch_plan -from ..svg import render_stitch_plan, PIXELS_PER_MM -from ..utils.io import save_stdout +from ..svg import PIXELS_PER_MM class Zip(InkstitchExtension): diff --git a/lib/inx/generate.py b/lib/inx/generate.py index 1cf347f2..941596de 100644 --- a/lib/inx/generate.py +++ b/lib/inx/generate.py @@ -1,9 +1,7 @@ -import os - from .inputs import generate_input_inx_files from .outputs import generate_output_inx_files from .extensions import generate_extension_inx_files -from .utils import iterate_inx_locales, inx_path +from .utils import iterate_inx_locales def generate_inx_files(): diff --git a/lib/inx/utils.py b/lib/inx/utils.py index 6670cfcb..8dd3fdf8 100644 --- a/lib/inx/utils.py +++ b/lib/inx/utils.py @@ -3,7 +3,7 @@ import gettext from os.path import dirname from jinja2 import Environment, FileSystemLoader -from ..i18n import translation as default_translation, locale_dir, _, N_ +from ..i18n import translation as default_translation, locale_dir, N_ _top_path = dirname(dirname(dirname(os.path.realpath(__file__)))) diff --git a/lib/stitches/auto_fill.py b/lib/stitches/auto_fill.py index e777d026..e732c940 100644 --- a/lib/stitches/auto_fill.py +++ b/lib/stitches/auto_fill.py @@ -1,14 +1,12 @@ import sys import shapely import networkx -import math from itertools import groupby, izip from collections import deque from .fill import intersect_region_with_grating, row_num, stitch_row from .running_stitch import running_stitch from ..i18n import _ -from ..svg import PIXELS_PER_MM from ..utils.geometry import Point as InkstitchPoint, cut @@ -367,7 +365,6 @@ def find_stitch_path(graph, segments, starting_point=None, ending_point=None): the order of most-recently-visited first. """ - original_graph = graph graph = graph.copy() num_segments = len(segments) segments_visited = 0 diff --git a/lib/stitches/fill.py b/lib/stitches/fill.py index b6b97e1b..af0a8403 100644 --- a/lib/stitches/fill.py +++ b/lib/stitches/fill.py @@ -1,6 +1,5 @@ import shapely import math -import sys from ..svg import PIXELS_PER_MM from ..utils import cache, Point as InkstitchPoint @@ -167,9 +166,7 @@ def intersect_region_with_grating(shape, angle, row_spacing, end_row_spacing=Non def section_to_stitches(group_of_segments, angle, row_spacing, max_stitch_length, staggers): stitches = [] - first_segment = True swap = False - last_end = None for segment in group_of_segments: (beg, end) = segment @@ -240,7 +237,7 @@ def pull_runs(rows, shape, row_spacing): # print >> sys.stderr, len(run) runs.append(run) - rows = [row for row in rows if len(row) > 0] + rows = [r for r in rows if len(r) > 0] count += 1 diff --git a/lib/svg/path.py b/lib/svg/path.py index 51100e38..4502b2ea 100644 --- a/lib/svg/path.py +++ b/lib/svg/path.py @@ -1,5 +1,4 @@ import simpletransform -import cubicsuperpath from .units import get_viewbox_transform diff --git a/lib/svg/realistic_rendering.py b/lib/svg/realistic_rendering.py index 5af7e9a6..73da3a09 100644 --- a/lib/svg/realistic_rendering.py +++ b/lib/svg/realistic_rendering.py @@ -2,7 +2,7 @@ import simplepath import math from .units import PIXELS_PER_MM -from ..utils import cache, Point +from ..utils import Point # The stitch vector path looks like this: # _______ diff --git a/lib/svg/units.py b/lib/svg/units.py index 585afab4..c4ec82a0 100644 --- a/lib/svg/units.py +++ b/lib/svg/units.py @@ -1,6 +1,7 @@ import simpletransform from ..utils import cache +from ..i18n import _ # modern versions of Inkscape use 96 pixels per inch as per the CSS standard PIXELS_PER_MM = 96 / 25.4 diff --git a/lib/threads/palette.py b/lib/threads/palette.py index 785fb082..654c43e5 100644 --- a/lib/threads/palette.py +++ b/lib/threads/palette.py @@ -41,8 +41,11 @@ class ThreadPalette(Set): if self.name.lower().startswith('name: ink/stitch: '): self.name = self.name[18:] - columns_line = palette.readline() - headers_line = palette.readline() + # number of columns + palette.readline() + + # headers + palette.readline() for line in palette: fields = line.split("\t", 3) diff --git a/lib/utils/geometry.py b/lib/utils/geometry.py index eb1a28fa..ef5f12b5 100644 --- a/lib/utils/geometry.py +++ b/lib/utils/geometry.py @@ -80,7 +80,7 @@ class Point: if isinstance(other, (int, float)): return self * (1.0 / other) else: - raise ValueErorr("cannot divide Point by %s" % type(other)) + raise ValueError("cannot divide Point by %s" % type(other)) def __repr__(self): return "Point(%s,%s)" % (self.x, self.y) diff --git a/messages.po b/messages.po index 94de4c34..3f5a5041 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-21 20:50-0400\n" +"POT-Creation-Date: 2018-08-21 21:43-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -119,7 +119,7 @@ msgid "" "shapes." msgstr "" -#: lib/elements/element.py:232 +#: lib/elements/element.py:230 #, python-format msgid "%(id)s has more than one command of type '%(command)s' linked to it" msgstr "" @@ -381,106 +381,106 @@ msgstr "" msgid "Tip: use Path -> Object to Path to convert non-paths." msgstr "" -#: lib/extensions/convert_to_satin.py:28 +#: lib/extensions/convert_to_satin.py:29 msgid "Please select at least one line to convert to a satin column." msgstr "" #. : Convert To Satin extension, user selected one or more objects that were #. not lines. -#: lib/extensions/convert_to_satin.py:33 +#: lib/extensions/convert_to_satin.py:34 msgid "Only simple lines may be converted to satin columns." msgstr "" -#: lib/extensions/convert_to_satin.py:55 +#: lib/extensions/convert_to_satin.py:56 #, python-format msgid "" "Cannot convert %s to a satin column because it intersects itself. Try " "breaking it up into multiple paths." msgstr "" -#: lib/extensions/embroider.py:41 +#: lib/extensions/embroider.py:38 msgid "" "\n" "\n" "Seeing a 'no such option' message? Please restart Inkscape to fix." msgstr "" -#: lib/extensions/flip.py:36 +#: lib/extensions/flip.py:35 msgid "Please select one or more satin columns to flip." msgstr "" -#: lib/extensions/install.py:30 +#: lib/extensions/install.py:25 msgid "" "Ink/Stitch can install files (\"add-ons\") that make it easier to use " "Inkscape to create machine embroidery designs. These add-ons will be " "installed:" msgstr "" -#: lib/extensions/install.py:32 +#: lib/extensions/install.py:27 msgid "thread manufacturer color palettes" msgstr "" -#: lib/extensions/install.py:33 +#: lib/extensions/install.py:28 msgid "Ink/Stitch visual commands (Object -> Symbols...)" msgstr "" -#: lib/extensions/install.py:42 +#: lib/extensions/install.py:37 msgid "Install" msgstr "" -#: lib/extensions/install.py:45 lib/extensions/params.py:380 +#: lib/extensions/install.py:40 lib/extensions/params.py:380 msgid "Cancel" msgstr "" -#: lib/extensions/install.py:59 +#: lib/extensions/install.py:54 msgid "Choose Inkscape directory" msgstr "" -#: lib/extensions/install.py:69 +#: lib/extensions/install.py:64 msgid "Inkscape add-on installation failed" msgstr "" -#: lib/extensions/install.py:70 +#: lib/extensions/install.py:65 msgid "Installation Failed" msgstr "" -#: lib/extensions/install.py:74 +#: lib/extensions/install.py:69 msgid "" "Inkscape add-on files have been installed. Please restart Inkscape to " "load the new add-ons." msgstr "" -#: lib/extensions/install.py:75 +#: lib/extensions/install.py:70 msgid "Installation Completed" msgstr "" -#: lib/extensions/install.py:105 +#: lib/extensions/install.py:100 msgid "Ink/Stitch Add-ons Installer" msgstr "" -#: lib/extensions/layer_commands.py:29 +#: lib/extensions/layer_commands.py:27 msgid "Please choose one or more commands to add." msgstr "" -#: lib/extensions/layer_commands.py:41 lib/extensions/object_commands.py:80 +#: lib/extensions/layer_commands.py:39 lib/extensions/object_commands.py:74 msgid "Ink/Stitch Command" msgstr "" #. : the name of the line that connects a command to the object it applies to -#: lib/extensions/object_commands.py:36 +#: lib/extensions/object_commands.py:30 msgid "connector" msgstr "" #. : the name of a command symbol (example: scissors icon for trim command) -#: lib/extensions/object_commands.py:95 +#: lib/extensions/object_commands.py:89 msgid "command marker" msgstr "" -#: lib/extensions/object_commands.py:106 +#: lib/extensions/object_commands.py:100 msgid "Please select one or more objects to which to attach commands." msgstr "" -#: lib/extensions/object_commands.py:114 +#: lib/extensions/object_commands.py:108 msgid "Please choose one or more commands to attach." msgstr "" @@ -578,15 +578,15 @@ msgid "" "\"Overwrite\"" msgstr "" -#: lib/extensions/print_pdf.py:134 +#: lib/extensions/print_pdf.py:132 msgid "Closing..." msgstr "" -#: lib/extensions/print_pdf.py:134 +#: lib/extensions/print_pdf.py:132 msgid "It is safe to close this window now." msgstr "" -#: lib/extensions/print_pdf.py:265 +#: lib/extensions/print_pdf.py:263 msgid "" "A print preview has been opened in your web browser. This window will " "stay open in order to communicate with the JavaScript code running in " @@ -596,7 +596,7 @@ msgid "" " or you can close it manually if necessary." msgstr "" -#: lib/extensions/print_pdf.py:414 +#: lib/extensions/print_pdf.py:412 msgid "Ink/Stitch Print" msgstr "" @@ -604,7 +604,7 @@ msgstr "" msgid "Embroidery Simulation" msgstr "" -#: lib/extensions/zip.py:52 +#: lib/extensions/zip.py:49 msgid "No embroidery file formats selected." msgstr "" @@ -663,13 +663,13 @@ msgstr "" msgid "Stitch #" msgstr "" -#: lib/stitches/auto_fill.py:169 +#: lib/stitches/auto_fill.py:167 msgid "" "Unable to autofill. This most often happens because your shape is made " "up of multiple sections that aren't connected." msgstr "" -#: lib/stitches/auto_fill.py:398 +#: lib/stitches/auto_fill.py:395 msgid "" "Unexpected error while generating fill stitches. Please send your SVG " "file to lexelby@github." @@ -679,12 +679,12 @@ msgstr "" msgid "Stitch Plan" msgstr "" -#: lib/svg/units.py:45 +#: lib/svg/units.py:46 #, python-format msgid "parseLengthWithUnits: unknown unit %s" msgstr "" -#: lib/svg/units.py:77 +#: lib/svg/units.py:78 #, python-format msgid "Unknown unit: %s" msgstr "" -- cgit v1.3.1 From f53fe0520098d26e65d89adcf1580b36433c4927 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Tue, 21 Aug 2018 21:57:15 -0400 Subject: a few more fixups --- lib/extensions/layer_commands.py | 20 ++++++++++---------- lib/extensions/output.py | 1 - lib/extensions/print_pdf.py | 2 +- lib/simulator.py | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-) (limited to 'lib/extensions') diff --git a/lib/extensions/layer_commands.py b/lib/extensions/layer_commands.py index 8210c7c6..dbafc39f 100644 --- a/lib/extensions/layer_commands.py +++ b/lib/extensions/layer_commands.py @@ -34,13 +34,13 @@ class LayerCommands(CommandsExtension): self.ensure_symbol(command) inkex.etree.SubElement(self.current_layer, SVG_USE_TAG, - { - "id": self.uniqueId("use"), - INKSCAPE_LABEL: _("Ink/Stitch Command") + ": %s" % get_command_description(command), - XLINK_HREF: "#inkstitch_%s" % command, - "height": "100%", - "width": "100%", - "x": str(i * 20), - "y": "-10", - "transform": correction_transform - }) + { + "id": self.uniqueId("use"), + INKSCAPE_LABEL: _("Ink/Stitch Command") + ": %s" % get_command_description(command), + XLINK_HREF: "#inkstitch_%s" % command, + "height": "100%", + "width": "100%", + "x": str(i * 20), + "y": "-10", + "transform": correction_transform + }) diff --git a/lib/extensions/output.py b/lib/extensions/output.py index 9ffa82a3..26fd4f2e 100644 --- a/lib/extensions/output.py +++ b/lib/extensions/output.py @@ -3,7 +3,6 @@ import os import tempfile from .base import InkstitchExtension -from ..i18n import _ from ..output import write_embroidery_file from ..stitch_plan import patches_to_stitch_plan from ..svg import PIXELS_PER_MM diff --git a/lib/extensions/print_pdf.py b/lib/extensions/print_pdf.py index 47b89061..d2e2365d 100644 --- a/lib/extensions/print_pdf.py +++ b/lib/extensions/print_pdf.py @@ -107,7 +107,7 @@ class PrintPreviewServer(Thread): else: self.resources_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', '..', 'print', 'resources')) - def __setup_app(self): + def __setup_app(self): # noqa: C901 self.__set_resources_path() self.app = Flask(__name__) diff --git a/lib/simulator.py b/lib/simulator.py index 5620f65b..3df72a08 100644 --- a/lib/simulator.py +++ b/lib/simulator.py @@ -5,7 +5,7 @@ import colorsys from itertools import izip from .svg import PIXELS_PER_MM, color_block_to_point_lists - +from .i18n import _ class EmbroiderySimulator(wx.Frame): def __init__(self, *args, **kwargs): -- cgit v1.3.1 From 674283c13557a5c0e30d7e8a2048c3297b044888 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Wed, 22 Aug 2018 14:12:39 -0400 Subject: fix missing install extension INX file --- lib/extensions/__init__.py | 21 ++++++++++++--------- lib/extensions/install.py | 4 ++++ lib/inx/utils.py | 2 +- messages.po | 4 ++-- 4 files changed, 19 insertions(+), 12 deletions(-) (limited to 'lib/extensions') diff --git a/lib/extensions/__init__.py b/lib/extensions/__init__.py index 1606795c..cf0313b2 100644 --- a/lib/extensions/__init__.py +++ b/lib/extensions/__init__.py @@ -11,12 +11,15 @@ 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) +__all__ = extensions = [Embroider, + Install, + Params, + Print, + Simulate, + Input, + Output, + Zip, + Flip, + ObjectCommands, + LayerCommands, + ConvertToSatin] diff --git a/lib/extensions/install.py b/lib/extensions/install.py index 42a92113..3644afad 100644 --- a/lib/extensions/install.py +++ b/lib/extensions/install.py @@ -98,6 +98,10 @@ class InstallerFrame(wx.Frame): shutil.copy(palette_file, dest) class Install(inkex.Effect): + @classmethod + def name(cls): + return "install" + def effect(self): app = wx.App() installer_frame = InstallerFrame(None, title=_("Ink/Stitch Add-ons Installer"), size=(550, 250)) diff --git a/lib/inx/utils.py b/lib/inx/utils.py index cd0fdc6e..7c471276 100644 --- a/lib/inx/utils.py +++ b/lib/inx/utils.py @@ -28,7 +28,7 @@ def build_environment(): def write_inx_file(name, contents): inx_file_name = "inkstitch_%s_%s.inx" % (name, current_locale) with open(os.path.join(inx_path, inx_file_name), 'w') as inx_file: - print >> inx_file.encode("utf-8"), contents + print >> inx_file, contents.encode("utf-8") def iterate_inx_locales(): global current_translation, current_locale diff --git a/messages.po b/messages.po index 074159c4..df36b6e9 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-20 20:42-0400\n" +"POT-Creation-Date: 2018-08-22 14:12-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -454,7 +454,7 @@ msgstr "" msgid "Installation Completed" msgstr "" -#: lib/extensions/install.py:103 +#: lib/extensions/install.py:107 msgid "Ink/Stitch Add-ons Installer" msgstr "" -- cgit v1.3.1 From 82d7f494184a031dabc6f5318c13c477ec8052a1 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Thu, 23 Aug 2018 21:24:46 -0400 Subject: properly internationalize install extension --- lib/extensions/install.py | 1 + messages.po | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) (limited to 'lib/extensions') diff --git a/lib/extensions/install.py b/lib/extensions/install.py index 3644afad..e405cbac 100644 --- a/lib/extensions/install.py +++ b/lib/extensions/install.py @@ -14,6 +14,7 @@ import wx import inkex from ..utils import guess_inkscape_config_path, get_bundled_dir +from ..i18n import _ class InstallerFrame(wx.Frame): diff --git a/messages.po b/messages.po index cbb660de..fb3abe12 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-23 20:56-0400\n" +"POT-Creation-Date: 2018-08-23 21:24-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -409,52 +409,52 @@ msgstr "" msgid "Please select one or more satin columns to flip." msgstr "" -#: lib/extensions/install.py:30 +#: lib/extensions/install.py:31 msgid "" "Ink/Stitch can install files (\"add-ons\") that make it easier to use " "Inkscape to create machine embroidery designs. These add-ons will be " "installed:" msgstr "" -#: lib/extensions/install.py:31 +#: lib/extensions/install.py:32 msgid "thread manufacturer color palettes" msgstr "" -#: lib/extensions/install.py:32 +#: lib/extensions/install.py:33 msgid "Ink/Stitch visual commands (Object -> Symbols...)" msgstr "" -#: lib/extensions/install.py:41 +#: lib/extensions/install.py:42 msgid "Install" msgstr "" -#: lib/extensions/install.py:44 lib/extensions/params.py:380 +#: lib/extensions/install.py:45 lib/extensions/params.py:380 msgid "Cancel" msgstr "" -#: lib/extensions/install.py:58 +#: lib/extensions/install.py:59 msgid "Choose Inkscape directory" msgstr "" -#: lib/extensions/install.py:68 +#: lib/extensions/install.py:69 msgid "Inkscape add-on installation failed" msgstr "" -#: lib/extensions/install.py:69 +#: lib/extensions/install.py:70 msgid "Installation Failed" msgstr "" -#: lib/extensions/install.py:73 +#: lib/extensions/install.py:74 msgid "" "Inkscape add-on files have been installed. Please restart Inkscape to " "load the new add-ons." msgstr "" -#: lib/extensions/install.py:74 +#: lib/extensions/install.py:75 msgid "Installation Completed" msgstr "" -#: lib/extensions/install.py:107 +#: lib/extensions/install.py:108 msgid "Ink/Stitch Add-ons Installer" msgstr "" -- cgit v1.3.1 From a448b2c0ea4e61b28dccd406ffcc5a5ebb96cdd2 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Wed, 22 Aug 2018 22:13:51 -0400 Subject: add origin command and remove guides method --- lib/commands.py | 30 ++++++++++++++----------- lib/extensions/base.py | 2 +- lib/output.py | 59 ++++++++++++-------------------------------------- messages.po | 21 +++++++++++------- 4 files changed, 45 insertions(+), 67 deletions(-) (limited to 'lib/extensions') diff --git a/lib/commands.py b/lib/commands.py index b9cf9610..37196990 100644 --- a/lib/commands.py +++ b/lib/commands.py @@ -1,5 +1,6 @@ import inkex import cubicsuperpath +import simpletransform from .svg import apply_transforms, get_node_transform from .svg.tags import SVG_USE_TAG, SVG_SYMBOL_TAG, CONNECTION_START, CONNECTION_END, XLINK_HREF @@ -22,8 +23,11 @@ COMMANDS = { # L10N command attached to an object "ignore_object": N_("Ignore this object (do not stitch)"), - # L10N command that affects entire layer - "ignore_layer": N_("Ignore layer (do not stitch any objects in this layer)") + # L10N command that affects a layer + "ignore_layer": N_("Ignore layer (do not stitch any objects in this layer)"), + + # L10N command that affects entire document + "origin": N_("Origin for exported embroidery files"), } OBJECT_COMMANDS = ["fill_start", "fill_end", "stop", "trim", "ignore_object"] @@ -153,31 +157,31 @@ def find_commands(node): def layer_commands(layer, command): """Find standalone (unconnected) command symbols in this layer.""" - commands = [] + for global_command in global_commands(layer.getroottree().getroot(), command): + if layer in global_command.node.iterancestors(): + yield global_command - for standalone_command in standalone_commands(layer.getroottree().getroot()): - if standalone_command.command == command: - if layer in standalone_command.node.iterancestors(): - commands.append(command) - return commands +def global_commands(svg, command): + """Find standalone (unconnected) command symbols anywhere in the document.""" + for standalone_command in _standalone_commands(svg): + if standalone_command.command == command: + yield standalone_command -def standalone_commands(svg): + +def _standalone_commands(svg): """Find all unconnected command symbols in the SVG.""" xpath = ".//svg:use[starts-with(@xlink:href, '#inkstitch_')]" symbols = svg.xpath(xpath, namespaces=inkex.NSS) - commands = [] for symbol in symbols: try: - commands.append(StandaloneCommand(symbol)) + yield StandaloneCommand(symbol) except CommandParseError: pass - return commands - def is_command(node): return CONNECTION_START in node.attrib or CONNECTION_END in node.attrib diff --git a/lib/extensions/base.py b/lib/extensions/base.py index 22bc82db..25de441f 100644 --- a/lib/extensions/base.py +++ b/lib/extensions/base.py @@ -123,7 +123,7 @@ class InkstitchExtension(inkex.Effect): return [] if node.tag == SVG_GROUP_TAG and node.get(INKSCAPE_GROUPMODE) == "layer": - if layer_commands(node, "ignore_layer"): + if len(list(layer_commands(node, "ignore_layer"))): return [] if element.has_style('display') and element.get_style('display') is None: diff --git a/lib/output.py b/lib/output.py index eed665ed..ae15ce4e 100644 --- a/lib/output.py +++ b/lib/output.py @@ -5,6 +5,7 @@ import shapely.geometry as shgeo from .utils import Point from .svg import PIXELS_PER_MM, get_doc_size, get_viewbox_transform +from .commands import global_commands def get_command(stitch): @@ -26,57 +27,25 @@ def _string_to_floats(string): def get_origin(svg): - # The user can specify the embroidery origin by defining two guides - # named "embroidery origin" that intersect. + origin_commands = list(global_commands(svg, "origin")) - namedview = svg.find(inkex.addNS('namedview', 'sodipodi')) - all_guides = namedview.findall(inkex.addNS('guide', 'sodipodi')) - label_attribute = inkex.addNS('label', 'inkscape') - guides = [guide for guide in all_guides - if guide.get(label_attribute, "").startswith("embroidery origin")] + if origin_commands: + origin = origin_commands[0].point - # document size used below - doc_size = list(get_doc_size(svg)) - - # convert the size from viewbox-relative to real-world pixels - viewbox_transform = get_viewbox_transform(svg) - simpletransform.applyTransformToPoint(simpletransform.invertTransform(viewbox_transform), doc_size) - - default = [doc_size[0] / 2.0, doc_size[1] / 2.0] - simpletransform.applyTransformToPoint(viewbox_transform, default) - default = Point(*default) - - if len(guides) < 2: - return default - - # Find out where the guides intersect. Only pay attention to the first two. - guides = guides[:2] - - lines = [] - for guide in guides: - # inkscape's Y axis is reversed from SVG's, and the guide is in inkscape coordinates - position = Point(*_string_to_floats(guide.get('position'))) - position.y = doc_size[1] - position.y + return origin + else: + # default: center of the canvas - # This one baffles me. I think inkscape might have gotten the order of - # their vector wrong? - parts = _string_to_floats(guide.get('orientation')) - direction = Point(parts[1], parts[0]) + doc_size = list(get_doc_size(svg)) - # We have a theoretically infinite line defined by a point on the line - # and a vector direction. Shapely can only deal in concrete line - # segments, so we'll pick points really far in either direction on the - # line and call it good enough. - lines.append(shgeo.LineString((position + 100000 * direction, position - 100000 * direction))) + # convert the size from viewbox-relative to real-world pixels + viewbox_transform = get_viewbox_transform(svg) + simpletransform.applyTransformToPoint(simpletransform.invertTransform(viewbox_transform), doc_size) - intersection = lines[0].intersection(lines[1]) + default = [doc_size[0] / 2.0, doc_size[1] / 2.0] + simpletransform.applyTransformToPoint(viewbox_transform, default) + default = Point(*default) - if isinstance(intersection, shgeo.Point): - origin = [intersection.x, intersection.y] - simpletransform.applyTransformToPoint(viewbox_transform, origin) - return Point(*origin) - else: - # Either the two guides are the same line, or they're parallel. return default diff --git a/messages.po b/messages.po index 5443542a..2d082dd5 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-24 20:45-0400\n" +"POT-Creation-Date: 2018-08-24 20:54-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,35 +18,40 @@ msgstr "" "Generated-By: Babel 2.5.3\n" #. command attached to an object -#: lib/commands.py:11 +#: lib/commands.py:12 msgid "Fill stitch starting position" msgstr "" #. command attached to an object -#: lib/commands.py:14 +#: lib/commands.py:15 msgid "Fill stitch ending position" msgstr "" #. command attached to an object -#: lib/commands.py:17 +#: lib/commands.py:18 msgid "Stop (pause machine) after sewing this object" msgstr "" #. command attached to an object -#: lib/commands.py:20 +#: lib/commands.py:21 msgid "Trim thread after sewing this object" msgstr "" #. command attached to an object -#: lib/commands.py:23 +#: lib/commands.py:24 msgid "Ignore this object (do not stitch)" msgstr "" -#. command that affects entire layer -#: lib/commands.py:26 +#. command that affects a layer +#: lib/commands.py:27 msgid "Ignore layer (do not stitch any objects in this layer)" msgstr "" +#. command that affects entire document +#: lib/commands.py:30 +msgid "Origin for exported embroidery files" +msgstr "" + #: lib/elements/auto_fill.py:11 msgid "Auto-Fill" msgstr "" -- cgit v1.3.1 From 53f92df05635668783a6b9407a01326de14a1291 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Fri, 24 Aug 2018 16:29:13 -0400 Subject: add 'Add Commands' extension --- lib/commands.py | 3 ++- lib/extensions/__init__.py | 2 ++ lib/extensions/global_commands.py | 14 ++++++++++++++ lib/inx/extensions.py | 9 +++++++-- messages.po | 29 ++++++++++++++++++++++------- templates/global_commands.inx | 26 ++++++++++++++++++++++++++ templates/layer_commands.inx | 4 +++- templates/object_commands.inx | 6 ++++-- 8 files changed, 80 insertions(+), 13 deletions(-) create mode 100644 lib/extensions/global_commands.py create mode 100644 templates/global_commands.inx (limited to 'lib/extensions') diff --git a/lib/commands.py b/lib/commands.py index 3a4ca230..db3c8a71 100644 --- a/lib/commands.py +++ b/lib/commands.py @@ -31,11 +31,12 @@ COMMANDS = { N_("origin"): N_("Origin for exported embroidery files"), # L10N command that affects entire document - N_("stop_point"): N_("Jump destination for Stop commands (a.k.a. \"Frame Out position\")."), + N_("stop_position"): N_("Jump destination for Stop commands (a.k.a. \"Frame Out position\")."), } OBJECT_COMMANDS = ["fill_start", "fill_end", "stop", "trim", "ignore_object"] LAYER_COMMANDS = ["ignore_layer"] +GLOBAL_COMMANDS = ["origin", "stop_position"] class CommandParseError(Exception): diff --git a/lib/extensions/__init__.py b/lib/extensions/__init__.py index cf0313b2..5b72ecb3 100644 --- a/lib/extensions/__init__.py +++ b/lib/extensions/__init__.py @@ -9,6 +9,7 @@ from zip import Zip from flip import Flip from object_commands import ObjectCommands from layer_commands import LayerCommands +from global_commands import GlobalCommands from convert_to_satin import ConvertToSatin __all__ = extensions = [Embroider, @@ -22,4 +23,5 @@ __all__ = extensions = [Embroider, Flip, ObjectCommands, LayerCommands, + GlobalCommands, ConvertToSatin] diff --git a/lib/extensions/global_commands.py b/lib/extensions/global_commands.py new file mode 100644 index 00000000..55848be9 --- /dev/null +++ b/lib/extensions/global_commands.py @@ -0,0 +1,14 @@ +import inkex + +from .layer_commands import LayerCommands +from ..commands import GLOBAL_COMMANDS + + +# It's a bit weird subclassing this from LayerCommands, but global commands +# must still be placed in a layer. That means the two extensions +# do the same thing and the code is the same. We keep this as separate +# extensions because we want the user to understand that global commands +# affect the entire document, not just the current layer. + +class GlobalCommands(LayerCommands): + COMMANDS = GLOBAL_COMMANDS diff --git a/lib/inx/extensions.py b/lib/inx/extensions.py index 4b4b3c13..d1a0c7f3 100755 --- a/lib/inx/extensions.py +++ b/lib/inx/extensions.py @@ -3,7 +3,7 @@ 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, COMMANDS +from ..commands import LAYER_COMMANDS, OBJECT_COMMANDS, GLOBAL_COMMANDS, COMMANDS def layer_commands(): @@ -13,6 +13,10 @@ def layer_commands(): 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] @@ -35,4 +39,5 @@ def generate_extension_inx_files(): write_inx_file(name, template.render(formats=pyembroidery_output_formats(), debug_formats=pyembroidery_debug_formats(), layer_commands=layer_commands(), - object_commands=object_commands())) + object_commands=object_commands(), + global_commands=global_commands())) diff --git a/messages.po b/messages.po index d5dbe507..9105da77 100644 --- a/messages.po +++ b/messages.po @@ -82,14 +82,14 @@ msgstr "" #. command that affects entire document #: lib/commands.py:34 -msgid "stop_point" +msgid "stop_position" msgstr "" #: lib/commands.py:34 msgid "Jump destination for Stop commands (a.k.a. \"Frame Out position\")." msgstr "" -#: lib/commands.py:189 +#: lib/commands.py:190 #, python-format msgid "" "Error: there is more than one %(command)s command in the document, but " @@ -101,7 +101,7 @@ msgstr "" #. command name to them. Contents of %(description)s are in a separate #. translation #. string. -#: lib/commands.py:196 +#: lib/commands.py:197 #, python-format msgid "%(command)s: %(description)s" msgstr "" @@ -1176,9 +1176,10 @@ msgstr "" #. to your language's word for its language, e.g. "Español" for the spanish #. translation. #: templates/convert_to_satin.inx:12 templates/embroider.inx:24 -#: templates/flip.inx:12 templates/install.inx:12 -#: templates/layer_commands.inx:16 templates/object_commands.inx:15 -#: templates/params.inx:12 templates/print.inx:12 templates/simulate.inx:12 +#: templates/flip.inx:12 templates/global_commands.inx:16 +#: templates/install.inx:12 templates/layer_commands.inx:16 +#: templates/object_commands.inx:15 templates/params.inx:12 +#: templates/print.inx:12 templates/simulate.inx:12 msgid "English" msgstr "" @@ -1224,6 +1225,20 @@ msgstr "" msgid "Flip Satin Columns" msgstr "" +#: templates/global_commands.inx:3 +msgid "Add Commands" +msgstr "" + +#: templates/global_commands.inx:7 +msgid "These commands affect the entire embroidery design." +msgstr "" + +#. Inkscape submenu under Extensions -> Ink/Stitch +#: templates/global_commands.inx:18 templates/layer_commands.inx:17 +#: templates/object_commands.inx:16 +msgid "Commands" +msgstr "" + #: templates/input.inx:11 #, python-format msgid "convert %(file_extension)s file to Ink/Stitch manual-stitch paths" @@ -1242,7 +1257,7 @@ msgid "Commands will be added to the currently-selected layer." msgstr "" #: templates/object_commands.inx:3 -msgid "Attach Commands" +msgid "Attach Commands to Selected Objects" msgstr "" #: templates/output.inx:11 diff --git a/templates/global_commands.inx b/templates/global_commands.inx new file mode 100644 index 00000000..eda2721d --- /dev/null +++ b/templates/global_commands.inx @@ -0,0 +1,26 @@ + + + {% trans %}Add Commands{% endtrans %} + org.inkstitch.global_commands.{{ locale }} + inkstitch.py + inkex.py + {% trans %}These commands affect the entire embroidery design.{% endtrans %} + {% for command, description in global_commands %} + false + {% endfor %} + global_commands + + all + + + + {# L10N Inkscape submenu under Extensions -> Ink/Stitch #} + + + + + + + diff --git a/templates/layer_commands.inx b/templates/layer_commands.inx index a6c0283c..f1a8f987 100644 --- a/templates/layer_commands.inx +++ b/templates/layer_commands.inx @@ -13,7 +13,9 @@ all - + + + diff --git a/templates/object_commands.inx b/templates/object_commands.inx index 6de2a3fc..68535db2 100644 --- a/templates/object_commands.inx +++ b/templates/object_commands.inx @@ -1,6 +1,6 @@ - {% trans %}Attach Commands{% endtrans %} + {% trans %}Attach Commands to Selected Objects{% endtrans %} org.inkstitch.commands.{{ locale }} inkstitch.py inkex.py @@ -12,7 +12,9 @@ all - + + + -- cgit v1.3.1 From 77177f9b55f57d1373408b3dc619a53fe45d00ce Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Fri, 24 Aug 2018 20:40:56 -0400 Subject: fix style --- lib/extensions/global_commands.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'lib/extensions') diff --git a/lib/extensions/global_commands.py b/lib/extensions/global_commands.py index 55848be9..9655c7af 100644 --- a/lib/extensions/global_commands.py +++ b/lib/extensions/global_commands.py @@ -1,5 +1,3 @@ -import inkex - from .layer_commands import LayerCommands from ..commands import GLOBAL_COMMANDS -- cgit v1.3.1