diff options
| author | Lex Neva <lexelby@users.noreply.github.com> | 2019-08-11 16:26:54 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-11 16:26:54 -0400 |
| commit | b05cc4a031fb4dace2eded97a3e44e86e2f79fe8 (patch) | |
| tree | 3c2e1490a2b4a38e0c0b02682b76c0b50de2e383 /lib/stitch_plan/stitch_plan.py | |
| parent | 077f7ea72ba38790bf030d3181c44787fef953b6 (diff) | |
| parent | dafc3b97822ac0e929655bfa73590209e3350c47 (diff) | |
Merge pull request #509 from inkstitch/lexelby/input-fixes
input: read STOP commands too
Diffstat (limited to 'lib/stitch_plan/stitch_plan.py')
| -rw-r--r-- | lib/stitch_plan/stitch_plan.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/stitch_plan/stitch_plan.py b/lib/stitch_plan/stitch_plan.py index b621ef07..ac6b3b8d 100644 --- a/lib/stitch_plan/stitch_plan.py +++ b/lib/stitch_plan/stitch_plan.py @@ -169,6 +169,12 @@ class ColorBlock(object): def __repr__(self): return "ColorBlock(%s, %s)" % (self.color, self.stitches) + def __getitem__(self, item): + return self.stitches[item] + + def __delitem__(self, item): + del self.stitches[item] + def has_color(self): return self._color is not None @@ -210,6 +216,20 @@ class ColorBlock(object): else: return False + @property + def trim_after(self): + # If there's a STOP, it will be at the end. We still want to return + # True. + for stitch in reversed(self.stitches): + if stitch.stop or stitch.jump: + continue + elif stitch.trim: + return True + else: + break + + return False + def filter_duplicate_stitches(self): if not self.stitches: return |
