ó {fc@s‹dZddlZejddkZer6ddUn ddlZejddkrdddlZnzejdkr‚ddlZn\ddlZejƒZej ƒz)ej dd d d e ƒddlZWdej ƒX[ej Z d „Zejdkrdd lmZnddlZejZejdejddd„Zdejfd„ƒYZdefd„ƒYZddd„ƒYZdS(sNManage shelves of pickled objects using bsddb database files for the storage. iÿÿÿÿNiisfrom . import dbiitignoretmessages1the cPickle module has been removed in Python 3.0tcategorycCstj|d|ƒS(Ntprotocol(tcPickletdumps(tobjectR((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt_dumpsDs(t DictMixini°cCsÒt|ƒtdƒkr©|}|dkr6tj}q©|dkrKd}q©|dkrctj}q©|dkr{tj}q©|dkrštjtjB}q©tjd‚nt|ƒ}|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_CREATEt DB_TRUNCATEtDBErrortDBShelftopen(tfilenametflagstmodetfiletypetdbenvtdbnametsflagtd((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRPs           t DBShelveErrorcBseZRS((t__name__t __module__(((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRssRcBseZdZdd„Zd„Zd„Zd„Zd„Zd„Z d„Z dd„Z e j dkrud „Znd „Zd „Zd„Zdd„Zdd„Zdd„Zdd„Zdd„Zd„Zddd„Zddd„Zddd„Zdd„ZRS(sŽA 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/lib64/python2.7/bsddb/dbshelve.pyt__init__zs   cCs|jƒdS(N(tclose(R&((s&/usr/lib64/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/lib64/python2.7/bsddb/dbshelve.pyt __getattr__‡scCs t|jƒS(N(tlenR(R&((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt__len__‘scCs|j|}tj|ƒS(N(RRtloads(R&tkeytdata((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt __getitem__•s cCs#t||jƒ}||j|(R$tidtreprtdictt iteritems(R&((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt__repr__¿s cCsm|dk r!|jj|ƒ}n|jjƒ}g}x0|D](\}}|j|tj|ƒfƒq=W|S(N(R6RtitemstappendRR/(R&R8RCtnewitemsR9tv((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRCÆs  cCs@|dk r!|jj|ƒ}n|jjƒ}ttj|ƒS(N(R6RtvaluestmapRR/(R&R8RG((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRGÑs cCs%t||jƒ}|jj||ƒS(N(RRRRD(R&R3R8R1((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt__appendÜscCs5|jƒtjkr(|j|d|ƒStd‚dS(NR8sOappend() only supported when dbshelve opened with filetype=dbshelve.db.DB_RECNO(tget_typeRtDB_RECNOt_DBShelf__appendR(R&R3R8((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRDàsicCs"|d„}|jj|||ƒS(NcSsYtjddks"t|tƒr4tj|ƒ}ntjt|dƒƒ}|||ƒS(Niis iso8859-1(tsyst version_infot isinstancetbytesRR/(tpriKeytpriDatat realCallbackR1((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt_shelf_callbackçs"(Rt associate(R&t secondaryDBtcallbackRRT((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRUæs cOsK|jj||Ž}ytj|ƒSWntttjfk rF|SXdS(N(RtgetRR/tEOFErrort TypeErrortUnpicklingError(R&R<tkwR1((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRXós cCs:t||jƒ}|jj||||ƒ}tj|ƒS(N(RRRRXRR/(R&R0R3R8RR1((s&/usr/lib64/python2.7/bsddb/dbshelve.pytget_bothÿscCs+t|jj||ƒƒ}|j|_|S(N(t DBShelfCursorRtcursorR(R&R8RR ((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR_s cCs+t||jƒ}|jj||||ƒS(N(RRRtput(R&R0R3R8RR1((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR` scCs t‚dS(N(tNotImplementedError(R&t cursorListR((s&/usr/lib64/python2.7/bsddb/dbshelve.pytjoinsN(ii(R R!t__doc__R6R'R)R,R.R2R4R5R7RMRNR:RR(RBRCRGRLRDRURXR]R_R`Rc(((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRvs0            R^cBseZdZd„Zd„Zd„Zdd„Zdd„Zd„Zd„Z d „Z d „Z dd „Z dd „Z dd „Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„ZeZd„ZRS(s cCs ||_dS(N(tdbc(R&R_((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR'!scCs|jƒdS(N(R((R&((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR)$scCst|j|ƒS(sHSome methods we can just pass through to the cursor object. (See below)(R*Re(R&R+((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR,(sicCs(t|jj|ƒƒ}|j|_|S(N(R^RetdupR(R&RR ((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRf/s cCs(t||jƒ}|jj|||ƒS(N(RRReR`(R&R0R3RR1((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR`5scGs-t|ƒ}t|d|ƒ}||ŒdS(Nsget_%d(R-R*(R&R<tcounttmethod((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRX:s cCs|jj|ƒ}|j|ƒS(N(ReRXt_extract(R&Rtrec((s&/usr/lib64/python2.7/bsddb/dbshelve.pytget_1?scCs"|jj||ƒ}|j|ƒS(N(ReRXRi(R&R0RRj((s&/usr/lib64/python2.7/bsddb/dbshelve.pytget_2CscCs4t||jƒ}|jj||ƒ}|j|ƒS(N(RRReRXRi(R&R0R3RR1Rj((s&/usr/lib64/python2.7/bsddb/dbshelve.pytget_3GscCs|j|tjBƒS(N(RkRt DB_CURRENT(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pytcurrentMR cCs|j|tjBƒS(N(RkRtDB_FIRST(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pytfirstNR cCs|j|tjBƒS(N(RkRtDB_LAST(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pytlastOR cCs|j|tjBƒS(N(RkRtDB_NEXT(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pytnextPR cCs|j|tjBƒS(N(RkRtDB_PREV(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pytprevQR cCs|j|tjBƒS(N(RkRt DB_CONSUME(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pytconsumeRR cCs|j|tjBƒS(N(RkRt DB_NEXT_DUP(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pytnext_dupSR cCs|j|tjBƒS(N(RkRt DB_NEXT_NODUP(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt next_nodupTR cCs|j|tjBƒS(N(RkRt DB_PREV_NODUP(R&R((s&/usr/lib64/python2.7/bsddb/dbshelve.pyt prev_nodupUR cCs4t||jƒ}|jj||ƒ}|j|ƒS(N(RRReR]Ri(R&R0R3RR1Rj((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR]XscCs"|jj||ƒ}|j|ƒS(N(RetsetRi(R&R0RRj((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR€^scCs"|jj||ƒ}|j|ƒS(N(Ret set_rangeRi(R&R0RRj((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRbscCs"|jj||ƒ}|j|ƒS(N(Ret set_recnoRi(R&trecnoRRj((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR‚fscCsq|dkrdS|\}}tjddks>t|tƒrQ|tj|ƒfS|tjt|dƒƒfSdS(Niis iso8859-1(R6RMRNRORPRR/(R&RjR0R1((s&/usr/lib64/python2.7/bsddb/dbshelve.pyRils   "(R R!RdR'R)R,RfR`RXRkRlRmRoRqRsRuRwRyR{R}RR]R€RR‚tset_bothRi(((s&/usr/lib64/python2.7/bsddb/dbshelve.pyR^s2                      (ii(ii((RdRMRNtabsolute_importRRtwarningstcatch_warningsR t __enter__tfilterwarningstDeprecationWarningt__exit__R%RtUserDictRtMutableMappingt collectionsRtDB_HASHR6RRRRR^(((s&/usr/lib64/python2.7/bsddb/dbshelve.pyts<            "¨