From 038875f876d79d0f1e971886fe42f5bee4f9f31e Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Tue, 21 Aug 2018 20:32:50 -0400 Subject: autopep8 --- 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 +++++++++++++++++++------------------- 10 files changed, 116 insertions(+), 116 deletions(-) (limited to 'lib/extensions') 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) -- cgit v1.2.3 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/extensions/install.py | 6 ++++-- lib/extensions/print_pdf.py | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/extensions') 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) -- cgit v1.2.3 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/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 +---- 12 files changed, 13 insertions(+), 44 deletions(-) (limited to 'lib/extensions') 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): -- cgit v1.2.3 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 +- 3 files changed, 11 insertions(+), 12 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__) -- cgit v1.2.3