fix parse style (#667)

pull/531/head
Kaalleen 2020-04-25 14:22:17 +02:00 zatwierdzone przez GitHub
rodzic dce3ffa68f
commit 3b2c7ba1a9
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 19 dodań i 13 usunięć

Wyświetl plik

@ -2,7 +2,7 @@ import sys
from copy import deepcopy
import cubicsuperpath
import simplestyle
import tinycss2
from cspsubdiv import cspsubdiv
from ..commands import find_commands
@ -133,20 +133,25 @@ class EmbroideryElement(object):
def set_param(self, name, value):
self.node.set("embroider_%s" % name, str(value))
@property
@cache
def get_style(self, style_name, default=None):
style = simplestyle.parseStyle(self.node.get("style"))
if (style_name not in style):
return default
value = style[style_name]
if value == 'none':
return None
return value
def style(self):
declarations = tinycss2.parse_declaration_list(self.node.get("style", ""))
style = {declaration.lower_name: declaration.value[0].serialize() for declaration in declarations}
return style
def get_style(self, style_name, default=None):
style = self.style.get(style_name)
# Style not found, let's see if it is set as a separate attribute
if style is None:
style = self.node.get(style_name, default)
if style == 'none':
style = None
return style
@cache
def has_style(self, style_name):
style = simplestyle.parseStyle(self.node.get("style"))
return style_name in style
return style_name in self.style
@property
@cache
@ -160,7 +165,7 @@ class EmbroideryElement(object):
@property
@cache
def stroke_width(self):
width = self.get_style("stroke-width", "1")
width = self.get_style("stroke-width", None)
if width is None:
return 1.0

Wyświetl plik

@ -10,6 +10,7 @@ jinja2>2.9
requests
colormath
stringcase
tinycss2
# We're not ready for flask 1.0 yet. Logging changed, among othe things.
flask==0.*