summaryrefslogtreecommitdiff
path: root/lib/elements
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2020-04-25 14:45:27 +0200
committerGitHub <noreply@github.com>2020-04-25 14:45:27 +0200
commit319905087661bc44a560afff6c574b6545d21115 (patch)
tree249f7c5ff6f023df1a1bdd3933b7bc0377232658 /lib/elements
parent1d3b89111e627b3662a7ec2749bb3dcfe694be66 (diff)
Namespaced Attributes (#657)
Diffstat (limited to 'lib/elements')
-rw-r--r--lib/elements/auto_fill.py4
-rw-r--r--lib/elements/element.py24
2 files changed, 21 insertions, 7 deletions
diff --git a/lib/elements/auto_fill.py b/lib/elements/auto_fill.py
index 04da3288..b574c8bf 100644
--- a/lib/elements/auto_fill.py
+++ b/lib/elements/auto_fill.py
@@ -53,9 +53,9 @@ class AutoFill(Fill):
return max(self.get_float_param("running_stitch_length_mm", 1.5), 0.01)
@property
- @param('fill_underlay', _('Underlay'), type='toggle', group=_('AutoFill Underlay'), default=False)
+ @param('fill_underlay', _('Underlay'), type='toggle', group=_('AutoFill Underlay'), default=True)
def fill_underlay(self):
- return self.get_boolean_param("fill_underlay", default=False)
+ return self.get_boolean_param("fill_underlay", default=True)
@property
@param('fill_underlay_angle',
diff --git a/lib/elements/element.py b/lib/elements/element.py
index f39280fc..83e3978f 100644
--- a/lib/elements/element.py
+++ b/lib/elements/element.py
@@ -8,7 +8,7 @@ from cspsubdiv import cspsubdiv
from ..commands import find_commands
from ..i18n import _
from ..svg import PIXELS_PER_MM, apply_transforms, convert_length, get_doc_size
-from ..svg.tags import INKSCAPE_LABEL
+from ..svg.tags import INKSCAPE_LABEL, INKSTITCH_ATTRIBS
from ..utils import cache
@@ -72,6 +72,16 @@ class EmbroideryElement(object):
def __init__(self, node):
self.node = node
+ legacy_attribs = False
+ for attrib in self.node.attrib:
+ if attrib.startswith('embroider_'):
+ # update embroider_ attributes to namespaced attributes
+ self.replace_legacy_param(attrib)
+ legacy_attribs = True
+ if legacy_attribs and not self.get_param('fill_underlay', ""):
+ # defaut setting for fill_underlay has changed
+ self.set_param('fill_underlay', False)
+
@property
def id(self):
return self.node.get('id')
@@ -85,13 +95,16 @@ class EmbroideryElement(object):
# The 'param' attribute is set by the 'param' decorator defined above.
if hasattr(prop.fget, 'param'):
params.append(prop.fget.param)
-
return params
+ def replace_legacy_param(self, param):
+ value = self.node.get(param, "").strip()
+ self.set_param(param[10:], value)
+ del self.node.attrib[param]
+
@cache
def get_param(self, param, default):
- value = self.node.get("embroider_" + param, "").strip()
-
+ value = self.node.get(INKSTITCH_ATTRIBS[param], "").strip()
return value or default
@cache
@@ -131,7 +144,8 @@ class EmbroideryElement(object):
return value
def set_param(self, name, value):
- self.node.set("embroider_%s" % name, str(value))
+ param = INKSTITCH_ATTRIBS[name]
+ self.node.set(param, str(value))
@property
@cache