3 \C!@sddlmZmZddlmZddlZddddgZGdd d ejZGd ddejZ Gd dde Z Gd dde Z dddZ dS))Pickler Unpickler)BytesIONShelf BsdDbShelfDbfilenameShelfopenc@s4eZdZddZeZZZZZZ ddZ dS) _ClosedDictcGs tddS)Nz!invalid operation on closed shelf) ValueError)selfargsr /usr/lib64/python3.6/shelve.pyclosedEsz_ClosedDict.closedcCsdS)Nzr )r r r r__repr__Isz_ClosedDict.__repr__N) __name__ __module__ __qualname__r__iter____len__ __getitem__ __setitem__ __delitem__keysrr r r rr Bsr c@sxeZdZdddZddZdd Zd d Zdd d ZddZddZ ddZ ddZ ddZ ddZ ddZddZdS) rNFutf-8cCs.||_|dkrd}||_||_i|_||_dS)N)dict _protocol writebackcache keyencoding)r rprotocolrr r r r__init__TszShelf.__init__ccs&x |jjD]}|j|jVq WdS)N)rrdecoder )r kr r rr^szShelf.__iter__cCs t|jS)N)lenr)r r r rrbsz Shelf.__len__cCs|j|j|jkS)N)encoder r)r keyr r r __contains__eszShelf.__contains__cCs|j|j|jkr||S|S)N)r&r r)r r'defaultr r rgethsz Shelf.getc CsZy|j|}WnFtk rTt|j|j|j}t|j}|jrP||j|<YnX|S)N) rKeyErrorrrr&r rloadr)r r'valuefr r rrms zShelf.__getitem__cCsF|jr||j|<t}t||j}|j||j|j|j|j <dS)N) rrrrrdumpgetvaluerr&r )r r'r-r.pr r rrws    zShelf.__setitem__c Cs6|j|j|j=y |j|=Wntk r0YnXdS)N)rr&r rr+)r r'r r rrs  zShelf.__delitem__cCs|S)Nr )r r r r __enter__szShelf.__enter__cCs |jdS)N)close)r typer- tracebackr r r__exit__szShelf.__exit__cCsf|jdkrdSz0|jy|jjWntk r:YnXWdy t|_Wnd|_YnXXdS)N)rsyncr3AttributeErrorr )r r r rr3s   z Shelf.closecCst|dsdS|jdS)Nr)hasattrr3)r r r r__del__s z Shelf.__del__cCsX|jr>|jr>d|_x|jjD]\}}|||<qWd|_i|_t|jdrT|jjdS)NFTr7)rritemsr9rr7)r r'entryr r rr7s   z Shelf.sync)NFr)N)rrrr"rrr(r*rrrr2r6r3r:r7r r r rrMs   c@s>eZdZdddZddZdd Zd d Zd d ZddZdS)rNFutf-8cCstj|||||dS)N)rr")r rr!rr r r rr"szBsdDbShelf.__init__cCs0|jj|\}}t|}|j|jt|jfS)N)r set_locationrr#r rr,)r r'r-r.r r rr>szBsdDbShelf.set_locationcCs.t|j\}}t|}|j|jt|jfS)N)nextrrr#r rr,)r r'r-r.r r rr?szBsdDbShelf.nextcCs.|jj\}}t|}|j|jt|jfS)N)rpreviousrr#r rr,)r r'r-r.r r rr@szBsdDbShelf.previouscCs.|jj\}}t|}|j|jt|jfS)N)rfirstrr#r rr,)r r'r-r.r r rrAszBsdDbShelf.firstcCs.|jj\}}t|}|j|jt|jfS)N)rlastrr#r rr,)r r'r-r.r r rrBszBsdDbShelf.last)NFr=) rrrr"r>r?r@rArBr r r rrs  c@seZdZdddZdS)rcNFcCs$ddl}tj||j||||dS)Nr)dbmrr"r)r filenameflagr!rrDr r rr"szDbfilenameShelf.__init__)rCNF)rrrr"r r r rrsrCFcCst||||S)N)r)rErFr!rr r rrs )rCNF) picklerrior collections__all__MutableMappingr rrrrr r r r;s   b+