Ζ
Nφ9c       sΙ   d  Z  y d k l Z l Z Wn& e j
 o d k l Z l Z n Xy d k l Z Wn  e j
 o d k l Z n Xd 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      sn   d  Z  d   Z d   Z d   Z d   Z e d  Z d   Z d   Z d   Z	 d	   Z
 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   | |  _  d  S(   N(   s   dicts   self(   s   selfs   dicts#   /mit/python/lib/python2.0/shelve.pys   __init__3 s    c    s   |  i i   Sd  S(   N(   s   selfs   dicts   keys(   s   selfs#   /mit/python/lib/python2.0/shelve.pys   keys6 s    c    s   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    s'   |  i i |  o |  | Sn | Sd  S(   N(   s   selfs   dicts   has_keys   keys   default(   s   selfs   keys   defaults#   /mit/python/lib/python2.0/shelve.pys   get? s    c    s'   t  |  i |  } 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    s9   t    } t |  } | i |  | 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   |  i | =d  S(   N(   s   selfs   dicts   key(   s   selfs   keys#   /mit/python/lib/python2.0/shelve.pys   __delitem__N s    c    s(   y |  i i   Wn n Xd |  _ d  S(   Ni    (   s   selfs   dicts   close(   s   selfs#   /mit/python/lib/python2.0/shelve.pys   closeQ s
    c    s   |  i   d  S(   N(   s   selfs   close(   s   selfs#   /mit/python/lib/python2.0/shelve.pys   __del__X s    c    s(   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      s>   d  Z  d   Z d   Z d   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   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    s>   |  i i |  \ } } t |  } | 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    s;   |  i i   \ } } t |  } | 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    s;   |  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    s;   |  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    s;   |  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    s)   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*