##// END OF EJS Templates
Make PickleShareDB inherit from collections.MutableMapping abc
Thomas Kluyver -
Show More
@@ -35,8 +35,8 b' License: MIT open source license.'
35
35
36 from IPython.external.path import path as Path
36 from IPython.external.path import path as Path
37 import os,stat,time
37 import os,stat,time
38 import collections
38 import cPickle as pickle
39 import cPickle as pickle
39 import UserDict
40 import glob
40 import glob
41
41
42 def gethashfile(key):
42 def gethashfile(key):
@@ -44,7 +44,7 b' def gethashfile(key):'
44
44
45 _sentinel = object()
45 _sentinel = object()
46
46
47 class PickleShareDB(UserDict.DictMixin):
47 class PickleShareDB(collections.MutableMapping):
48 """ The main 'connection' object for PickleShare database """
48 """ The main 'connection' object for PickleShare database """
49 def __init__(self,root):
49 def __init__(self,root):
50 """ Return a db object that will manage the specied directory"""
50 """ Return a db object that will manage the specied directory"""
@@ -187,6 +187,12 b' class PickleShareDB(UserDict.DictMixin):'
187 else:
187 else:
188 files = [Path(p) for p in glob.glob(self.root/globpat)]
188 files = [Path(p) for p in glob.glob(self.root/globpat)]
189 return [self._normalized(p) for p in files if p.isfile()]
189 return [self._normalized(p) for p in files if p.isfile()]
190
191 def __iter__(self):
192 return iter(keys)
193
194 def __len__(self):
195 return len(keys)
190
196
191 def uncache(self,*items):
197 def uncache(self,*items):
192 """ Removes all, or specified items from cache
198 """ Removes all, or specified items from cache
General Comments 0
You need to be logged in to leave comments. Login now