Skip to content

Commit

Permalink
Make tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
madig committed Oct 7, 2021
1 parent 71a968f commit b47daca
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions Lib/glyphsLib/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1866,8 +1866,8 @@ def __init__(
self, position=(0, 0), type=LINE, smooth=False, name=None, nodetype=None
):
self._position = Point(position[0], position[1])
if smooth:
self.smooth = smooth
self._userData = None
self.smooth = smooth
self.type = type
if nodetype is not None: # for backward compatibility
self.type = nodetype
Expand Down Expand Up @@ -1937,8 +1937,9 @@ def plistValue(self, format_version=2):
floatToString5(self.position[1]),
content,
)

@classmethod
def read(self, line):
def read(cls, line):
"""Parse a Glyphs node string into a GSNode.
The format of a Glyphs node string (`line`) is:
Expand All @@ -1953,17 +1954,21 @@ def read(self, line):
WARNING: This method is HOT. It is called for every single node and can
account for a significant portion of the file parsing time.
"""
m = self._PLIST_VALUE_RE.match(line).groups()
node = GSNode(position=(parse_float_or_int(m[0]), parse_float_or_int(m[1])), type=m[2].lower(), smooth=bool(m[3]))
m = cls._PLIST_VALUE_RE.match(line).groups()
node = cls(
position=(parse_float_or_int(m[0]), parse_float_or_int(m[1])),
type=m[2].lower(),
smooth=bool(m[3]),
)
if m[4] is not None and len(m[4]) > 0:
value = self._decode_dict_as_string(m[4])
value = cls._decode_dict_as_string(m[4])
parser = Parser()
node._userData = parser.parse(value)

return node

@classmethod
def read_v3(self, lst):
def read_v3(cls, lst):
position = (lst[0], lst[1])
smooth = lst[2].endswith("s")
if lst[2][0] == "c":
Expand All @@ -1974,7 +1979,7 @@ def read_v3(self, lst):
node_type = LINE
elif lst[2][0] == "q":
node_type = QCURVE
node = GSNode(position=position, type=node_type, smooth=smooth)
node = cls(position=position, type=node_type, smooth=smooth)
if len(lst) > 3:
node._userData = lst[3]
return node
Expand Down Expand Up @@ -4502,7 +4507,10 @@ def _get_custom_parameter_from_axes(self):
if ax.hidden:
value["Hidden"] = 1
values.append(value)
return GSCustomParameter(name="Axes", value=values,)
return GSCustomParameter(
name="Axes",
value=values,
)

def _set_axes_from_custom_parameter(self, value):
self.axes = [
Expand Down

0 comments on commit b47daca

Please sign in to comment.