Ζ
Nφ9c       sσ     d  Z   ! y " d k l Z l Z Wn, # e j
 o $ d k l Z l Z n X& y ' d k l Z Wn& ( e j
 o ) d k l Z n X, d f  d     YZ ` d e f d     YZ	  d e f d     YZ
  d
 d	  Z d S(   s£  Manage shelves of pickled objects.

A "shelf" is a persistent, dictionary-like object.  The difference
with dbm databases is that the values (not the keys!) in a shelf can
be essentially arbitrary Python objects -- anything that the "pickle"
module can handle.  This includes most class instances, recursive data
types, and objects containing lots of shared sub-objects.  The keys
are ordinary strings.

To summarize the interface (key is a string, data is an arbitrary
object):

        import shelve
        d = shelve.open(filename) # open, with (g)dbm filename -- no suffix

        d[key] = data   # store data at key (overwrites old data if
                        # using an existing key)
        data = d[key]   # retrieve data at key (raise KeyError if no
                        # such key)
        del d[key]      # delete data stored at key (raises KeyError
                        # if no such key)
        flag = d.has_key(key)   # true if the key exists
        list = d.keys() # a list of all existing keys (slow!)

        d.close()       # close it

Dependent on the implementation, closing a persistent dictionary may
or may not be necessary to flush changes to disk.
(   s   Picklers	   Unpickler(   s   StringIOs   Shelfc      s   , d  Z  1 3 d   Z 6 d   Z 9 d   Z < d   Z ? e d  Z D d   Z H d   Z N d   Z	 Q d	   Z
 X d
   Z [ d   Z RS(   s΄   Base class for shelf implementations.

        This is initialized with a dictionary-like object.
        See the module's __doc__ string for an overview of the interface.
        c    s   3 4 | |  _  d  S(   N(   s   dicts   self(   s   selfs   dicts#   /mit/python/lib/python2.0/shelve.pys   __init__3 s   c    s   6 7 |  i i   Sd  S(   N(   s   selfs   dicts   keys(   s   selfs#   /mit/python/lib/python2.0/shelve.pys   keys6 s   c    s   9 : t  |  i  Sd  S(   N(   s   lens   selfs   dict(   s   selfs#   /mit/python/lib/python2.0/shelve.pys   __len__9 s   c    s   < = |  i i |  Sd  S(   N(   s   selfs   dicts   has_keys   key(   s   selfs   keys#   /mit/python/lib/python2.0/shelve.pys   has_key< s   c    s3   ? @ |  i i |  o A |  | Sn B | Sd  S(   N(   s   selfs   dicts   has_keys   keys   default(   s   selfs   keys   defaults#   /mit/python/lib/python2.0/shelve.pys   get? s   c    s0   D E t  |  i |  } F t |  i   Sd  S(   N(   s   StringIOs   selfs   dicts   keys   fs	   Unpicklers   load(   s   selfs   keys   fs#   /mit/python/lib/python2.0/shelve.pys   __getitem__D s   c    sH   H I t    } J t |  } K | i |  L | i   |  i | <d  S(   N(
   s   StringIOs   fs   Picklers   ps   dumps   values   getvalues   selfs   dicts   key(   s   selfs   keys   values   fs   ps#   /mit/python/lib/python2.0/shelve.pys   __setitem__H s   c    s   N O |  i | =d  S(   N(   s   selfs   dicts   key(   s   selfs   keys#   /mit/python/lib/python2.0/shelve.pys   __delitem__N s   c    s:   Q R y S |  i i   Wn T U n XV d |  _ d  S(   Ni    (   s   selfs   dicts   close(   s   selfs#   /mit/python/lib/python2.0/shelve.pys   closeQ s
   c    s   X Y |  i   d  S(   N(   s   selfs   close(   s   selfs#   /mit/python/lib/python2.0/shelve.pys   __del__X s   c    s1   [ \ t  |  i d  o ] |  i i   n d  S(   Ns   sync(   s   hasattrs   selfs   dicts   sync(   s   selfs#   /mit/python/lib/python2.0/shelve.pys   sync[ s   (   s   __doc__s   __init__s   keyss   __len__s   has_keys   Nones   gets   __getitem__s   __setitem__s   __delitem__s   closes   __del__s   sync(    s#   /mit/python/lib/python2.0/shelve.pys   Shelf, s   	s
   BsdDbShelfc      sV   ` d  Z  k m d   Z p d   Z u d   Z z d   Z  d   Z  d   Z RS(   sΞ  Shelf implementation using the "BSD" db interface.

        This adds methods first(), next(), previous(), last() and
        set_location() that have no counterpart in [g]dbm databases.

        The actual database must be opened using one of the "bsddb"
        modules "open" routines (i.e. bsddb.hashopen, bsddb.btopen or
        bsddb.rnopen) and passed to the constructor.

        See the module's __doc__ string for an overview of the interface.
        c    s   m n t  i |  |  d  S(   N(   s   Shelfs   __init__s   selfs   dict(   s   selfs   dicts#   /mit/python/lib/python2.0/shelve.pys   __init__m s   c    sJ   p q |  i i |  \ } } r t |  } s | t |  i   f Sd  S(   N(	   s   selfs   dicts   set_locations   keys   values   StringIOs   fs	   Unpicklers   load(   s   selfs   keys   values   fs#   /mit/python/lib/python2.0/shelve.pys   set_locationp s   c    sG   u v |  i i   \ } } w t |  } x | t |  i   f Sd  S(   N(	   s   selfs   dicts   nexts   keys   values   StringIOs   fs	   Unpicklers   load(   s   selfs   keys   values   fs#   /mit/python/lib/python2.0/shelve.pys   nextu s   c    sG   z { |  i i   \ } } | t |  } } | t |  i   f Sd  S(   N(	   s   selfs   dicts   previouss   keys   values   StringIOs   fs	   Unpicklers   load(   s   selfs   keys   values   fs#   /mit/python/lib/python2.0/shelve.pys   previousz s   c    sG     |  i i   \ } }  t |  }  | t |  i   f Sd  S(   N(	   s   selfs   dicts   firsts   keys   values   StringIOs   fs	   Unpicklers   load(   s   selfs   keys   values   fs#   /mit/python/lib/python2.0/shelve.pys   first s   c    sG     |  i i   \ } }  t |  }  | t |  i   f Sd  S(   N(	   s   selfs   dicts   lasts   keys   values   StringIOs   fs	   Unpicklers   load(   s   selfs   keys   values   fs#   /mit/python/lib/python2.0/shelve.pys   last s   (   s   __doc__s   __init__s   set_locations   nexts   previouss   firsts   last(    s#   /mit/python/lib/python2.0/shelve.pys
   BsdDbShelf` s   	s   DbfilenameShelfc      s    d  Z    d d  Z RS(   sΦ   Shelf implementation using the "anydbm" generic dbm interface.

        This is initialized with the filename for the dbm database.
        See the module's __doc__ string for an overview of the interface.
        c    s2     d  k  }  t i |  | i | |   d  S(   N(   s   anydbms   Shelfs   __init__s   selfs   opens   filenames   flag(   s   selfs   filenames   flags   anydbms#   /mit/python/lib/python2.0/shelve.pys   __init__ s   s   c(   s   __doc__s   __init__(    s#   /mit/python/lib/python2.0/shelve.pys   DbfilenameShelf s   	c    s      t  |  |  Sd S(   sΐ   Open a persistent dictionary for reading and writing.

        Argument is the filename for the dbm database.
        See the module's __doc__ string for an overview of the interface.
        N(   s   DbfilenameShelfs   filenames   flag(   s   filenames   flags#   /mit/python/lib/python2.0/shelve.pys   open s   s   cN(   s   __doc__s   cPickles   Picklers	   Unpicklers   ImportErrors   pickles	   cStringIOs   StringIOs   Shelfs
   BsdDbShelfs   DbfilenameShelfs   open(    s#   /mit/python/lib/python2.0/shelve.pys   ? s   4*