diff options
author | willmcgugan <willmcgugan@67cdc799-7952-0410-af00-57a81ceafa0f> | 2010-01-02 21:17:58 +0000 |
---|---|---|
committer | willmcgugan <willmcgugan@67cdc799-7952-0410-af00-57a81ceafa0f> | 2010-01-02 21:17:58 +0000 |
commit | f02e1aeb4104cdf05628c7777c1879b4258be3f9 (patch) | |
tree | 9e64d9e738c99b9fe3a6ded1ce706a4d0d0e1b92 /fs/multifs.py | |
parent | b7dbf13f40bf766fc19ce43d7861b98ca9edbcda (diff) | |
download | pyfilesystem-f02e1aeb4104cdf05628c7777c1879b4258be3f9.tar.gz |
More documentation
git-svn-id: http://pyfilesystem.googlecode.com/svn/trunk@311 67cdc799-7952-0410-af00-57a81ceafa0f
Diffstat (limited to 'fs/multifs.py')
-rw-r--r-- | fs/multifs.py | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/fs/multifs.py b/fs/multifs.py index 6abc28d..110e6d5 100644 --- a/fs/multifs.py +++ b/fs/multifs.py @@ -1,9 +1,30 @@ """ fs.multifs ========== + +A MultiFS is a filesytem composed of a sequence of other filesystems, where +the directory structure of each filesystem is overlaid over the previous filesystem. +When you attempt to access a file from the MultiFS it will try each 'child' +FS in order, until it either finds a path that exists or raises a ResourceNotFoundError. + +One use for such a filesystem would be to selectively override a set of files, +to customize behaviour. For example, to create a filesystem that could be used +to *theme* a web application:: + + from fs.osfs import OSFS + from fs.multifs import MultiFS + + themed_template_fs.addfs('templates', OSFS('templates')) + themed_template_fs.addfs('theme', OSFS('themes')) + + index_template = themed_template_fs.getcontent('index.html') + +This will read the contents of *themes/index.html*, if it exists, otherwise +it will look for it in *templates/index.html*. + """ -from fs.base import FS, FSError +from fs.base import FS, FSError, synchronize from fs.path import * from fs import _thread_syncronize_default @@ -66,7 +87,7 @@ class MultiFS(FS): @synchronize def __iter__(self): - return iter(self.fs_sequence[:]) + return reversed(self.fs_sequence[:]) def _delegate_search(self, path): for fs in self: @@ -107,7 +128,7 @@ class MultiFS(FS): return "%s, on %s (%s)" % (fs.desc(path), name, fs) @synchronize - def open(self, path, mode="r",**kwargs): + def open(self, path, mode="r", **kwargs): for fs in self: if fs.exists(path): fs_file = fs.open(path, mode, **kwargs) |