ufoLib: use a single (abstract) base class for sharing methods between UFOReader, UFOWriter and GlyphSet
This commit is contained in:
parent
0a9e1e56ef
commit
7f3bf46096
@ -107,7 +107,7 @@ class UFOFileStructure(enum.Enum):
|
|||||||
# --------------
|
# --------------
|
||||||
|
|
||||||
|
|
||||||
class _ModTimeGetterMixin(object):
|
class _UFOBaseIO(object):
|
||||||
|
|
||||||
def _getFileModificationTime(self, path):
|
def _getFileModificationTime(self, path):
|
||||||
"""
|
"""
|
||||||
@ -123,9 +123,6 @@ class _ModTimeGetterMixin(object):
|
|||||||
else:
|
else:
|
||||||
return datetimeAsTimestamp(dt)
|
return datetimeAsTimestamp(dt)
|
||||||
|
|
||||||
|
|
||||||
class _PlistReaderMixin(object):
|
|
||||||
|
|
||||||
def _getPlist(self, fileName, default=None):
|
def _getPlist(self, fileName, default=None):
|
||||||
"""
|
"""
|
||||||
Read a property list relative to the UFO filesystem's root.
|
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)
|
"'%s' could not be read on %s: %s" % (fileName, self.fs, e)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class _PlistWriterMixin(object):
|
|
||||||
|
|
||||||
def _writePlist(self, fileName, obj):
|
def _writePlist(self, fileName, obj):
|
||||||
"""
|
"""
|
||||||
Write a property list to a file relative to the UFO filesystem's root.
|
Write a property list to a file relative to the UFO filesystem's root.
|
||||||
@ -198,7 +192,7 @@ class _PlistWriterMixin(object):
|
|||||||
# UFO Reader
|
# UFO Reader
|
||||||
# ----------
|
# ----------
|
||||||
|
|
||||||
class UFOReader(_PlistReaderMixin, _ModTimeGetterMixin):
|
class UFOReader(_UFOBaseIO):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Read the various components of the .ufo.
|
Read the various components of the .ufo.
|
||||||
@ -811,7 +805,7 @@ class UFOReader(_PlistReaderMixin, _ModTimeGetterMixin):
|
|||||||
# UFO Writer
|
# UFO Writer
|
||||||
# ----------
|
# ----------
|
||||||
|
|
||||||
class UFOWriter(_PlistWriterMixin, UFOReader):
|
class UFOWriter(UFOReader):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Write the various components of the .ufo.
|
Write the various components of the .ufo.
|
||||||
|
@ -34,7 +34,7 @@ from fontTools.ufoLib.validators import (
|
|||||||
glyphLibValidator,
|
glyphLibValidator,
|
||||||
)
|
)
|
||||||
from fontTools.misc import etree
|
from fontTools.misc import etree
|
||||||
from fontTools.ufoLib import _PlistReaderMixin, _PlistWriterMixin, _ModTimeGetterMixin
|
from fontTools.ufoLib import _UFOBaseIO
|
||||||
from fontTools.ufoLib.utils import integerTypes, numberTypes
|
from fontTools.ufoLib.utils import integerTypes, numberTypes
|
||||||
|
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ class Glyph(object):
|
|||||||
# Glyph Set
|
# Glyph Set
|
||||||
# ---------
|
# ---------
|
||||||
|
|
||||||
class GlyphSet(_PlistWriterMixin, _PlistReaderMixin, _ModTimeGetterMixin):
|
class GlyphSet(_UFOBaseIO):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
GlyphSet manages a set of .glif files inside one directory.
|
GlyphSet manages a set of .glif files inside one directory.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user