�`^c@s}dZddlZejddkZejdkr�ejdkr�ddlZejrzedkrzejded�nej d d
ed�nybedkr�er�ddUnddl
Z
e
Zdd
lm
ZnddlZdd
lm
ZWn*ek
r!ddlZeje=�nXeZZejZejZddlZddlZddlmZejdkr�ddlZejZnddlZejZdefd��YZdefd��YZddddddddd�Z!ddddddddd�Z"ddddddddddd�Z#d�Z$d�Z%yddl&Z'['Wnek
rxde_(nXdS(s�Support for Berkeley DB 4.3 through 5.3 with a simple interface.
For the full featured object oriented interface use the bsddb.db module
instead. It mirrors the Oracle Berkeley DB C API.
i�Niiiitbsddb3sQin 3.x, the bsddb module has been removed; please use the pybsddb project insteadtignores.*CObject.*sbsddb.__init__sfrom . import _pybsddb(tDeadlockWrap(treft_iter_mixincBs,eZd�Zd�Zd�Zd�ZRS(cCsAt|jj�}t|�}t||j|��|j|<|S(N(t
_DeadlockWraptdbtcursortidRt_gen_cref_cleanert_cursor_refs(tselftcurtkey((s$/sys/lib/python2.7/bsddb/__init__.pyt_make_iter_cursor_scs��fd�S(Ncs�jj�d�S(N(R
tpoptNone(R(R
R(s$/sys/lib/python2.7/bsddb/__init__.pyt<lambda>is((RR
((R
Rs$/sys/lib/python2.7/bsddb/__init__.pyR esccs@t|_|jd7_y�|j�}t|jddd�d}|Vt|d�}x�y"t|ddd�d}|VWq]tjk
r�|jr�t d��n|j�}t|j
|ddd�t|d�}q]Xq]Wn'tjk
r�ntjk
rnXWn|jd8_�nX|jd8_dS(Niitnexts'Database changed size during iteration.(tFalset_kill_iterationt_in_iterRRtfirsttgetattrt_bsddbtDBCursorClosedErrortRuntimeErrortsettDBNotFoundError(RRR
R((s$/sys/lib/python2.7/bsddb/__init__.pyt__iter__ks4 ccsG|js
dSt|_|jd7_y�|j�}t|j�}|d}|Vt|d�}x�yt|�}|d}|VWqgtj k
r�|jr�t
d��n|j�}t|j|ddd�t|d�}qgXqgWn'tjk
rntj k
rnXWn|jd8_�nX|jd8_dS(NiiRs'Database changed size during iteration.(
RRRRRRRRRRRRR(RRtkvR
R((s$/sys/lib/python2.7/bsddb/__init__.pyt iteritems�s<
(t__name__t
__module__RR RR(((s$/sys/lib/python2.7/bsddb/__init__.pyR^s )t
_DBWithCursorcBs�eZdZd�Zd�Zd�Zdd�Zd�Zd�Zd�Z e
jdkrid�Znd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Ze
jddkr�eZnd�Zd�Zd�Zd�ZRS(s�
A simple wrapper around DB that makes it look like the bsddbobject in
the old module. It uses a cursor as needed to provide DB traversal.
cCsJ||_|jjd�d|_d|_i|_d|_t|_dS(Ni( Rtset_get_returns_noneRtdbct
saved_dbc_keyR
RRR(RR((s$/sys/lib/python2.7/bsddb/__init__.pyt__init__�s
cCs|j�dS(N(tclose(R((s$/sys/lib/python2.7/bsddb/__init__.pyt__del__�scCs\|jdkrXt|jj�|_|jdk rXt|jj|j�d|_qXndS(N(R$RRRRR%R(R((s$/sys/lib/python2.7/bsddb/__init__.pyt_checkCursor�s
icCs�|jrq|j}d|_|r^y#t|jddd�d|_Wq^tjk
rZq^Xnt|j�~nx<|jj �D]+}|�}|dk r�t|j�q�q�WdS(Ni(
R$RRtcurrentR%RtDBErrorR'R
tvalues(Rtsavetctcref((s$/sys/lib/python2.7/bsddb/__init__.pyt
_closeCursors�s #
cCs|jdkrtd�ndS(Ns$BSDDB object has already been closed(RRterror(R((s$/sys/lib/python2.7/bsddb/__init__.pyt
_checkOpen�scCs
|jdk S(N(RR(R((s$/sys/lib/python2.7/bsddb/__init__.pytisOpen�scs�j�t�fd��S(Ncs
t�j�S(N(tlenR((R(s$/sys/lib/python2.7/bsddb/__init__.pyRs(R2R(R((Rs$/sys/lib/python2.7/bsddb/__init__.pyt__len__s
iicCs5|j�r(ttt|jj���Stt��S(N(R3treprtdictRRtitems(R((s$/sys/lib/python2.7/bsddb/__init__.pyt__repr__scs �j�t��fd��S(Ncs�j�S(N(R((R
R(s$/sys/lib/python2.7/bsddb/__init__.pyRs(R2R(RR
((R
Rs$/sys/lib/python2.7/bsddb/__init__.pyt__getitem__s
csX�j��j��jr5��kr5t�_n���fd�}t|�dS(Ncs��j�<dS(N(R((R
Rtvalue(s$/sys/lib/python2.7/bsddb/__init__.pytwrapFs(R2R0RtTrueRR(RR
R;R<((R
RR;s$/sys/lib/python2.7/bsddb/__init__.pyt__setitem__s
csU�j��j��jr5��kr5t�_n��fd�}t|�dS(Ncs�j�=dS(N(R((R
R(s$/sys/lib/python2.7/bsddb/__init__.pyR<s(R2R0RR=RR(RR
R<((R
Rs$/sys/lib/python2.7/bsddb/__init__.pyt__delitem__s
cCsr|jdd�|jdk r2t|jj�nd}|jdk r\t|jj�}nd|_d|_|S(NR-i(R0R$RRR'R(Rtv((s$/sys/lib/python2.7/bsddb/__init__.pyR'"s cCs|j�t|jj�S(N(R2RRtkeys(R((s$/sys/lib/python2.7/bsddb/__init__.pyRA-s
cCs|j�t|jj|�S(N(R2RRthas_key(RR
((s$/sys/lib/python2.7/bsddb/__init__.pyRB1s
cCs'|j�|j�t|jj|�S(N(R2R)RR$t set_range(RR
((s$/sys/lib/python2.7/bsddb/__init__.pytset_location5s
cCs0|j�|j�tt|jd��}|S(NR(R2R)RRR$(Rtrv((s$/sys/lib/python2.7/bsddb/__init__.pyR:s
iicCs*|j�|j�t|jj�}|S(N(R2R)RR$tprev(RRE((s$/sys/lib/python2.7/bsddb/__init__.pytpreviousCs
cCs3|j�d|_|j�t|jj�}|S(N(R2RR%R)RR$R(RRE((s$/sys/lib/python2.7/bsddb/__init__.pyRIs
cCs3|j�d|_|j�t|jj�}|S(N(R2RR%R)RR$tlast(RRE((s$/sys/lib/python2.7/bsddb/__init__.pyRHQs
cCs|j�t|jj�S(N(R2RRtsync(R((s$/sys/lib/python2.7/bsddb/__init__.pyRIYs
(ii(R R!t__doc__R&R(R)R0R2R3R5tsystversion_infoR9R:R>R?R'RARBRDRt__next__RGRRHRI(((s$/sys/lib/python2.7/bsddb/__init__.pyR"�s0 R.i�c Cs�t||�} t|�}
tj|
�}|j|�|dk rS|j|�n|dk ro|j|�n|dk r�|j|�n|dk r�|j |�n|j
|tj| |�t|�S(N(
t
_checkflagt
_openDBEnvRtDBt set_flagsRtset_pagesizet
set_lordert
set_h_ffactortset_h_nelemtopentDB_HASHR"(tfiletflagtmodetpgsizetffactortnelemt cachesizetlorderthflagstflagstetd((s$/sys/lib/python2.7/bsddb/__init__.pythashopenas
c Cs�t||�} t|�}
tj|
�}|dk rF|j|�n|dk rb|j|�n|j|�|dk r�|j|�n|dk r�|j |�n|j
|tj| |�t|�S(N(
RNRORRPRRRRSRQt
set_bt_minkeyt
set_bt_maxkeyRVtDB_BTREER"(RXRYRZtbtflagsR^t
maxkeypaget
minkeypageR[R_RaRbRc((s$/sys/lib/python2.7/bsddb/__init__.pytbtopenqs
cCst||�}t|�}tj|�}
|dk rF|
j|�n|dk rb|
j|�n|
j|�|dk r�|
j|�n|dk r�|
j |�n| dk r�|
j
| �n|
dk r�|
j|
�n|
j|tj
||�t|
�S(N(RNRORRPRRRRSRQtset_re_delimt
set_re_lent
set_re_sourcet
set_re_padRVtDB_RECNOR"(RXRYRZtrnflagsR^R[R_trlentdelimtsourcetpadRaRbRc((s$/sys/lib/python2.7/bsddb/__init__.pytrnopen�s$
cCs�tj�}|dk rC|dkr7|jd|�qCtd�n|jtj�|jdtjtj Btj
BtjBtjB�|S(NiPiscachesize must be >= 20480t.(
RtDBEnvRt
set_cachesizeR1t
set_lk_detecttDB_LOCK_DEFAULTRVt
DB_PRIVATEt DB_CREATEt DB_THREADtDB_INIT_LOCKt
DB_INIT_MPOOL(R^Rb((s$/sys/lib/python2.7/bsddb/__init__.pyRO�s/cCs�|dkrtj}n�|dkr-d}n|dkrEtj}ng|dkr]tj}nO|dkr�tj}|dk r�tjj|�r�tj|�q�n td�|tj BS(NtrtrwitwR.tns+flags should be one of 'r', 'w', 'c' or 'n'(
Rt DB_RDONLYR}RtostpathtisfiletunlinkR1R~(RYRXRa((s$/sys/lib/python2.7/bsddb/__init__.pyRN�s (ii(ii(ii()RJRKRLtabsolute_importtwarningstpy3kwarningR twarnpy3ktDeprecationWarningtfilterwarningst_pybsddbRtbsddb3.dbutilsRRt
bsddb.dbutilstImportErrortmodulesRt_dbt__version__R+R1R�tweakrefRtUserDictt DictMixintMutableMappingtcollectionsRR"RRdRkRvRORNtthreadtTR~(((s$/sys/lib/python2.7/bsddb/__init__.pyt<module>(sb
b�
|