fs.wrapfs.readonlyfs

An FS wrapper class for blocking operations that would modify the FS.

class fs.wrapfs.readonlyfs.ReadOnlyFS(fs)

Makes a FS object read only. Any operation that could potentially modify the underlying file system will throw an UnsupportedError

Note that this isn’t a secure sandbox, untrusted code could work around the read-only restrictions by getting the base class. Its main purpose is to provide a degree of safety if you want to protect an FS object from accidental modification.

copy(*args, **kwargs)

Replacement method for methods that can modify the file system

copydir(*args, **kwargs)

Replacement method for methods that can modify the file system

createfile(*args, **kwargs)

Replacement method for methods that can modify the file system

delxattr(*args, **kwargs)

Replacement method for methods that can modify the file system

getsyspath(path, allow_none=False)

Doesn’t technically modify the filesystem but could be used to work around read-only restrictions.

makedir(*args, **kwargs)

Replacement method for methods that can modify the file system

move(*args, **kwargs)

Replacement method for methods that can modify the file system

movedir(*args, **kwargs)

Replacement method for methods that can modify the file system

open(path, mode='r', buffering=-1, encoding=None, errors=None, newline=None, line_buffering=False, **kwargs)

Only permit read access

remove(*args, **kwargs)

Replacement method for methods that can modify the file system

removedir(*args, **kwargs)

Replacement method for methods that can modify the file system

rename(*args, **kwargs)

Replacement method for methods that can modify the file system

setcontents(*args, **kwargs)

Replacement method for methods that can modify the file system

settimes(*args, **kwargs)

Replacement method for methods that can modify the file system

setxattr(*args, **kwargs)

Replacement method for methods that can modify the file system