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 ++++++++-- messages.po | 18 ++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) 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) diff --git a/messages.po b/messages.po index 9105da77..78f0a3b2 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:56-0400\n" +"POT-Creation-Date: 2018-08-24 21:20-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -178,11 +178,25 @@ msgid "" "shapes." msgstr "" -#: lib/elements/element.py:230 +#: lib/elements/element.py:202 +#, python-format +msgid "" +"Object %(id)s has an empty 'd' attribute. Please delete this object from" +" your document." +msgstr "" + +#: lib/elements/element.py:234 #, python-format msgid "%(id)s has more than one command of type '%(command)s' linked to it" msgstr "" +#. used when showing an error message to the user such as "satin column: One or +#. more of the rungs doesn't +#. intersect both rails." +#: lib/elements/element.py:273 +msgid "error:" +msgstr "" + #: lib/elements/fill.py:12 msgid "Fill" msgstr "" -- cgit v1.2.3