diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2025-03-25 06:15:33 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-25 07:15:33 +0100 |
| commit | c1759232b42c8926c080006223c382e20b9b2470 (patch) | |
| tree | aed2cd8582cb43154619e11949d63b5c84f0dcf8 | |
| parent | 23dcbd58bc8f26a71b0483ed907c0052ca348899 (diff) | |
Read sew stack debug information once and re-use (#3604)
| -rw-r--r-- | lib/debug/debug.py | 5 | ||||
| -rw-r--r-- | lib/elements/utils.py | 5 | ||||
| -rw-r--r-- | tests/utils.py | 5 |
3 files changed, 9 insertions, 6 deletions
diff --git a/lib/debug/debug.py b/lib/debug/debug.py index d96dd36d..83e001eb 100644 --- a/lib/debug/debug.py +++ b/lib/debug/debug.py @@ -17,12 +17,17 @@ from lxml import etree # to create svg file from ..svg import line_strings_to_path from ..svg.tags import INKSCAPE_GROUPMODE, INKSCAPE_LABEL +from .utils import safe_get +from ..utils.paths import get_ini + import logging logger = logging.getLogger("inkstitch.debug") # create module logger with name 'inkstitch.debug' # to log messages if previous debug logger is not enabled logger_inkstich = logging.getLogger("inkstitch") # create module logger with name 'inkstitch' +sew_stack_enabled = safe_get(get_ini(), "DEBUG", "enable_sew_stack", default=False) + # -------------------------------------------------------------------------------------------- # decorator to check if debugging is enabled diff --git a/lib/elements/utils.py b/lib/elements/utils.py index cf770af4..6aec1cc2 100644 --- a/lib/elements/utils.py +++ b/lib/elements/utils.py @@ -9,13 +9,12 @@ from inkex import BaseElement from lxml.etree import Comment from ..commands import is_command, layer_commands -from ..debug.utils import safe_get +from ..debug.debug import sew_stack_enabled from ..marker import has_marker from ..svg.tags import (CONNECTOR_TYPE, EMBROIDERABLE_TAGS, INKSCAPE_GROUPMODE, NOT_EMBROIDERABLE_TAGS, SVG_CLIPPATH_TAG, SVG_DEFS_TAG, SVG_GROUP_TAG, SVG_IMAGE_TAG, SVG_MASK_TAG, SVG_TEXT_TAG) -from ..utils.paths import get_ini from .clone import Clone, is_clone from .element import EmbroideryElement from .empty_d_object import EmptyDObject @@ -58,7 +57,7 @@ def node_to_elements(node, clone_to_element=False) -> List[EmbroideryElement]: if element.get_boolean_param("stroke_first", False): elements.reverse() - if safe_get(get_ini(), "DEBUG", "sew_stack_enable", default=False): + if sew_stack_enabled: elements.append(sew_stack) return elements diff --git a/tests/utils.py b/tests/utils.py index 3e771628..cfcaa29a 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,9 +1,8 @@ -from lib.debug.utils import safe_get -from lib.utils.paths import get_ini +from lib.debug.debug import sew_stack_enabled def element_count(): element_count = 1 - if safe_get(get_ini(), "DEBUG", "sew_stack_enable", default=False): + if sew_stack_enabled: element_count = 2 return element_count |
