def getReadFileForPath(self, path, encoding=None):
"""
Returns a file (or file-like) object for 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.
Note: The caller is responsible for closing the open file.
"""
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, "rb", encoding=encoding)
else:
f = open(fullPath, "r")
return f
评论列表
文章目录