Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/bsddb/
Upload File :
Current File : //usr/lib/python2.7/bsddb/dbshelve.pyc


|_c@sdZddlZejddkZer6ddUnddlZejddkrdddlZnzejdkrddlZn\ddlZejZej	z)ej
dd	d
deddlZWdejX[ejdkrej
Z
ejdkrd
Zq,dZndZ
dZejdkryddlmZWn$ek
rudddYZnXeZnddlZejZejdejdddZdejfdYZdefdYZdd dYZdS(!sNManage shelves of pickled objects using bsddb database files for the
storage.
iNiisfrom . import dbiitignoretmessages1the cPickle module has been removed in Python 3.0tcategoryicCstj||S(N(tcPickletdumps(tobjecttprotocol((s$/usr/lib/python2.7/bsddb/dbshelve.pyt_dumpsKscCstj|d|S(NR(RR(RR((s$/usr/lib/python2.7/bsddb/dbshelve.pyRNscCstj|d|S(Ntbin(RR(RR((s$/usr/lib/python2.7/bsddb/dbshelve.pyRSs(t	DictMixinR	cBseZRS((t__name__t
__module__(((s$/usr/lib/python2.7/bsddb/dbshelve.pyR	\sicCst|tdkr|}|dkr6tj}q|dkrKd}q|dkrctj}q|dkr{tj}q|dkrtjtjB}qtjdnt|}|j||||||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()
    ttrtrwitwtctnsJflags should be one of 'r', 'w', 'c' or 'n' or use the bsddb.db.DB_* flags(ttypetdbt	DB_RDONLYt	DB_CREATEtDB_TRUNCATEtDBErrortDBShelftopen(tfilenametflagstmodetfiletypetdbenvtdbnametsflagtd((s$/usr/lib/python2.7/bsddb/dbshelve.pyRes 	t
DBShelveErrorcBseZRS((R
R(((s$/usr/lib/python2.7/bsddb/dbshelve.pyR"sRcBseZdZddZdZdZdZdZdZ	dZ
ddZej
dkrudZndZd
ZdZddZddZddZddZddZdZdddZdddZdddZddZRS(sA shelf to hold pickled objects, built upon a bsddb DB object.  It
    automatically pickles/unpickles data objects going to/from the DB.
    cCs:tj||_t|_tr-t|_n	d|_dS(Ni(RtDBtTruet_closedtHIGHEST_PROTOCOLR(tselfR((s$/usr/lib/python2.7/bsddb/dbshelve.pyt__init__s
	cCs|jdS(N(tclose(R'((s$/usr/lib/python2.7/bsddb/dbshelve.pyt__del__scCst|j|S(sTMany methods we can just pass through to the DB object.
        (See below)
        (tgetattrR(R'tname((s$/usr/lib/python2.7/bsddb/dbshelve.pyt__getattr__scCs
t|jS(N(tlenR(R'((s$/usr/lib/python2.7/bsddb/dbshelve.pyt__len__scCs|j|}tj|S(N(RRtloads(R'tkeytdata((s$/usr/lib/python2.7/bsddb/dbshelve.pyt__getitem__s
cCs#t||j}||j|<dS(N(RRR(R'R1tvalueR2((s$/usr/lib/python2.7/bsddb/dbshelve.pyt__setitem__scCs|j|=dS(N(R(R'R1((s$/usr/lib/python2.7/bsddb/dbshelve.pyt__delitem__scCs-|dk	r|jj|S|jjSdS(N(tNoneRtkeys(R'ttxn((s$/usr/lib/python2.7/bsddb/dbshelve.pyR8siiccs#x|jjD]}|VqWdS(N(RR8(R'tk((s$/usr/lib/python2.7/bsddb/dbshelve.pyt__iter__scOs |jj||t|_dS(N(RRtFalseR%(R'targstkwargs((s$/usr/lib/python2.7/bsddb/dbshelve.pyRscOs |jj||t|_dS(N(RR)R$R%(R'R=R>((s$/usr/lib/python2.7/bsddb/dbshelve.pyR)scCs1|jrdt|Stt|jSdS(Ns<DBShelf @ 0x%x - closed>(R%tidtreprtdictt	iteritems(R'((s$/usr/lib/python2.7/bsddb/dbshelve.pyt__repr__s	cCsm|dk	r!|jj|}n|jj}g}x0|D](\}}|j|tj|fq=W|S(N(R7RtitemstappendRR0(R'R9RDtnewitemsR:tv((s$/usr/lib/python2.7/bsddb/dbshelve.pyRDs cCs@|dk	r!|jj|}n|jj}ttj|S(N(R7RtvaluestmapRR0(R'R9RH((s$/usr/lib/python2.7/bsddb/dbshelve.pyRHscCs%t||j}|jj||S(N(RRRRE(R'R4R9R2((s$/usr/lib/python2.7/bsddb/dbshelve.pyt__appendscCs5|jtjkr(|j|d|StddS(NR9sOappend() only supported when dbshelve opened with filetype=dbshelve.db.DB_RECNO(tget_typeRtDB_RECNOt_DBShelf__appendR"(R'R4R9((s$/usr/lib/python2.7/bsddb/dbshelve.pyREsicCs"|d}|jj|||S(NcSsYtjddks"t|tr4tj|}ntjt|d}|||S(Niis	iso8859-1(tsystversion_infot
isinstancetbytesRR0(tpriKeytpriDatatrealCallbackR2((s$/usr/lib/python2.7/bsddb/dbshelve.pyt_shelf_callbacks"(Rt	associate(R'tsecondaryDBtcallbackRRU((s$/usr/lib/python2.7/bsddb/dbshelve.pyRVscOsK|jj||}ytj|SWntttjfk
rF|SXdS(N(RtgetRR0tEOFErrort	TypeErrortUnpicklingError(R'R=tkwR2((s$/usr/lib/python2.7/bsddb/dbshelve.pyRYs
cCs:t||j}|jj||||}tj|S(N(RRRRYRR0(R'R1R4R9RR2((s$/usr/lib/python2.7/bsddb/dbshelve.pytget_bothscCs+t|jj||}|j|_|S(N(t
DBShelfCursorRtcursorR(R'R9RR((s$/usr/lib/python2.7/bsddb/dbshelve.pyR`scCs+t||j}|jj||||S(N(RRRtput(R'R1R4R9RR2((s$/usr/lib/python2.7/bsddb/dbshelve.pyRa scCs
tdS(N(tNotImplementedError(R't
cursorListR((s$/usr/lib/python2.7/bsddb/dbshelve.pytjoin%sN(ii(R
Rt__doc__R7R(R*R-R/R3R5R6R8RNROR;RR)RCRDRHRMRERVRYR^R`RaRd(((s$/usr/lib/python2.7/bsddb/dbshelve.pyRs0			
							
	R_cBseZdZdZdZdZddZddZdZdZ	d	Z
d
ZddZddZ
dd
ZddZddZddZddZddZddZddZddZddZddZeZdZRS(s
    cCs
||_dS(N(tdbc(R'R`((s$/usr/lib/python2.7/bsddb/dbshelve.pyR(6scCs|jdS(N(R)(R'((s$/usr/lib/python2.7/bsddb/dbshelve.pyR*9scCst|j|S(sHSome methods we can just pass through to the cursor object.  (See below)(R+Rf(R'R,((s$/usr/lib/python2.7/bsddb/dbshelve.pyR-=sicCs(t|jj|}|j|_|S(N(R_RftdupR(R'RR((s$/usr/lib/python2.7/bsddb/dbshelve.pyRgDscCs(t||j}|jj|||S(N(RRRfRa(R'R1R4RR2((s$/usr/lib/python2.7/bsddb/dbshelve.pyRaJscGs-t|}t|d|}||dS(Nsget_%d(R.R+(R'R=tcounttmethod((s$/usr/lib/python2.7/bsddb/dbshelve.pyRYOscCs|jj|}|j|S(N(RfRYt_extract(R'Rtrec((s$/usr/lib/python2.7/bsddb/dbshelve.pytget_1TscCs"|jj||}|j|S(N(RfRYRj(R'R1RRk((s$/usr/lib/python2.7/bsddb/dbshelve.pytget_2XscCs4t||j}|jj||}|j|S(N(RRRfRYRj(R'R1R4RR2Rk((s$/usr/lib/python2.7/bsddb/dbshelve.pytget_3\scCs|j|tjBS(N(RlRt
DB_CURRENT(R'R((s$/usr/lib/python2.7/bsddb/dbshelve.pytcurrentbscCs|j|tjBS(N(RlRtDB_FIRST(R'R((s$/usr/lib/python2.7/bsddb/dbshelve.pytfirstcscCs|j|tjBS(N(RlRtDB_LAST(R'R((s$/usr/lib/python2.7/bsddb/dbshelve.pytlastdscCs|j|tjBS(N(RlRtDB_NEXT(R'R((s$/usr/lib/python2.7/bsddb/dbshelve.pytnextescCs|j|tjBS(N(RlRtDB_PREV(R'R((s$/usr/lib/python2.7/bsddb/dbshelve.pytprevfscCs|j|tjBS(N(RlRt
DB_CONSUME(R'R((s$/usr/lib/python2.7/bsddb/dbshelve.pytconsumegscCs|j|tjBS(N(RlRtDB_NEXT_DUP(R'R((s$/usr/lib/python2.7/bsddb/dbshelve.pytnext_duphscCs|j|tjBS(N(RlRt
DB_NEXT_NODUP(R'R((s$/usr/lib/python2.7/bsddb/dbshelve.pyt
next_nodupiscCs|j|tjBS(N(RlRt
DB_PREV_NODUP(R'R((s$/usr/lib/python2.7/bsddb/dbshelve.pyt
prev_nodupjscCs4t||j}|jj||}|j|S(N(RRRfR^Rj(R'R1R4RR2Rk((s$/usr/lib/python2.7/bsddb/dbshelve.pyR^mscCs"|jj||}|j|S(N(RftsetRj(R'R1RRk((s$/usr/lib/python2.7/bsddb/dbshelve.pyRsscCs"|jj||}|j|S(N(Rft	set_rangeRj(R'R1RRk((s$/usr/lib/python2.7/bsddb/dbshelve.pyRwscCs"|jj||}|j|S(N(Rft	set_recnoRj(R'trecnoRRk((s$/usr/lib/python2.7/bsddb/dbshelve.pyR{scCsq|dkrdS|\}}tjddks>t|trQ|tj|fS|tjt|dfSdS(Niis	iso8859-1(R7RNRORPRQRR0(R'RkR1R2((s$/usr/lib/python2.7/bsddb/dbshelve.pyRjs"(R
RReR(R*R-RgRaRYRlRmRnRpRrRtRvRxRzR|R~RR^RRRtset_bothRj(((s$/usr/lib/python2.7/bsddb/dbshelve.pyR_3s2							(ii(ii(ii(ii(((ReRNROtabsolute_importRRtwarningstcatch_warningsRt	__enter__tfilterwarningstDeprecationWarningt__exit__R&RR7tUserDictR	tImportErrortMutableMappingtcollectionsRtDB_HASHRRR"RR_(((s$/usr/lib/python2.7/bsddb/dbshelve.pyt<module>sN
		
		"