Skip to content

Commit

Permalink
image: always set default (1,0,0,1,0,0) transform
Browse files Browse the repository at this point in the history
it's never None in defcon.Image
  • Loading branch information
anthrotype committed May 23, 2018
1 parent 2c2725a commit 60cd1fa
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/ufoLib2/objects/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
from ufoLib2.objects.misc import Transformation


def _to_optional_transformation(v):
if v is not None and not isinstance(v, Transformation):
def _to_transformation(v):
if not isinstance(v, Transformation):
return Transformation(*v)
return v


@attr.s(slots=True)
class Image(object):
fileName = attr.ib(default=None, type=Optional[str])
_transformation = attr.ib(
default=None,
convert=_to_optional_transformation,
type=Optional[Transformation],
default=Transformation(),
convert=_to_transformation,
type=Transformation,
)
color = attr.ib(default=None, type=Optional[str])

Expand All @@ -24,7 +25,7 @@ def transformation(self):

@transformation.setter
def transformation(self, value):
self._transformation = _to_optional_transformation(value)
self._transformation = _to_transformation(value)

def clear(self):
self.fileName = None
Expand Down

0 comments on commit 60cd1fa

Please sign in to comment.