diff options
author | willmcgugan <willmcgugan@67cdc799-7952-0410-af00-57a81ceafa0f> | 2010-06-18 18:53:33 +0000 |
---|---|---|
committer | willmcgugan <willmcgugan@67cdc799-7952-0410-af00-57a81ceafa0f> | 2010-06-18 18:53:33 +0000 |
commit | 75fe116f57cfc20922ef0cb4d33a3e423189edb0 (patch) | |
tree | 610dd8ac9a9f0453a59c0652c5d5dca59617b0c7 /fs/multifs.py | |
parent | 4ded92bcaea1500a89678272769837f084b3200d (diff) | |
download | pyfilesystem-git-75fe116f57cfc20922ef0cb4d33a3e423189edb0.tar.gz |
Mostly doc changes, and some pedantic pep-8 tweaks
Diffstat (limited to 'fs/multifs.py')
-rw-r--r-- | fs/multifs.py | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/fs/multifs.py b/fs/multifs.py index e1b751d..85c203f 100644 --- a/fs/multifs.py +++ b/fs/multifs.py @@ -9,18 +9,46 @@ FS in order, until it either finds a path that exists or raises a ResourceNotFou 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:: +to *theme* a web application. We start with the following directories:: + + + `-- templates + |-- snippets + | `-- panel.html + |-- index.html + |-- profile.html + `-- base.html + + `-- theme + |-- snippets + | |-- widget.html + | `-- extra.html + |-- index.html + `-- theme.html + +And we want to create a single filesystem that looks for files in `templates` if +they don't exist in `theme`. We can do this with the following code:: + from fs.osfs import OSFS from fs.multifs import MultiFS themed_template_fs.addfs('templates', OSFS('templates')) themed_template_fs.addfs('theme', OSFS('themes')) + + +Now we have a `themed_template_fs` FS object presents a single view of both +directories:: + + |-- snippets + | |-- panel.html + | |-- widget.html + | `-- extra.html + |-- index.html + |-- profile.html + |-- base.html + `-- theme.html - 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*. """ |