Skip to content

Commit

Permalink
tools/clean_svg: do not remove an elem while iterating on a list
Browse files Browse the repository at this point in the history
Doing a simple is undefined:
    for e in ls:
      if e.matches(foo):
        ls.remove(e)

Basically we were skipping the next entry, still leaving some metadata
in the cleaned up svg file.
  • Loading branch information
bentiss committed Oct 16, 2024
1 parent 5dc6699 commit 3fbf841
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/clean_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def round_if_number(value):
def remove_non_svg_nodes_and_strip_namespace(root):
if root.tag.startswith(BRACKETS_NAMESPACE):
root.tag = root.tag[len(BRACKETS_NAMESPACE) :]
for elem in root:
for elem in list(root):
if (
not elem.tag.startswith(BRACKETS_NAMESPACE)
or elem.tag == BRACKETS_NAMESPACE + "metadata"
Expand Down

0 comments on commit 3fbf841

Please sign in to comment.