-ν
ηΆ<c       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 d d d g Z 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   Shelfs
   BsdDbShelfs   DbfilenameShelfs   openc      st   t  Z 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   dict(    (    s   /usr/lib/python2.2/shelve.pys   __init__4 s    c    s   |  i i   Sd  S(   N(   s   selfs   dicts   keys(   s   self(    (    s   /usr/lib/python2.2/shelve.pys   keys7 s    c    s   t  |  i  Sd  S(   N(   s   lens   selfs   dict(   s   self(    (    s   /usr/lib/python2.2/shelve.pys   __len__: s    c    s   |  i i |  Sd  S(   N(   s   selfs   dicts   has_keys   key(   s   selfs   key(    (    s   /usr/lib/python2.2/shelve.pys   has_key= s    c    s'   |  i i |  o |  | Sn | Sd  S(   N(   s   selfs   dicts   has_keys   keys   default(   s   selfs   keys   default(    (    s   /usr/lib/python2.2/shelve.pys   get@ s    c    s'   t  |  i |  } t |  i   Sd  S(   N(   s   StringIOs   selfs   dicts   keys   fs	   Unpicklers   load(   s   selfs   keys   f(    (    s   /usr/lib/python2.2/shelve.pys   __getitem__E 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   ps   f(    (    s   /usr/lib/python2.2/shelve.pys   __setitem__I s    	c    s   |  i | =d  S(   N(   s   selfs   dicts   key(   s   selfs   key(    (    s   /usr/lib/python2.2/shelve.pys   __delitem__O s    c    s(   y |  i i   Wn n Xd |  _ d  S(   Ni    (   s   selfs   dicts   close(   s   self(    (    s   /usr/lib/python2.2/shelve.pys   closeR s
    c    s   |  i   d  S(   N(   s   selfs   close(   s   self(    (    s   /usr/lib/python2.2/shelve.pys   __del__Y s    c    s(   t  |  i d  o |  i i   n d  S(   Ns   sync(   s   hasattrs   selfs   dicts   sync(   s   self(    (    s   /usr/lib/python2.2/shelve.pys   sync\ s    (   s   __name__s
   __module__s   __doc__s   __init__s   keyss   __len__s   has_keys   Nones   gets   __getitem__s   __setitem__s   __delitem__s   closes   __del__s   sync(    (    (    s   /usr/lib/python2.2/shelve.pys   Shelf- s    									c      sD   t  Z 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   dict(    (    s   /usr/lib/python2.2/shelve.pys   __init__n 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   fs   value(    (    s   /usr/lib/python2.2/shelve.pys   set_locationq 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   fs   value(    (    s   /usr/lib/python2.2/shelve.pys   nextv 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   fs   value(    (    s   /usr/lib/python2.2/shelve.pys   previous{ 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   fs   value(    (    s   /usr/lib/python2.2/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   fs   value(    (    s   /usr/lib/python2.2/shelve.pys   last s    (	   s   __name__s
   __module__s   __doc__s   __init__s   set_locations   nexts   previouss   firsts   last(    (    (    s   /usr/lib/python2.2/shelve.pys
   BsdDbShelfa s    					c      s   t  Z 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.
    s   cc    s)   d  k  } t i |  | i | |   d  S(   N(   s   anydbms   Shelfs   __init__s   selfs   opens   filenames   flag(   s   selfs   filenames   flags   anydbm(    (    s   /usr/lib/python2.2/shelve.pys   __init__ s    	(   s   __name__s
   __module__s   __doc__s   __init__(    (    (    s   /usr/lib/python2.2/shelve.pys   DbfilenameShelf s    s   cc    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   flag(    (    s   /usr/lib/python2.2/shelve.pys   open s     N(   s   __doc__s   cPickles   Picklers	   Unpicklers   ImportErrors   pickles	   cStringIOs   StringIOs   __all__s   Shelfs
   BsdDbShelfs   DbfilenameShelfs   open(   s
   BsdDbShelfs   opens   __all__s   StringIOs   Shelfs	   Unpicklers   Picklers   DbfilenameShelf(    (    s   /usr/lib/python2.2/shelve.pys   ? s   4*