From 038875f876d79d0f1e971886fe42f5bee4f9f31e Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Tue, 21 Aug 2018 20:32:50 -0400 Subject: autopep8 --- lib/stitches/auto_fill.py | 31 ++++++++++++++++++------------- lib/stitches/fill.py | 2 ++ 2 files changed, 20 insertions(+), 13 deletions(-) (limited to 'lib/stitches') 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 -- 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/stitches') 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/stitches') 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