Contains MountFS class which is a virtual filesystem which can have other filesystems linked as branched directories.

For example, lets say we have two filesystems containing config files and resources respectively:

|-- config.cfg
`-- defaults.cfg

|-- images
|   |-- logo.jpg
|   `-- photo.jpg
`-- data.dat

We can combine these filesystems in to a single filesystem with the following code:

from fs.mountfs import MountFS
combined_fs = MountFS()
combined_fs.mountdir('config', config_fs)
combined_fs.mountdir('resources', resources_fs)

This will create a single filesystem where paths under config map to config_fs, and paths under resources map to resources_fs:

|-- config
|   |-- config.cfg
|   `-- defaults.cfg
`-- resources
    |-- images
    |   |-- logo.jpg
    |   `-- photo.jpg
    `-- data.dat

Now both filesystems can be accessed with the same path structure:

print combined_fs.getcontents('/config/defaults.cfg')
MountFS.mountdir(self, path, fs)

Mounts a host FS object on a given path.

  • path – A path within the MountFS
  • fs – A filesystem object to mount
MountFS.mountfile(self, path, open_callable=None, info_callable=None)

Mounts a single file path.

  • path – A path within the MountFS
  • open_callable – A callable that returns a file-like object, open_callable should have the same signature as open()
  • info_callable – A callable that returns a dictionary with information regarding the file-like object, info_callable should have the same signagture as getinfo()

Unmounts a path.

Parameters:path – Path to unmount
Returns:True if a path was unmounted, False if the path was already unmounted
Return type:bool