improve error message for files with too many color changes ()

pull/2994/head dev-build-capellan-fix-filter-whitespace
Kaalleen 2024-06-12 12:25:52 +02:00 zatwierdzone przez GitHub
rodzic 45a3eb49b1
commit 39d9defef4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
2 zmienionych plików z 15 dodań i 1 usunięć

Wyświetl plik

@ -4,9 +4,12 @@
# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
import os
import re
import sys
import inkex
from pyembroidery.exceptions import TooManyColorChangesError
import pyembroidery
from .commands import global_command
@ -113,3 +116,14 @@ def write_embroidery_file(file_path, stitch_plan, svg, settings={}):
msg = _("Error writing to %(path)s: %(error)s") % dict(path=file_path, error=e.strerror)
inkex.errormsg(msg)
sys.exit(1)
except TooManyColorChangesError as e:
num_color_changes = re.search("d+", str(e)).group()
msg = _("Couldn't save embrodiery file.")
msg += '\n\n'
msg += _("There are {num_color_changes} in your design. This is way too many.").format(num_color_changes=num_color_changes)
msg += '\n'
msg += _("Please reduce color changes. Find more information on our website:")
msg += '\n\n'
msg += _("http://inkstitch.org/docs/faq/#too-many-color-changes")
inkex.errormsg(msg)
sys.exit(1)

@ -1 +1 @@
Subproject commit b24efddbda3775bf6750e1aab0abbaf1e0a05276
Subproject commit 4990269d02d88b7bb75f26ee7ed1935e66ccb97e