Permalink
Browse files

Make PickleShareDB inherit from collections.MutableMapping abc

  • Loading branch information...
1 parent e57ac64 commit 1ec897c122257b14aa3b00b26e056c2669a1cd4c @takluyver committed Aug 6, 2011
Showing with 8 additions and 2 deletions.
  1. +8 −2 IPython/utils/pickleshare.py
@@ -35,16 +35,16 @@
from IPython.external.path import path as Path
import os,stat,time
+import collections
import cPickle as pickle
-import UserDict
import glob
def gethashfile(key):
return ("%02x" % abs(hash(key) % 256))[-2:]
_sentinel = object()
-class PickleShareDB(UserDict.DictMixin):
+class PickleShareDB(collections.MutableMapping):
""" The main 'connection' object for PickleShare database """
def __init__(self,root):
""" Return a db object that will manage the specied directory"""
@@ -187,6 +187,12 @@ def keys(self, globpat = None):
else:
files = [Path(p) for p in glob.glob(self.root/globpat)]
return [self._normalized(p) for p in files if p.isfile()]
+
+ def __iter__(self):
+ return iter(keys)
+
+ def __len__(self):
+ return len(keys)
def uncache(self,*items):
""" Removes all, or specified items from cache

0 comments on commit 1ec897c

Please sign in to comment.