summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bachelier <laurent@bachelier.name>2011-06-08 23:02:26 +0200
committerLaurent Bachelier <laurent@bachelier.name>2011-06-08 23:02:26 +0200
commit700e1d9240218892c56fa2262c169a2e2a9e4594 (patch)
tree9875a214016fb10e4e5b06626ecd828964abea6d
parentFactorization (diff)
downloadffs-700e1d9240218892c56fa2262c169a2e2a9e4594.tar.xz
Fix vocabulary
It's a dict, not a list!
-rw-r--r--ffs.py10
-rw-r--r--test.py14
2 files changed, 12 insertions, 12 deletions
diff --git a/ffs.py b/ffs.py
index 609b334..96aab9d 100644
--- a/ffs.py
+++ b/ffs.py
@@ -27,7 +27,7 @@ class Router(object):
return cls
-class List(MutableMapping):
+class Dict(MutableMapping):
def __init__(self, root, router):
self.root = root
self.router = router
@@ -38,8 +38,8 @@ class List(MutableMapping):
def __getitem__(self, key):
cls = self._get_cls(key)
- if self._is_list(cls):
- return List(self._get_path(key), cls)
+ if self._is_dict(cls):
+ return Dict(self._get_path(key), cls)
else:
with open(self._get_path(key), 'rb') as f:
data = f.read()
@@ -55,7 +55,7 @@ class List(MutableMapping):
raise KeyError(key)
return cls
- def _is_list(self, cls):
+ def _is_dict(self, cls):
return isinstance(cls, Router)
def _get_path(self, key):
@@ -63,7 +63,7 @@ class List(MutableMapping):
def __delitem__(self, key):
cls = self._get_cls(key)
- if self._is_list(cls):
+ if self._is_dict(cls):
shutil.rmtree(self._get_path(key))
else:
os.unlink(self._get_path(key))
diff --git a/test.py b/test.py
index 56655e9..32c68c9 100644
--- a/test.py
+++ b/test.py
@@ -1,4 +1,4 @@
-from ffs import Router, List, RouterError
+from ffs import Router, Dict, RouterError
from tempfile import mkdtemp
import os
import shutil
@@ -18,7 +18,7 @@ class FfsTest(TestCase):
def test_simpleAccess1(self):
rtr = Router(lol=Router(hop=str))
- lst1 = List(self.root, rtr)
+ lst1 = Dict(self.root, rtr)
assert 'hop' not in lst1
assert 'lol' in lst1
lst2 = lst1['lol']
@@ -26,7 +26,7 @@ class FfsTest(TestCase):
def test_simpleAccess2(self):
rtr = Router(lol=Router(cat=str))
- lst1 = List(self.root, rtr)
+ lst1 = Dict(self.root, rtr)
assert 'cat' not in lst1
assert 'lol' in lst1
lst2 = lst1['lol']
@@ -40,7 +40,7 @@ class FfsTest(TestCase):
f.write("hello3")
rtr = Router(lol=Router({'c*t': str}))
- lst1 = List(self.root, rtr)
+ lst1 = Dict(self.root, rtr)
assert 'cat' not in lst1
assert 'lol' in lst1
lst2 = lst1['lol']
@@ -55,7 +55,7 @@ class FfsTest(TestCase):
def test_finalValueDelete(self):
rtr = Router(lol=Router(cat=str))
- lst1 = List(self.root, rtr)
+ lst1 = Dict(self.root, rtr)
lst2 = lst1['lol']
assert 'cat' in lst2
del lst2['cat']
@@ -63,7 +63,7 @@ class FfsTest(TestCase):
def test_finalValueSet(self):
rtr = Router(lol=Router(cat=str, cot=str))
- lst1 = List(self.root, rtr)
+ lst1 = Dict(self.root, rtr)
lst2 = lst1['lol']
assert 'cot' not in lst2
lst2['cot'] = "hello2"
@@ -72,7 +72,7 @@ class FfsTest(TestCase):
def test_listDelete(self):
rtr = Router(lol=Router(cat=str, cot=str))
- lst1 = List(self.root, rtr)
+ lst1 = Dict(self.root, rtr)
assert 'lol' in lst1
del lst1['lol']
assert 'lol' not in lst1