summaryrefslogtreecommitdiff
path: root/lib/elements/element.py
diff options
context:
space:
mode:
authorLex Neva <github.com@lexneva.name>2018-06-04 20:19:37 -0400
committerLex Neva <github.com@lexneva.name>2018-06-04 20:19:37 -0400
commit692e033e71ed4655cef93be44c762bacf39caaee (patch)
treee24119a0174a093780f0ce7fc82a4e7c5f36bd54 /lib/elements/element.py
parentd53f2ecaf926828526304248d4508afc416b1296 (diff)
don't crash on empty subpaths
Diffstat (limited to 'lib/elements/element.py')
-rw-r--r--lib/elements/element.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/elements/element.py b/lib/elements/element.py
index 300136dd..42f6c470 100644
--- a/lib/elements/element.py
+++ b/lib/elements/element.py
@@ -29,6 +29,10 @@ class Patch:
else:
raise TypeError("Patch can only be added to another Patch")
+ def __len__(self):
+ # This method allows `len(patch)` and `if patch:
+ return len(self.stitches)
+
def add_stitch(self, stitch):
self.stitches.append(stitch)
@@ -36,7 +40,6 @@ class Patch:
return Patch(self.color, self.stitches[::-1])
-
class Param(object):
def __init__(self, name, description, unit=None, values=[], type=None, group=None, inverse=False, default=None, tooltip=None, sort_index=0):
self.name = name