³ò
¼›\Kc           @   s¿   d  Z  d d k Z y d d k l Z Wn& e j
 o d d d „  ƒ  YZ n Xd d k Z e i d e i d d d „ Z	 d e i
 f d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d d d „  ƒ  YZ d S(   sN   Manage shelves of pickled objects using bsddb database files for the
storage.
iÿÿÿÿN(   t	   DictMixinR    c           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyR    %   s    i°  c         C   sÞ   t  | ƒ t  d ƒ j oœ | } | d j o t i } qµ | d j o
 d } qµ | d j o t i } qµ | d j o t i } qµ | d j o t i t i B} qµ t i d ‚ n t | ƒ } | i |  | | | | ƒ | S(	   s(  
    A simple factory function for compatibility with the standard
    shleve.py module.  It can be used like this, where key is a string
    and data is a pickleable object:

        from bsddb import dbshelve
        db = dbshelve.open(filename)

        db[key] = data

        db.close()
    t    t   rt   rwi    t   wt   ct   nsJ   flags should be one of 'r', 'w', 'c' or 'n' or use the bsddb.db.DB_* flags(   t   typet   dbt	   DB_RDONLYt	   DB_CREATEt   DB_TRUNCATEt   DBErrort   DBShelft   open(   t   filenamet   flagst   modet   filetypet   dbenvt   dbnamet   sflagt   d(    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyR   +   s     
t   DBShelveErrorc           B   s   e  Z RS(    (   R   R   (    (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyR   N   s    R   c           B   sÚ   e  Z d  Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d d „ Z d d	 „ Z d d
 „ Z d d „ Z d d „ Z d d „ Z d „  Z d d d „ Z d d d „ Z d d d „ Z d d „ Z RS(   sŽ   A shelf to hold pickled objects, built upon a bsddb DB object.  It
    automatically pickles/unpickles data objects going to/from the DB.
    c         C   s   t  i | ƒ |  _  d |  _ d  S(   Ni   (   R
   t   DBt   binary(   t   selfR   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyt   __init__U   s    c         C   s   |  i  ƒ  d  S(   N(   t   close(   R   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyt   __del__Z   s    c         C   s   t  |  i | ƒ S(   sT   Many methods we can just pass through to the DB object.
        (See below)
        (   t   getattrR
   (   R   t   name(    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyt   __getattr__^   s    c         C   s   t  |  i ƒ S(   N(   t   lenR
   (   R   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyt   __len__h   s    c         C   s   |  i  | } t i | ƒ S(   N(   R
   t   cPicklet   loads(   R   t   keyt   data(    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyt   __getitem__l   s    c         C   s&   t  i | |  i ƒ } | |  i | <d  S(   N(   R%   t   dumpsR   R
   (   R   R'   t   valueR(   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyt   __setitem__q   s    c         C   s   |  i  | =d  S(   N(   R
   (   R   R'   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyt   __delitem__v   s    c         C   s2   | d  j o |  i i | ƒ Sn |  i i ƒ  Sd  S(   N(   t   NoneR
   t   keys(   R   t   txn(    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyR/   z   s    c         C   so   | d  j o |  i i | ƒ } n |  i i ƒ  } g  } x0 | D]( \ } } | i | t i | ƒ f ƒ q? W| S(   N(   R.   R
   t   itemst   appendR%   R&   (   R   R0   R1   t   newitemst   kt   v(    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyR1      s      c         C   sB   | d  j o |  i i | ƒ } n |  i i ƒ  } t t i | ƒ S(   N(   R.   R
   t   valuest   mapR%   R&   (   R   R0   R6   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyR6   Œ   s    c         C   s(   t  i | |  i ƒ } |  i i | | ƒ S(   N(   R%   R*   R   R
   R2   (   R   R+   R0   R(   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyt   __append—   s    c         C   s:   |  i  ƒ  t i j o |  i | d | ƒSn t d ‚ d  S(   NR0   sO   append() only supported when dbshelve opened with filetype=dbshelve.db.DB_RECNO(   t   get_typeR
   t   DB_RECNOt   _DBShelf__appendR   (   R   R+   R0   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyR2   ›   s    i    c         C   s"   | d „ } |  i  i | | | ƒ S(   Nc         S   s   t  i | ƒ } | |  | ƒ S(   N(   R%   R&   (   t   priKeyt   priDatat   realCallbackR(   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyt   _shelf_callback¢   s    (   R
   t	   associate(   R   t   secondaryDBt   callbackR   R?   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyR@   ¡   s    c         O   sP   t  |  i i | | ƒ } y t i | ƒ SWn  t t i f j
 o | Sn Xd  S(   N(   t   applyR
   t   getR%   R&   t	   TypeErrort   UnpicklingError(   R   t   argst   kwR(   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyRD   ©   s
    c         C   s=   t  i | |  i ƒ } |  i i | | | | ƒ } t  i | ƒ S(   N(   R%   R*   R   R
   RD   R&   (   R   R'   R+   R0   R   R(   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyt   get_bothµ   s    c         C   s+   t  |  i i | | ƒ ƒ } |  i | _ | S(   N(   t   DBShelfCursorR
   t   cursorR   (   R   R0   R   R   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyRK   »   s    c         C   s.   t  i | |  i ƒ } |  i i | | | | ƒ S(   N(   R%   R*   R   R
   t   put(   R   R'   R+   R0   R   R(   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyRL   Á   s    c         C   s
   t  ‚ d  S(   N(   t   NotImplementedError(   R   t
   cursorListR   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyt   joinÆ   s    N(   R   R   t   __doc__R.   R   R   R"   R$   R)   R,   R-   R/   R1   R6   R;   R2   R@   RD   RI   RK   RL   RO   (    (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyR   Q   s&   		
					RJ   c           B   s  e  Z d  Z d „  Z d „  Z d „  Z d d „ Z d d „ Z d „  Z d „  Z	 d	 „  Z
 d
 „  Z d d „ Z d d „ Z d d „ Z d d „ Z d d „ Z d d „ Z d d „ Z d d „ Z d d „ Z d d „ Z d d „ Z d d „ Z d d „ Z e Z d „  Z RS(   s   
    c         C   s   | |  _  d  S(   N(   t   dbc(   R   RK   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyR   ×   s    c         C   s   |  i  ƒ  d  S(   N(   R   (   R   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyR   Ú   s    c         C   s   t  |  i | ƒ S(   sH   Some methods we can just pass through to the cursor object.  (See below)(   R    RQ   (   R   R!   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyR"   Þ   s    i    c         C   s   t  |  i i | ƒ ƒ S(   N(   RJ   RQ   t   dup(   R   R   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyRR   å   s    c         C   s+   t  i | |  i ƒ } |  i i | | | ƒ S(   N(   R%   R*   R   RQ   RL   (   R   R'   R+   R   R(   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyRL   é   s    c         G   s0   t  | ƒ } t |  d | ƒ } t | | ƒ d  S(   Ns   get_%d(   R#   R    RC   (   R   RG   t   countt   method(    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyRD   î   s    c         C   s   |  i  i | ƒ } |  i | ƒ S(   N(   RQ   RD   t   _extract(   R   R   t   rec(    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyt   get_1ó   s    c         C   s"   |  i  i | | ƒ } |  i | ƒ S(   N(   RQ   RD   RU   (   R   R'   R   RV   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyt   get_2÷   s    c         C   s7   t  i | |  i ƒ } |  i i | | ƒ } |  i | ƒ S(   N(   R%   R*   R   RQ   RD   RU   (   R   R'   R+   R   R(   RV   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyt   get_3û   s    c         C   s   |  i  | t i Bƒ S(   N(   RW   R
   t
   DB_CURRENT(   R   R   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyt   current  s    c         C   s   |  i  | t i Bƒ S(   N(   RW   R
   t   DB_FIRST(   R   R   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyt   first  s    c         C   s   |  i  | t i Bƒ S(   N(   RW   R
   t   DB_LAST(   R   R   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyt   last  s    c         C   s   |  i  | t i Bƒ S(   N(   RW   R
   t   DB_NEXT(   R   R   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyt   next  s    c         C   s   |  i  | t i Bƒ S(   N(   RW   R
   t   DB_PREV(   R   R   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyt   prev  s    c         C   s   |  i  | t i Bƒ S(   N(   RW   R
   t
   DB_CONSUME(   R   R   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyt   consume  s    c         C   s   |  i  | t i Bƒ S(   N(   RW   R
   t   DB_NEXT_DUP(   R   R   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyt   next_dup  s    c         C   s   |  i  | t i Bƒ S(   N(   RW   R
   t   DB_NEXT_NODUP(   R   R   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyt
   next_nodup  s    c         C   s   |  i  | t i Bƒ S(   N(   RW   R
   t   DB_PREV_NODUP(   R   R   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyt
   prev_nodup	  s    c         C   s7   t  i | |  i ƒ } |  i i | | ƒ } |  i | ƒ S(   N(   R%   R*   R   RQ   RI   RU   (   R   R'   R+   R   R(   RV   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyRI     s    c         C   s"   |  i  i | | ƒ } |  i | ƒ S(   N(   RQ   t   setRU   (   R   R'   R   RV   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyRl     s    c         C   s"   |  i  i | | ƒ } |  i | ƒ S(   N(   RQ   t	   set_rangeRU   (   R   R'   R   RV   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyRm     s    c         C   s"   |  i  i | | ƒ } |  i | ƒ S(   N(   RQ   t	   set_recnoRU   (   R   t   recnoR   RV   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyRn     s    c         C   s8   | d  j o d  Sn  | \ } } | t i | ƒ f Sd  S(   N(   R.   R%   R&   (   R   RV   R'   R(   (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyRU      s    (   R   R   RP   R   R   R"   RR   RL   RD   RW   RX   RY   R[   R]   R_   Ra   Rc   Re   Rg   Ri   Rk   RI   Rl   Rm   Rn   t   set_bothRU   (    (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pyRJ   Ô   s2   							(    (    (   RP   R%   t   UserDictR    t   ImportErrorR
   R   t   DB_HASHR.   R   R   R   R   RJ   (    (    (    s$   /usr/lib/python2.5/bsddb/dbshelve.pys   <module>   s   "ƒ