drawpyo
drawpyo copied to clipboard
Bug with reading set dashPattern?
Maybe I'm misunderstanding how dashed and dashPattern work due to their interaction with line_pattern, but from looking at the code it looks like when reading dashPattern directly it can incorrectly return self._dashed instead?
Example showing issue:
import drawpyo
file = drawpyo.File()
page = drawpyo.Page(file=file)
rect = drawpyo.diagram.object_from_library(
library="general",
obj_name="rectangle",
page=page,
)
rect.apply_style_string(
"rounded=0;whiteSpace=wrap;html=1;fillColor=none;dashed=1;dashPattern=8 8;"
)
assert rect.dashed == 1, rect.dashed
assert rect.dashPattern == '8 8', rect.dashPattern
@dashed.setter
def dashed(self, value):
self._line_pattern = None
self._dashed = value
@property
def dashPattern(self):
"""This is one of the properties that defines the line style. Along with dashed, it can be overriden by setting line_pattern or set directly.
Returns:
str: What style the object stroke is dashed with.
"""
if self._line_pattern is None:
return self._dashed
else:
return line_styles[self._line_pattern]
@dashPattern.setter
def dashPattern(self, value):
self._line_pattern = None
self._dashPattern = value
This seems to be the part of the code you are talking about. Correct?
I agree that there is some confusion of dashPattern and dashed here. Have you tried to return dashePattern here instead? I am not sure if line_pattern should play a role in the @property function.
Can you help to clarify? @MerrimanInd