projects
/
invirt/packages/python-routefs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
I apparently used to have a crappy sense of style. Let's fix that.
[invirt/packages/python-routefs.git]
/
routefs
/
dictfs.py
diff --git
a/routefs/dictfs.py
b/routefs/dictfs.py
index
9b88485
..
25904b1
100644
(file)
--- a/
routefs/dictfs.py
+++ b/
routefs/dictfs.py
@@
-10,41
+10,44
@@
A dictionary represents a directory, with keys corresponding to
file names and the values corresponding to the file contents.
"""
file names and the values corresponding to the file contents.
"""
-import routefs
-from routes import Mapper
+
import os
import os
+from routes import Mapper
+
+import routefs
+
+
class DictFS(routefs.RouteFS):
controllers = ['handler']
class DictFS(routefs.RouteFS):
controllers = ['handler']
-
+
@property
def files(self):
"""
This property should be overridden in your DictFS descendant
"""
return dict()
@property
def files(self):
"""
This property should be overridden in your DictFS descendant
"""
return dict()
-
- @property
- def map(self):
+
+ def make_map(self):
m = Mapper()
m = Mapper()
-
+
m.connect('*path', controller='handler')
m.connect('*path', controller='handler')
-
+
return m
return m
-
+
def handler(self, path, **kwargs):
if path != '':
elements = path.split(os.path.sep)
else:
elements = []
def handler(self, path, **kwargs):
if path != '':
elements = path.split(os.path.sep)
else:
elements = []
-
+
try:
tree = self.files
for elt in elements:
tree = tree[elt]
except KeyError:
return
try:
tree = self.files
for elt in elements:
tree = tree[elt]
except KeyError:
return
-
+
if type(tree) is dict:
return tree.keys()
else:
if type(tree) is dict:
return tree.keys()
else: