Ñò
•à"Ic           @   s  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 e i d d !d j oG y d d k	 l
 Z
 Wn& e j
 o d d d „  ƒ  YZ
 n Xe
 Z n d d k Z e i 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ÿÿÿÿNi    i   s   from . import dbi   i   c         C   s   t  i |  | ƒ S(   N(   t   cPicklet   dumps(   t   objectt   protocol(    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyt   _dumps2   s    c         C   s   t  i |  d | ƒS(   NR   (   R    R   (   R   R   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyR   5   s    c         C   s   t  i |  d | ƒS(   Nt   bin(   R    R   (   R   R   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyR   :   s    i   (   t	   DictMixinR   c           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyR   C   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+   /mit/python/lib/python2.6/bsddb/dbshelve.pyR   L   s     
t   DBShelveErrorc           B   s   e  Z RS(    (   R   R   (    (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyR   o   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 e i d	 d
 !d j o d „  Z n 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+   /mit/python/lib/python2.6/bsddb/dbshelve.pyt   __init__v   s
    	c         C   s   |  i  ƒ  d  S(   N(   t   close(   R$   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyt   __del__   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+   /mit/python/lib/python2.6/bsddb/dbshelve.pyt   __getattr__ƒ   s    c         C   s   t  |  i ƒ S(   N(   t   lenR   (   R$   (    (    s+   /mit/python/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+   /mit/python/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+   /mit/python/lib/python2.6/bsddb/dbshelve.pyt   __setitem__–   s    c         C   s   |  i  | =d  S(   N(   R   (   R$   R.   (    (    s+   /mit/python/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+   /mit/python/lib/python2.6/bsddb/dbshelve.pyR5   Ÿ   s    i    i   i   c         C   s   |  i  i ƒ  S(   N(   R   t   __iter__(   R$   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyR7   ¦   s    c         O   s    |  i  i | | Ž  t |  _ d  S(   N(   R   R   t   FalseR"   (   R$   t   argst   kwargs(    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyR   ª   s    c         O   s    |  i  i | | Ž  t |  _ d  S(   N(   R   R&   R!   R"   (   R$   R9   R:   (    (    s+   /mit/python/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+   /mit/python/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+   /mit/python/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   RE   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyRE   Æ   s    c         C   s%   t  | |  i ƒ } |  i i | | ƒ S(   N(   R   R   R   RA   (   R$   R1   R6   R/   (    (    s+   /mit/python/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+   /mit/python/lib/python2.6/bsddb/dbshelve.pyRA   Õ   s    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+   /mit/python/lib/python2.6/bsddb/dbshelve.pyt   _shelf_callbackÜ   s    $(   R   t	   associate(   R$   t   secondaryDBt   callbackR   RR   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyRS   Û   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$   R9   t   kwR/   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyRW   è   s
    c         C   s:   t  | |  i ƒ } |  i i | | | | ƒ } t i | ƒ S(   N(   R   R   R   RW   R    R-   (   R$   R.   R1   R6   R   R/   (    (    s+   /mit/python/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+   /mit/python/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+   /mit/python/lib/python2.6/bsddb/dbshelve.pyR_      s    c         C   s
   t  ‚ d  S(   N(   t   NotImplementedError(   R$   t
   cursorListR   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyt   join  s    N(   i   i   (   R   R   t   __doc__R4   R%   R'   R*   R,   R0   R2   R3   R5   RK   RL   R7   R   R&   R?   R@   RE   RJ   RA   RS   RW   R\   R^   R_   Rb   (    (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyR   r   s0   			
								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+   /mit/python/lib/python2.6/bsddb/dbshelve.pyR%     s    c         C   s   |  i  ƒ  d  S(   N(   R&   (   R$   (    (    s+   /mit/python/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(   Rd   (   R$   R)   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyR*     s    i    c         C   s(   t  |  i i | ƒ ƒ } |  i | _ | S(   N(   R]   Rd   t   dupR   (   R$   R   R   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyRe   $  s    c         C   s(   t  | |  i ƒ } |  i i | | | ƒ S(   N(   R   R   Rd   R_   (   R$   R.   R1   R   R/   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyR_   *  s    c         G   s0   t  | ƒ } t |  d | ƒ } t | | ƒ d  S(   Ns   get_%d(   R+   R(   RV   (   R$   R9   t   countt   method(    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyRW   /  s    c         C   s   |  i  i | ƒ } |  i | ƒ S(   N(   Rd   RW   t   _extract(   R$   R   t   rec(    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyt   get_14  s    c         C   s"   |  i  i | | ƒ } |  i | ƒ S(   N(   Rd   RW   Rh   (   R$   R.   R   Ri   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyt   get_28  s    c         C   s4   t  | |  i ƒ } |  i i | | ƒ } |  i | ƒ S(   N(   R   R   Rd   RW   Rh   (   R$   R.   R1   R   R/   Ri   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyt   get_3<  s    c         C   s   |  i  | t i Bƒ S(   N(   Rj   R   t
   DB_CURRENT(   R$   R   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyt   currentB  s    c         C   s   |  i  | t i Bƒ S(   N(   Rj   R   t   DB_FIRST(   R$   R   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyt   firstC  s    c         C   s   |  i  | t i Bƒ S(   N(   Rj   R   t   DB_LAST(   R$   R   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyt   lastD  s    c         C   s   |  i  | t i Bƒ S(   N(   Rj   R   t   DB_NEXT(   R$   R   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyt   nextE  s    c         C   s   |  i  | t i Bƒ S(   N(   Rj   R   t   DB_PREV(   R$   R   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyt   prevF  s    c         C   s   |  i  | t i Bƒ S(   N(   Rj   R   t
   DB_CONSUME(   R$   R   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyt   consumeG  s    c         C   s   |  i  | t i Bƒ S(   N(   Rj   R   t   DB_NEXT_DUP(   R$   R   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyt   next_dupH  s    c         C   s   |  i  | t i Bƒ S(   N(   Rj   R   t   DB_NEXT_NODUP(   R$   R   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyt
   next_nodupI  s    c         C   s   |  i  | t i Bƒ S(   N(   Rj   R   t   DB_PREV_NODUP(   R$   R   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyt
   prev_nodupJ  s    c         C   s4   t  | |  i ƒ } |  i i | | ƒ } |  i | ƒ S(   N(   R   R   Rd   R\   Rh   (   R$   R.   R1   R   R/   Ri   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyR\   M  s    c         C   s"   |  i  i | | ƒ } |  i | ƒ S(   N(   Rd   t   setRh   (   R$   R.   R   Ri   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyR   S  s    c         C   s"   |  i  i | | ƒ } |  i | ƒ S(   N(   Rd   t	   set_rangeRh   (   R$   R.   R   Ri   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyR€   W  s    c         C   s"   |  i  i | | ƒ } |  i | ƒ S(   N(   Rd   t	   set_recnoRh   (   R$   t   recnoR   Ri   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyR   [  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   RK   RL   RM   RN   R    R-   (   R$   Ri   R.   R/   (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyRh   a  s    $(   R   R   Rc   R%   R'   R*   Re   R_   RW   Rj   Rk   Rl   Rn   Rp   Rr   Rt   Rv   Rx   Rz   R|   R~   R\   R   R€   R   t   set_bothRh   (    (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyR]     s2   							(   i   i   i    (   i   i   i    (   i   i   (    (    (   Rc   R    RK   RL   t   absolute_importR   R#   R   R4   t   UserDictR   t   ImportErrort   MutableMappingt   collectionsR   t   DB_HASHR   R   R   R   R]   (    (    (    s+   /mit/python/lib/python2.6/bsddb/dbshelve.pyt   <module>   s6   		
	"¡