From 7bf8c2d871eb012ad2fbbf34433bd6ea0affb9e5 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Fri, 24 Aug 2018 21:20:59 -0400 Subject: helpful error message for empty path "d" attribute (fixes #220) also internationalizes "error:" string --- lib/elements/element.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/elements') diff --git a/lib/elements/element.py b/lib/elements/element.py index 4edb00c0..bca743c2 100644 --- a/lib/elements/element.py +++ b/lib/elements/element.py @@ -197,7 +197,11 @@ class EmbroideryElement(object): # In a path, each element in the 3-tuple is itself a tuple of (x, y). # Tuples all the way down. Hasn't anyone heard of using classes? - return cubicsuperpath.parsePath(self.node.get("d")) + d = self.node.get("d", "") + if not d: + self.fatal(_("Object %(id)s has an empty 'd' attribute. Please delete this object from your document.") % dict(id=self.node.get("id"))) + + return cubicsuperpath.parsePath(d) @cache def parse_path(self): @@ -264,5 +268,7 @@ class EmbroideryElement(object): return patches def fatal(self, message): - print >> sys.stderr, "error:", message + # L10N used when showing an error message to the user such as "satin column: One or more of the rungs doesn't + # intersect both rails." + print >> sys.stderr, _("error:"), message sys.exit(1) -- cgit v1.3.1 From 05327d56dbdcc9392c447fc72ef8dbd5c16f0ddc Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sat, 1 Sep 2018 16:38:53 -0400 Subject: stop showing 'None' in Params --- lib/elements/auto_fill.py | 2 +- lib/extensions/params.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/elements') diff --git a/lib/elements/auto_fill.py b/lib/elements/auto_fill.py index cfee6d7d..9801b610 100644 --- a/lib/elements/auto_fill.py +++ b/lib/elements/auto_fill.py @@ -55,7 +55,7 @@ class AutoFill(Fill): def fill_underlay_angle(self): underlay_angle = self.get_float_param("fill_underlay_angle") - if underlay_angle: + if underlay_angle is not None: return math.radians(underlay_angle) else: return self.angle + math.pi / 2.0 diff --git a/lib/extensions/params.py b/lib/extensions/params.py index c301ed1a..f5da7e8b 100644 --- a/lib/extensions/params.py +++ b/lib/extensions/params.py @@ -329,7 +329,7 @@ class ParamsTab(ScrolledPanel): input.Bind(wx.EVT_CHECKBOX, self.changed) elif len(param.values) > 1: - input = wx.ComboBox(self, wx.ID_ANY, choices=sorted(param.values), style=wx.CB_DROPDOWN) + input = wx.ComboBox(self, wx.ID_ANY, choices=sorted(str(value) for value in param.values), style=wx.CB_DROPDOWN) input.Bind(wx.EVT_COMBOBOX, self.changed) input.Bind(wx.EVT_TEXT, self.changed) else: @@ -720,7 +720,7 @@ class Params(InkstitchExtension): getter = 'get_param' values = filter(lambda item: item is not None, - (getattr(node, getter)(param.name, str(param.default)) for node in nodes)) + (getattr(node, getter)(param.name, param.default) for node in nodes)) return values -- cgit v1.3.1 From 29f0e31ccdce084abf5f49d366733558cd288cfa Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sat, 1 Sep 2018 19:54:13 -0400 Subject: name AutoFill tabs consistently --- lib/elements/auto_fill.py | 2 +- messages.po | 54 +++++++++++++++++++++++------------------------ 2 files changed, 28 insertions(+), 28 deletions(-) (limited to 'lib/elements') diff --git a/lib/elements/auto_fill.py b/lib/elements/auto_fill.py index 9801b610..65b11fb1 100644 --- a/lib/elements/auto_fill.py +++ b/lib/elements/auto_fill.py @@ -8,7 +8,7 @@ from .fill import Fill class AutoFill(Fill): - element_name = _("Auto-Fill") + element_name = _("AutoFill") @property @param('auto_fill', _('Automatically routed fill stitching'), type='toggle', default=True) diff --git a/messages.po b/messages.po index efa4ca22..7d14b239 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-09-01 16:26-0400\n" +"POT-Creation-Date: 2018-09-01 19:54-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -107,7 +107,7 @@ msgid "%(command)s: %(description)s" msgstr "" #: lib/elements/auto_fill.py:11 -msgid "Auto-Fill" +msgid "AutoFill" msgstr "" #: lib/elements/auto_fill.py:14 @@ -501,7 +501,7 @@ msgstr "" msgid "Install" msgstr "" -#: lib/extensions/install.py:40 lib/extensions/params.py:411 +#: lib/extensions/install.py:40 lib/extensions/params.py:409 msgid "Cancel" msgstr "" @@ -557,104 +557,104 @@ msgstr "" msgid "Please choose one or more commands to attach." msgstr "" -#: lib/extensions/params.py:252 +#: lib/extensions/params.py:250 msgid "These settings will be applied to 1 object." msgstr "" -#: lib/extensions/params.py:254 +#: lib/extensions/params.py:252 #, python-format msgid "These settings will be applied to %d objects." msgstr "" -#: lib/extensions/params.py:257 +#: lib/extensions/params.py:255 msgid "" "Some settings had different values across objects. Select a value from " "the dropdown or enter a new one." msgstr "" -#: lib/extensions/params.py:261 +#: lib/extensions/params.py:259 #, python-format msgid "Disabling this tab will disable the following %d tabs." msgstr "" -#: lib/extensions/params.py:263 +#: lib/extensions/params.py:261 msgid "Disabling this tab will disable the following tab." msgstr "" -#: lib/extensions/params.py:266 +#: lib/extensions/params.py:264 #, python-format msgid "Enabling this tab will disable %s and vice-versa." msgstr "" -#: lib/extensions/params.py:296 +#: lib/extensions/params.py:294 msgid "Inkscape objects" msgstr "" -#: lib/extensions/params.py:354 +#: lib/extensions/params.py:352 msgid "" "Click to force this parameter to be saved when you click \"Apply and " "Quit\"" msgstr "" -#: lib/extensions/params.py:362 +#: lib/extensions/params.py:360 msgid "This parameter will be saved when you click \"Apply and Quit\"" msgstr "" -#: lib/extensions/params.py:377 +#: lib/extensions/params.py:375 msgid "Embroidery Params" msgstr "" -#: lib/extensions/params.py:394 +#: lib/extensions/params.py:392 msgid "Presets" msgstr "" -#: lib/extensions/params.py:399 +#: lib/extensions/params.py:397 msgid "Load" msgstr "" -#: lib/extensions/params.py:402 +#: lib/extensions/params.py:400 msgid "Add" msgstr "" -#: lib/extensions/params.py:405 +#: lib/extensions/params.py:403 msgid "Overwrite" msgstr "" -#: lib/extensions/params.py:408 +#: lib/extensions/params.py:406 msgid "Delete" msgstr "" -#: lib/extensions/params.py:415 +#: lib/extensions/params.py:413 msgid "Use Last Settings" msgstr "" -#: lib/extensions/params.py:418 +#: lib/extensions/params.py:416 msgid "Apply and Quit" msgstr "" -#: lib/extensions/params.py:470 +#: lib/extensions/params.py:468 msgid "Preview" msgstr "" -#: lib/extensions/params.py:489 +#: lib/extensions/params.py:487 msgid "Internal Error" msgstr "" -#: lib/extensions/params.py:542 +#: lib/extensions/params.py:540 msgid "Please enter or select a preset name first." msgstr "" -#: lib/extensions/params.py:542 lib/extensions/params.py:548 -#: lib/extensions/params.py:576 +#: lib/extensions/params.py:540 lib/extensions/params.py:546 +#: lib/extensions/params.py:574 msgid "Preset" msgstr "" -#: lib/extensions/params.py:548 +#: lib/extensions/params.py:546 #, python-format msgid "Preset \"%s\" not found." msgstr "" -#: lib/extensions/params.py:576 +#: lib/extensions/params.py:574 #, python-format msgid "" "Preset \"%s\" already exists. Please use another name or press " -- cgit v1.3.1 From 1c2dc2d95442b3663eebf1e2b633f3bb388982c0 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sat, 1 Sep 2018 20:06:39 -0400 Subject: add error message for invalid geometries (#216) --- lib/elements/fill.py | 5 ++++- messages.po | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/elements') diff --git a/lib/elements/fill.py b/lib/elements/fill.py index 626573e6..4156a24b 100644 --- a/lib/elements/fill.py +++ b/lib/elements/fill.py @@ -120,7 +120,10 @@ class Fill(EmbroideryElement): poly_ary.sort(key=lambda point_list: shgeo.Polygon(point_list).area, reverse=True) polygon = shgeo.MultiPolygon([(poly_ary[0], poly_ary[1:])]) - # print >> sys.stderr, "polygon valid:", polygon.is_valid + + if not polygon.is_valid: + self.fatal(_("shape is not valid. This can happen if the border crosses over itself.")) + return polygon def to_patches(self, last_patch): diff --git a/messages.po b/messages.po index 7d14b239..f477151e 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-09-01 19:54-0400\n" +"POT-Creation-Date: 2018-09-01 20:06-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -264,6 +264,10 @@ msgid "" " it bigger or delete it." msgstr "" +#: lib/elements/fill.py:125 +msgid "shape is not valid. This can happen if the border crosses over itself." +msgstr "" + #: lib/elements/satin_column.py:10 msgid "Satin Column" msgstr "" -- cgit v1.3.1 From 71643ba280d251b6bf7727d5f6841d8cda1a5bca Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sat, 1 Sep 2018 20:09:18 -0400 Subject: make error messages more useful --- lib/elements/element.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/elements') diff --git a/lib/elements/element.py b/lib/elements/element.py index bca743c2..ec50ce22 100644 --- a/lib/elements/element.py +++ b/lib/elements/element.py @@ -270,5 +270,5 @@ class EmbroideryElement(object): def fatal(self, message): # L10N used when showing an error message to the user such as "satin column: One or more of the rungs doesn't # intersect both rails." - print >> sys.stderr, _("error:"), message + print >> sys.stderr, self.node.get("id") + ":", _("error:"), message sys.exit(1) -- cgit v1.3.1