aboutsummaryrefslogtreecommitdiff
path: root/Lib/fontTools/ufoLib/glifLib.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/fontTools/ufoLib/glifLib.py')
-rwxr-xr-xLib/fontTools/ufoLib/glifLib.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/fontTools/ufoLib/glifLib.py b/Lib/fontTools/ufoLib/glifLib.py
index 385f54bf..3003110e 100755
--- a/Lib/fontTools/ufoLib/glifLib.py
+++ b/Lib/fontTools/ufoLib/glifLib.py
@@ -135,6 +135,7 @@ class GlyphSet(_UFOBaseIO):
ufoFormatVersion=None,
validateRead=True,
validateWrite=True,
+ expectContentsFile=False,
):
"""
'path' should be a path (string) to an existing local directory, or
@@ -148,6 +149,9 @@ class GlyphSet(_UFOBaseIO):
``validateRead`` will validate read operations. Its default is ``True``.
``validateWrite`` will validate write operations. Its default is ``True``.
+ ``expectContentsFile`` will raise a GlifLibError if a contents.plist file is
+ not found on the glyph set file system. This should be set to ``True`` if you
+ are reading an existing UFO and ``False`` if you create a fresh glyph set.
"""
try:
ufoFormatVersion = UFOFormatVersion(ufoFormatVersion)
@@ -191,6 +195,8 @@ class GlyphSet(_UFOBaseIO):
self.fs = filesystem
# if glyphSet contains no 'contents.plist', we consider it empty
self._havePreviousFile = filesystem.exists(CONTENTS_FILENAME)
+ if expectContentsFile and not self._havePreviousFile:
+ raise GlifLibError(f"{CONTENTS_FILENAME} is missing.")
# attribute kept for backward compatibility
self.ufoFormatVersion = ufoFormatVersion.major
self.ufoFormatVersionTuple = ufoFormatVersion