def readBytesFromPath(self, path, encoding=None):
"""
Returns the bytes in the file at the given path.
The path must be relative to the UFO path.
Returns None if the file does not exist.
An encoding may be passed if needed.
"""
fullPath = os.path.join(self._path, path)
if not self._checkForFile(fullPath):
return None
if os.path.isdir(fullPath):
raise UFOLibError("%s is a directory." % path)
if encoding:
f = open(fullPath, encoding=encoding)
else:
f = open(fullPath, "rb", encoding=encoding)
data = f.read()
f.close()
return data
评论列表
文章目录