diff options
| author | Lex Neva <github.com@lexneva.name> | 2018-06-22 22:19:57 -0400 |
|---|---|---|
| committer | Lex Neva <github.com@lexneva.name> | 2018-06-22 22:28:51 -0400 |
| commit | 1f4bc62d960ab99c6911ab0a292d6ea52a309813 (patch) | |
| tree | 046b4034f056eeef5bc4f686d602433ac73c49e5 | |
| parent | e29096ee138bd674e96a369a853d75eb7c919823 (diff) | |
add quick access methods for commands
| -rw-r--r-- | lib/elements/element.py | 16 | ||||
| -rw-r--r-- | messages.po | 6 |
2 files changed, 21 insertions, 1 deletions
diff --git a/lib/elements/element.py b/lib/elements/element.py index 465813d4..3c31f1b0 100644 --- a/lib/elements/element.py +++ b/lib/elements/element.py @@ -210,6 +210,22 @@ class EmbroideryElement(object): def commands(self): return find_commands(self.node) + @cache + def get_commands(self, command): + return [c for c in self.commands if c.command == command] + + @cache + def get_command(self, command): + commands = self.get_commands(command) + + if len(commands) == 1: + 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)) + else: + return None + def strip_control_points(self, subpath): return [point for control_before, point, control_after in subpath] diff --git a/messages.po b/messages.po index fb081eb1..e6bfed43 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-06-16 22:33-0400\n" +"POT-Creation-Date: 2018-06-22 22:19-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -47,6 +47,10 @@ msgstr "" msgid "Expand" msgstr "" +#, python-format +msgid "%(id)s has more than one command of type '%(command)s' linked to it" +msgstr "" + msgid "TRIM after" msgstr "" |
