summaryrefslogtreecommitdiff
path: root/lib/tartan/svg.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tartan/svg.py')
-rw-r--r--lib/tartan/svg.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/tartan/svg.py b/lib/tartan/svg.py
index 497d0199..62d737c9 100644
--- a/lib/tartan/svg.py
+++ b/lib/tartan/svg.py
@@ -7,7 +7,7 @@ import time
from collections import defaultdict
from copy import copy
from itertools import chain
-from typing import List, Optional, Tuple
+from typing import List, Optional, Tuple, cast
from inkex import BaseElement, Group, Path, PathElement
from networkx import MultiGraph, is_empty
@@ -66,12 +66,12 @@ class TartanSvgGroup:
:param outline: the outline to be filled with the tartan pattern
"""
parent_group = outline.getparent()
- if parent_group.get_id().startswith('inkstitch-tartan'):
+ if parent_group is not None and parent_group.get_id().startswith('inkstitch-tartan'):
# remove everything but the tartan outline
for child in parent_group.iterchildren():
if child != outline:
parent_group.remove(child)
- group = parent_group
+ group = cast(Group, parent_group)
else:
group = Group()
group.set('id', f'inkstitch-tartan-{int(time.time())}')
@@ -86,6 +86,7 @@ class TartanSvgGroup:
# set outline invisible
outline.style['display'] = 'none'
group.append(outline)
+ return group
def _generate_tartan_group_elements(self, group, outline_shape, transform):
dimensions, rotation_center = self._get_dimensions(outline_shape)