WcJ- ddlZddlZddlZddlZddgZdZ e Z GddejjZd d ZdS) NerroropeniceZdZeZeZddZdZdZdZeZ dZ dZ dZ d Z d Zd Zd Zd ZdZdZdZeZdZdZeZdZdZdZdS) _Databasecc|jj|}||_|dk|_|dz|_|dz|_|dz|_d|_|j||j|dS)Nrs.dirs.dats.bak) _osfsencode_mode _readonly_dirfile_datfile_bakfile_index_create_update)self filebasenamemodeflags !/usr/lib64/python3.12/dbm/dumb.py__init__z_Database.__init__0sxx((6  #+%w. %w. $w.   T Tc|dkr?|j|j|jfD]} tj| t j|jdd}|jdS#t $rY`wxYw#t $ra|dvrt j|jdd5}|j|jdddYdS#1swYYdSxYwwxYw)Nnr Latin-1encodingrrw) rrrr removeOSError_iorclose_chmod)rrfilenamefs rrz_Database._createJsS 3;;!]]DMM4==I  JJx((( i@@A GGIIIID  + + +:%%$--yAA +Q DMM** + + + + + + + + + + + + + + + + + + + +s;A>$B> B  B 3C9C* C9*C5 /C95C9c~d|_i|_ tj|jdd}|5|D]N}|j }t j|\}}|jd}||j|<P ddddS#1swYdSxYw#t$r|dvrd|_YdSwxYw)NFr rrr T) _modifiedrr$rrrstrip_ast literal_evalencoder#)rrr(linekeypos_and_siz_pairs rrz_Database._update]s!  8i@@A  8 888D;;=D,0,=,=d,C)C)**Y/C'7DKK$$ 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8  " " ":%%!DNNNN "s$B"ABB"B<;B<c~|j |jsdS |jj|j |jj |j|j|jj|jdd5}|j|j|jjD]/\}}|jdd|d}|j|1 ddddS#t $rYwxYw#t $rYwxYw#1swYdSxYw)Nr!rr,  )rr*r unlinkrr#renamerr$rr&itemsdecodewrite)rr(r0r1entrys r_commitz_Database._commitqs ;; dnnn F  HHOODMM * *  HHOODMM4== 9 9XX]]4==# ] B a KK & &)-):):)<  %%'*jj&;&;&;=M=M=MN             D      D           s0&D1D"A)D2 DD" D/.D/2D<c8|j tddSN"DBM object has already been closed)rrrs r _verify_openz_Database._verify_opens ;; <= =  rcVt|tr|jd}|j|j|\}}t j |jd5}|j||j|}ddd|S#1swYSxYw)Nutf-8rb) isinstancestrr.r@rr$rrseekread)rr0possizr(dats r __getitem__z_Database.__getitem__s c3  **W%C ;;s#S XXdmmT * a FF3KK&&+C               s .%BB(ctj|jd5}|jddt |j }|t zdz t zt z}|jd||z z|}|j|dddt|fS#1swYxYw)Nrb+r) r$rrrFinttell _BLOCKSIZEr9len)rvalr(rHnposs r_addvalz_Database._addvals XXdmmU + q FF1aLLaffh-C:%)j8JFD GGE48$ % %C GGCLL      SX         s A9B44B=ctj|jd5}|j||j |ddd|t |fS#1swYxYw)NrM)r$rrrFr9rT)rrHrUr(s r_setvalz_Database._setvals XXdmmU + q FF3KK GGCLL     SX         s %A  A)c"||j|<tj|jdd5}|j |j|j |j dd|dddddS#1swYdSxYw)Narrr3r4)rr$rrr&r9r8)rr0r1r(s r_addkeyz_Database._addkeys+ C XXdmmS9 = = L KK & & GG#**Y"7"7"79I9I9IJ K K L L L L L L L L L L L L L L L L Ls ABBc$|jr tdt|tr|j d}n't|t t fs tdt|tr|j d}n't|t t fs td|jd|_ ||jvr%|j||j|dS|j|\}}|tzdz tz}t|tzdz tz}||kr"|j|||j|<dS|j||j|<dS)N'The database is opened for reading onlyrBzkeys must be bytes or stringszvalues must be bytes or stringsTrO)r rrDrEr.bytes bytearray TypeErrorr@r*rr\rWrSrTrY)rr0rUrHrI oldblocks newblockss r __setitem__z_Database.__setitem__s[ >>>AB B c3  **W%CCC%!344;< < c3  **W%CCC%!344=> >  dkk ! ! LLdll3/ 0 0 0 0{{3'HCz)A-*>>AB B c3  **W%C  KK  rcj t|jS#t$rtddwxYwr=)listrrarr?s rkeysz_Database.keysD H $ $ H H H<=4 G H2cpjfdjjDS)Nc&g|] }||fSro).0r0rs r z#_Database.items..s"???Sd3i   ?r)r@rrjr?s`rr7z_Database.itemss6 ????DKK,<,<,>???rct|tr|jd} ||jvS#t$r|jt ddwxYw)NrBr>)rDrEr.rrarrfs r __contains__z_Database.__contains__sg c3  **W%C $++% %   {{"@AtK  s 5&Acj t|jS#t$rtddwxYwr=)iterrrarr?s riterkeysz_Database.iterkeysrkrlcj t|jS#t$rtddwxYwr=)rTrrarr?s r__len__z_Database.__len__ sD Ht{{# # H H H<=4 G Hrlc |jdx|_x|_x|_|_dS#dx|_x|_x|_|_wxYwN)r;rrrrr?s rr%z_Database.closes[ O LLNNJN NDK N$- N$-$---$ NDK N$- N$-$- N N N Ns 1AcT|jj||jdSrz)r chmodr )rfiles rr&z_Database._chmods! tTZZ((((rc|Srzror?s r __enter__z_Database.__enter__s rc(|jdSrz)r%)rargss r__exit__z_Database.__exit__s rN)r)__name__ __module__ __qualname__r r$rrrr;syncr@rKrWrYr\rdrgrjr7rsrv__iter__rxr%__del__r&rrrorrrr#sy C C4&888(2 D>>>LLL 555J   HHH @@@   HHH HHHH OOO G)))rrrc tjd}tj|||z}|dvr tdt |||S#t$rY-wxYw)Nr)r r!rrz)Flag must be one of 'r', 'w', 'c', or 'n')r)r umaskAttributeError ValueErrorr)r}rrums rrr#s  YYq\ " s| '''DEE T4d + ++      s.A A%$A%)rr)astr,ior$osr collections.abc collections__all__rSr#rabcMutableMappingrrrorrrs. F   }}}}} ..}}@,,,,,,r