N
λu¦9c       sΥ     d  Z   ! y " k l l Wn# # e j
 o $ k l l n X& y ' k l Wn  ( e j
 o ) k l 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   Shelfc      s   , d  Z  1 3 d   Z 6 d   Z 9 d   Z < d   Z ? d   Z C d   Z I d   Z L d   Z S d	   Z	 V 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*   /usr/lib/python1.5/site-packages/shelve.pys   __init__3 s   c    s   6 7 |  i i   Sd  S(   N(   s   selfs   dicts   keys(   s   selfs*   /usr/lib/python1.5/site-packages/shelve.pys   keys6 s   c    s   9 : t  |  i  Sd  S(   N(   s   lens   selfs   dict(   s   selfs*   /usr/lib/python1.5/site-packages/shelve.pys   __len__9 s   c    s   < = |  i i |  Sd  S(   N(   s   selfs   dicts   has_keys   key(   s   selfs   keys*   /usr/lib/python1.5/site-packages/shelve.pys   has_key< s   c    s0   ? @ t  |  i |  } A t |  i   Sd  S(   N(   s   StringIOs   selfs   dicts   keys   fs	   Unpicklers   load(   s   selfs   keys   fs*   /usr/lib/python1.5/site-packages/shelve.pys   __getitem__? s   c    sH   C D t    } E t |  } F | i |  G | i   |  i | <d  S(   N(
   s   StringIOs   fs   Picklers   ps   dumps   values   getvalues   selfs   dicts   key(   s   selfs   keys   values   fs   ps*   /usr/lib/python1.5/site-packages/shelve.pys   __setitem__C s   c    s   I J |  i | =d  S(   N(   s   selfs   dicts   key(   s   selfs   keys*   /usr/lib/python1.5/site-packages/shelve.pys   __delitem__I s   c    s:   L M y N |  i i   Wn O P n XQ d |  _ d  S(   Ni    (   s   selfs   dicts   close(   s   selfs*   /usr/lib/python1.5/site-packages/shelve.pys   closeL s
   c    s   S T |  i   d  S(   N(   s   selfs   close(   s   selfs*   /usr/lib/python1.5/site-packages/shelve.pys   __del__S s   c    s1   V W t  |  i d  o X |  i i   n d  S(   Ns   sync(   s   hasattrs   selfs   dicts   sync(   s   selfs*   /usr/lib/python1.5/site-packages/shelve.pys   syncV s   (   s   __doc__s   __init__s   keyss   __len__s   has_keys   __getitem__s   __setitem__s   __delitem__s   closes   __del__s   sync(    s*   /usr/lib/python1.5/site-packages/shelve.pys   Shelf, s   	s
   BsdDbShelfc      sV   [ d  Z  f h d   Z k d   Z p d   Z u d   Z 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   h i t  i |  |  d  S(   N(   s   Shelfs   __init__s   selfs   dict(   s   selfs   dicts*   /usr/lib/python1.5/site-packages/shelve.pys   __init__h s   c    sJ   k l |  i i |  \ } } m t |  } n | t |  i   f Sd  S(   N(	   s   selfs   dicts   set_locations   keys   values   StringIOs   fs	   Unpicklers   load(   s   selfs   keys   values   fs*   /usr/lib/python1.5/site-packages/shelve.pys   set_locationk s   c    sG   p q |  i i   \ } } r t |  } s | t |  i   f Sd  S(   N(	   s   selfs   dicts   nexts   keys   values   StringIOs   fs	   Unpicklers   load(   s   selfs   keys   values   fs*   /usr/lib/python1.5/site-packages/shelve.pys   nextp s   c    sG   u v |  i i   \ } } w t |  } x | t |  i   f Sd  S(   N(	   s   selfs   dicts   previouss   keys   values   StringIOs   fs	   Unpicklers   load(   s   selfs   keys   values   fs*   /usr/lib/python1.5/site-packages/shelve.pys   previousu s   c    sG   z { |  i i   \ } } | t |  } } | t |  i   f Sd  S(   N(	   s   selfs   dicts   firsts   keys   values   StringIOs   fs	   Unpicklers   load(   s   selfs   keys   values   fs*   /usr/lib/python1.5/site-packages/shelve.pys   firstz 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*   /usr/lib/python1.5/site-packages/shelve.pys   last s   (   s   __doc__s   __init__s   set_locations   nexts   previouss   firsts   last(    s*   /usr/lib/python1.5/site-packages/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/     k  }  t i |  | i | |   d  S(   N(   s   anydbms   Shelfs   __init__s   selfs   opens   filenames   flag(   s   selfs   filenames   flags   anydbms*   /usr/lib/python1.5/site-packages/shelve.pys   __init__ s   	s   c(   s   __doc__s   __init__(    s*   /usr/lib/python1.5/site-packages/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*   /usr/lib/python1.5/site-packages/shelve.pys   open s   s   cN(   s   __doc__s   cPickles   Picklers	   Unpicklers   ImportErrors   pickles	   cStringIOs   StringIOs   Shelfs
   BsdDbShelfs   DbfilenameShelfs   open(    s*   /usr/lib/python1.5/site-packages/shelve.pys   ? s   /*