From f47fee933cc65ab135bae87d2369f7472d87e342 Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler Date: Tue, 15 Jan 2019 09:49:24 +0000 Subject: [PATCH] ufoLib, fs calls: Replace deprecated getbytes with readbytes (#1445) fs 2.2.0 comes with some renamed APIs. --- Lib/fontTools/ufoLib/__init__.py | 10 +++++----- Lib/fontTools/ufoLib/glifLib.py | 4 ++-- requirements.txt | 2 +- setup.py | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Lib/fontTools/ufoLib/__init__.py b/Lib/fontTools/ufoLib/__init__.py index d9a57c5d5..70ec6f8a8 100755 --- a/Lib/fontTools/ufoLib/__init__.py +++ b/Lib/fontTools/ufoLib/__init__.py @@ -173,7 +173,7 @@ class _UFOBaseIO(object): "the data is not properly formatted: %s" % (fileName, self.fs, e) ) - if self.fs.exists(fileName) and data == self.fs.getbytes(fileName): + if self.fs.exists(fileName) and data == self.fs.readbytes(fileName): return self.fs.setbytes(fileName, data) else: @@ -356,7 +356,7 @@ class UFOReader(_UFOBaseIO): Returns None if the file does not exist. """ try: - return self.fs.getbytes(fsdecode(path)) + return self.fs.readbytes(fsdecode(path)) except fs.errors.ResourceNotFound: return None @@ -758,7 +758,7 @@ class UFOReader(_UFOBaseIO): except AttributeError: # in case readData is called before getDataDirectoryListing dataFS = self.fs.opendir(DATA_DIRNAME) - data = dataFS.getbytes(fileName) + data = dataFS.readbytes(fileName) except fs.errors.ResourceNotFound: raise UFOLibError("No data file named '%s' on %s" % (fileName, self.fs)) return data @@ -781,7 +781,7 @@ class UFOReader(_UFOBaseIO): except AttributeError: # in case readImage is called before getImageDirectoryListing imagesFS = self.fs.opendir(IMAGES_DIRNAME) - data = imagesFS.getbytes(fileName) + data = imagesFS.readbytes(fileName) except fs.errors.ResourceNotFound: raise UFOLibError("No image file named '%s' on %s" % (fileName, self.fs)) if validate: @@ -1006,7 +1006,7 @@ class UFOWriter(UFOReader): """ path = fsdecode(path) if self._havePreviousFile: - if self.fs.isfile(path) and data == self.fs.getbytes(path): + if self.fs.isfile(path) and data == self.fs.readbytes(path): return try: self.fs.setbytes(path, data) diff --git a/Lib/fontTools/ufoLib/glifLib.py b/Lib/fontTools/ufoLib/glifLib.py index f2648b8c3..1f7aaf435 100755 --- a/Lib/fontTools/ufoLib/glifLib.py +++ b/Lib/fontTools/ufoLib/glifLib.py @@ -290,7 +290,7 @@ class GlyphSet(_UFOBaseIO): """ fileName = self.contents[glyphName] try: - return self.fs.getbytes(fileName) + return self.fs.readbytes(fileName) except fs.errors.ResourceNotFound: raise GlifLibError( "The file '%s' associated with glyph '%s' in contents.plist " @@ -420,7 +420,7 @@ class GlyphSet(_UFOBaseIO): if ( self._havePreviousFile and self.fs.exists(fileName) - and data == self.fs.getbytes(fileName) + and data == self.fs.readbytes(fileName) ): return self.fs.setbytes(fileName, data) diff --git a/requirements.txt b/requirements.txt index c9ac4f39b..b910fea7d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,4 @@ unicodedata2==11.0.0; python_version < '3.7' and platform_python_implementation scipy==1.2.0; platform_python_implementation != "PyPy" munkres==1.0.12; platform_python_implementation == "PyPy" zopfli==0.1.6 -fs==2.1.3 +fs==2.2.1 diff --git a/setup.py b/setup.py index 2612e0b35..ec9ffd0dc 100755 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ bumpversion = ['bump2version'] if needs_bumpversion else [] extras_require = { # for fontTools.ufoLib: to read/write UFO fonts "ufo": [ - "fs >= 2.1.1, < 3", + "fs >= 2.2.0, < 3", "enum34 >= 1.1.6; python_version < '3.4'", ], # for fontTools.misc.etree and fontTools.misc.plistlib: use lxml to