ufoLib: use a single (abstract) base class for sharing methods between UFOReader, UFOWriter and GlyphSet

This commit is contained in:
Cosimo Lupo 2018-10-23 20:41:35 +01:00
parent 0a9e1e56ef
commit 7f3bf46096
No known key found for this signature in database
GPG Key ID: 59D54DB0C9976482
2 changed files with 5 additions and 11 deletions

View File

@ -107,7 +107,7 @@ class UFOFileStructure(enum.Enum):
# --------------
class _ModTimeGetterMixin(object):
class _UFOBaseIO(object):
def _getFileModificationTime(self, path):
"""
@ -123,9 +123,6 @@ class _ModTimeGetterMixin(object):
else:
return datetimeAsTimestamp(dt)
class _PlistReaderMixin(object):
def _getPlist(self, fileName, default=None):
"""
Read a property list relative to the UFO filesystem's root.
@ -153,9 +150,6 @@ class _PlistReaderMixin(object):
"'%s' could not be read on %s: %s" % (fileName, self.fs, e)
)
class _PlistWriterMixin(object):
def _writePlist(self, fileName, obj):
"""
Write a property list to a file relative to the UFO filesystem's root.
@ -198,7 +192,7 @@ class _PlistWriterMixin(object):
# UFO Reader
# ----------
class UFOReader(_PlistReaderMixin, _ModTimeGetterMixin):
class UFOReader(_UFOBaseIO):
"""
Read the various components of the .ufo.
@ -811,7 +805,7 @@ class UFOReader(_PlistReaderMixin, _ModTimeGetterMixin):
# UFO Writer
# ----------
class UFOWriter(_PlistWriterMixin, UFOReader):
class UFOWriter(UFOReader):
"""
Write the various components of the .ufo.

View File

@ -34,7 +34,7 @@ from fontTools.ufoLib.validators import (
glyphLibValidator,
)
from fontTools.misc import etree
from fontTools.ufoLib import _PlistReaderMixin, _PlistWriterMixin, _ModTimeGetterMixin
from fontTools.ufoLib import _UFOBaseIO
from fontTools.ufoLib.utils import integerTypes, numberTypes
@ -89,7 +89,7 @@ class Glyph(object):
# Glyph Set
# ---------
class GlyphSet(_PlistWriterMixin, _PlistReaderMixin, _ModTimeGetterMixin):
class GlyphSet(_UFOBaseIO):
"""
GlyphSet manages a set of .glif files inside one directory.