Skip to content

Commit

Permalink
Make PickleShareDB inherit from collections.MutableMapping abc
Browse files Browse the repository at this point in the history
  • Loading branch information
takluyver committed Sep 7, 2011
1 parent e57ac64 commit 1ec897c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions IPython/utils/pickleshare.py
Expand Up @@ -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"""
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1ec897c

Please sign in to comment.