summaryrefslogtreecommitdiff
path: root/lib/svg
diff options
context:
space:
mode:
Diffstat (limited to 'lib/svg')
-rw-r--r--lib/svg/rendering.py2
-rw-r--r--lib/svg/svg.py11
2 files changed, 3 insertions, 10 deletions
diff --git a/lib/svg/rendering.py b/lib/svg/rendering.py
index 1f74e2df..b96fe9b7 100644
--- a/lib/svg/rendering.py
+++ b/lib/svg/rendering.py
@@ -222,7 +222,7 @@ def color_block_to_paths(color_block, svg, destination, visual_commands):
def render_stitch_plan(svg, stitch_plan, realistic=False, visual_commands=True):
- layer = svg.find(".//*[@id='__inkstitch_stitch_plan__']")
+ layer = svg.findone(".//*[@id='__inkstitch_stitch_plan__']")
if layer is None:
layer = inkex.Group(attrib={
'id': '__inkstitch_stitch_plan__',
diff --git a/lib/svg/svg.py b/lib/svg/svg.py
index 3bd9a693..2c521098 100644
--- a/lib/svg/svg.py
+++ b/lib/svg/svg.py
@@ -14,20 +14,13 @@ def get_document(node):
return node.getroottree().getroot()
-def generate_unique_id(document_or_element, prefix="path"):
+def generate_unique_id(document_or_element, prefix="path", blocklist=None):
if isinstance(document_or_element, etree._ElementTree):
document = document_or_element.getroot()
else:
document = get_document(document_or_element)
- doc_ids = {node.get('id') for node in document.iterdescendants() if 'id' in node.attrib}
-
- i = 1
- while True:
- new_id = "%s%d" % (prefix, i)
- if new_id not in doc_ids:
- break
- i += 1
+ new_id = document.get_unique_id(prefix, blacklist=blocklist)
return new_id