Ñò
.mÈKc           @   sW  d  Z  d d k Z d d k Z d d k Z e i d d j Z e o d d Un d d k Z e i d  d j o7 e i Z e i d  d j  o d „  Z q¶ d	 „  Z n d Z d
 „  Z y d d k	 l
 Z
 Wn& e j
 o d d d „  ƒ  YZ
 n Xe 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ÿÿÿÿNi    i   s   from . import dbi   i   c         C   s   t  i |  | ƒ S(   N(   t   cPicklet   dumps(   t   objectt   protocol(    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyt   _dumps2   s    c         C   s   t  i |  d | ƒS(   NR   (   R    R   (   R   R   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyR   5   s    c         C   s   t  i |  d | ƒS(   Nt   bin(   R    R   (   R   R   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyR   :   s    (   t	   DictMixinR   c           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyR   B   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.6/bsddb/dbshelve.pyR   G   s     
t   DBShelveErrorc           B   s   e  Z RS(    (   R   R   (    (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyR   j   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	 „  Z d
 „  Z 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 | ƒ |  _  t |  _ t o t |  _ n
 d |  _ d  S(   Ni   (   R   t   DBt   Truet   _closedt   HIGHEST_PROTOCOLR   (   t   selfR   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyt   __init__q   s
    	c         C   s   |  i  ƒ  d  S(   N(   t   close(   R$   (    (    s$   /usr/lib/python2.6/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.6/bsddb/dbshelve.pyt   __getattr__~   s    c         C   s   t  |  i ƒ S(   N(   t   lenR   (   R$   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyt   __len__ˆ   s    c         C   s   |  i  | } t i | ƒ S(   N(   R   R    t   loads(   R$   t   keyt   data(    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyt   __getitem__Œ   s    c         C   s#   t  | |  i ƒ } | |  i | <d  S(   N(   R   R   R   (   R$   R.   t   valueR/   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyt   __setitem__‘   s    c         C   s   |  i  | =d  S(   N(   R   (   R$   R.   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyt   __delitem__–   s    c         C   s/   | d  j o |  i i | ƒ S|  i i ƒ  Sd  S(   N(   t   NoneR   t   keys(   R$   t   txn(    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyR5   š   s    c         O   s    |  i  i | | Ž  t |  _ d  S(   N(   R   R   t   FalseR"   (   R$   t   argst   kwargs(    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyR   ¡   s    c         O   s    |  i  i | | Ž  t |  _ d  S(   N(   R   R&   R!   R"   (   R$   R8   R9   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyR&   ¦   s    c         C   s3   |  i  o d t |  ƒ St t |  i ƒ  ƒ ƒ Sd  S(   Ns   <DBShelf @ 0x%x - closed>(   R"   t   idt   reprt   dictt	   iteritems(   R$   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyt   __repr__«   s    
c         C   so   | d  j o |  i i | ƒ } n |  i i ƒ  } g  } x0 | D]( \ } } | i | t i | ƒ f ƒ q? W| S(   N(   R4   R   t   itemst   appendR    R-   (   R$   R6   R?   t   newitemst   kt   v(    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyR?   ²   s      c         C   sB   | d  j o |  i i | ƒ } n |  i i ƒ  } t t i | ƒ S(   N(   R4   R   t   valuest   mapR    R-   (   R$   R6   RD   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyRD   ½   s    c         C   s%   t  | |  i ƒ } |  i i | | ƒ S(   N(   R   R   R   R@   (   R$   R1   R6   R/   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyt   __appendÈ   s    c         C   s7   |  i  ƒ  t i j o |  i | d | ƒSt d ‚ d  S(   NR6   sO   append() only supported when dbshelve opened with filetype=dbshelve.db.DB_RECNO(   t   get_typeR   t   DB_RECNOt   _DBShelf__appendR   (   R$   R1   R6   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyR@   Ì   s    i    c         C   s"   | d „ } |  i  i | | | ƒ S(   Nc         S   s\   t  i d d j  p t | t ƒ o t i | ƒ } n t i t | d ƒ ƒ } | |  | ƒ S(   Ni    i   s	   iso8859-1(   t   syst   version_infot
   isinstancet   bytesR    R-   (   t   priKeyt   priDatat   realCallbackR/   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyt   _shelf_callbackÓ   s    $(   R   t	   associate(   R$   t   secondaryDBt   callbackR   RQ   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyRR   Ò   s    c         O   sP   t  |  i i | | ƒ } y t i | ƒ SWn  t t t i f j
 o | SXd  S(   N(   t   applyR   t   getR    R-   t   EOFErrort	   TypeErrort   UnpicklingError(   R$   R8   t   kwR/   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyRV   ß   s
    c         C   s:   t  | |  i ƒ } |  i i | | | | ƒ } t i | ƒ S(   N(   R   R   R   RV   R    R-   (   R$   R.   R1   R6   R   R/   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyt   get_bothë   s    c         C   s+   t  |  i i | | ƒ ƒ } |  i | _ | S(   N(   t   DBShelfCursorR   t   cursorR   (   R$   R6   R   R   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyR]   ñ   s    c         C   s+   t  | |  i ƒ } |  i i | | | | ƒ S(   N(   R   R   R   t   put(   R$   R.   R1   R6   R   R/   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyR^   ÷   s    c         C   s
   t  ‚ d  S(   N(   t   NotImplementedError(   R$   t
   cursorListR   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyt   joinü   s    N(   R   R   t   __doc__R4   R%   R'   R*   R,   R0   R2   R3   R5   R   R&   R>   R?   RD   RI   R@   RR   RV   R[   R]   R^   Ra   (    (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyR   m   s,   			
								R\   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$   R]   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyR%     s    c         C   s   |  i  ƒ  d  S(   N(   R&   (   R$   (    (    s$   /usr/lib/python2.6/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(   Rc   (   R$   R)   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyR*     s    i    c         C   s(   t  |  i i | ƒ ƒ } |  i | _ | S(   N(   R\   Rc   t   dupR   (   R$   R   R   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyRd     s    c         C   s(   t  | |  i ƒ } |  i i | | | ƒ S(   N(   R   R   Rc   R^   (   R$   R.   R1   R   R/   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyR^   !  s    c         G   s0   t  | ƒ } t |  d | ƒ } t | | ƒ d  S(   Ns   get_%d(   R+   R(   RU   (   R$   R8   t   countt   method(    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyRV   &  s    c         C   s   |  i  i | ƒ } |  i | ƒ S(   N(   Rc   RV   t   _extract(   R$   R   t   rec(    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyt   get_1+  s    c         C   s"   |  i  i | | ƒ } |  i | ƒ S(   N(   Rc   RV   Rg   (   R$   R.   R   Rh   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyt   get_2/  s    c         C   s4   t  | |  i ƒ } |  i i | | ƒ } |  i | ƒ S(   N(   R   R   Rc   RV   Rg   (   R$   R.   R1   R   R/   Rh   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyt   get_33  s    c         C   s   |  i  | t i Bƒ S(   N(   Ri   R   t
   DB_CURRENT(   R$   R   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyt   current9  s    c         C   s   |  i  | t i Bƒ S(   N(   Ri   R   t   DB_FIRST(   R$   R   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyt   first:  s    c         C   s   |  i  | t i Bƒ S(   N(   Ri   R   t   DB_LAST(   R$   R   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyt   last;  s    c         C   s   |  i  | t i Bƒ S(   N(   Ri   R   t   DB_NEXT(   R$   R   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyt   next<  s    c         C   s   |  i  | t i Bƒ S(   N(   Ri   R   t   DB_PREV(   R$   R   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyt   prev=  s    c         C   s   |  i  | t i Bƒ S(   N(   Ri   R   t
   DB_CONSUME(   R$   R   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyt   consume>  s    c         C   s   |  i  | t i Bƒ S(   N(   Ri   R   t   DB_NEXT_DUP(   R$   R   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyt   next_dup?  s    c         C   s   |  i  | t i Bƒ S(   N(   Ri   R   t   DB_NEXT_NODUP(   R$   R   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyt
   next_nodup@  s    c         C   s   |  i  | t i Bƒ S(   N(   Ri   R   t   DB_PREV_NODUP(   R$   R   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyt
   prev_nodupA  s    c         C   s4   t  | |  i ƒ } |  i i | | ƒ } |  i | ƒ S(   N(   R   R   Rc   R[   Rg   (   R$   R.   R1   R   R/   Rh   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyR[   D  s    c         C   s"   |  i  i | | ƒ } |  i | ƒ S(   N(   Rc   t   setRg   (   R$   R.   R   Rh   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyR~   J  s    c         C   s"   |  i  i | | ƒ } |  i | ƒ S(   N(   Rc   t	   set_rangeRg   (   R$   R.   R   Rh   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyR   N  s    c         C   s"   |  i  i | | ƒ } |  i | ƒ S(   N(   Rc   t	   set_recnoRg   (   R$   t   recnoR   Rh   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyR€   R  s    c         C   sv   | d  j o d  S| \ } } t i d d j  p t | t ƒ o | t i | ƒ f S| t i t | d ƒ ƒ f Sd  S(   Ni    i   s	   iso8859-1(   R4   RJ   RK   RL   RM   R    R-   (   R$   Rh   R.   R/   (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyRg   X  s    $(   R   R   Rb   R%   R'   R*   Rd   R^   RV   Ri   Rj   Rk   Rm   Ro   Rq   Rs   Ru   Rw   Ry   R{   R}   R[   R~   R   R€   t   set_bothRg   (    (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyR\   
  s2   							(   i   i   i    (   i   i   i    (    (    (   Rb   R    RJ   RK   t   absolute_importR   R#   R   R4   t   UserDictR   t   ImportErrorR   t   DB_HASHR   R   R   R   R\   (    (    (    s$   /usr/lib/python2.6/bsddb/dbshelve.pyt   <module>   s.   		"