fs.wrap¶
Collection of useful WrapFS subclasses.
Here’s an example that opens a filesystem then makes it read only:
>>> from fs import open_fs
>>> from fs.wrap import read_only
>>> projects_fs = open_fs('~/projects')
>>> read_only_projects_fs = read_only(projects_fs)
>>> read_only_projects_fs.remove('__init__.py')
Traceback (most recent call last):
...
fs.errors.ResourceReadOnly: resource '__init__.py' is read only
-
class
fs.wrap.WrapCachedDir(wrap_fs)[source]¶ Caches filesystem directory information.
This filesystem caches directory information retrieved from a scandir call. This may speed up code that calls
isdir,isfile, orgettypetoo frequently.Note
Using this wrap will prevent changes to directory information being visible to the filesystem object. Consequently it is best used only in a fairly limited scope where you don’t expected anything on the filesystem to change.
-
class
fs.wrap.WrapReadOnly(wrap_fs)[source]¶ Makes a Filesystem read-only.
Any call that would would write data or modify the filesystem in any way will raise a
ResourceReadOnlyexception.