def fake_open(filename, flags, mode=0777, _os_open=os.open):
  # A copy of os.open is saved in _os_open so it can still be used after os.open
  # is replaced with this stub.
  if flags & (os.O_RDWR | os.O_CREAT | os.O_WRONLY):
    raise OSError(errno.EROFS, 'Read-only file system', filename)
  elif not FakeFile.is_file_accessible(filename):
    raise OSError(errno.ENOENT, 'No such file or directory', filename)
  return _os_open(filename, flags, mode)
Fake version of os.open.
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/tools/devappserver2/python/stubs.py/fake_open