/usr/lib64/python3.9/dbm/__pycache__
NameSizeModeActions
dumb.cpython-39.opt-1.pyc79150644editdlrm
dumb.cpython-39.opt-2.pyc66250644editdlrm
dumb.cpython-39.pyc79150644editdlrm
gnu.cpython-39.opt-1.pyc2050644editdlrm
gnu.cpython-39.opt-2.pyc1440644editdlrm
gnu.cpython-39.pyc2050644editdlrm
ndbm.cpython-39.opt-1.pyc2040644editdlrm
ndbm.cpython-39.opt-2.pyc1440644editdlrm
ndbm.cpython-39.pyc2040644editdlrm
__init__.cpython-39.opt-1.pyc42330644editdlrm
__init__.cpython-39.opt-2.pyc22900644editdlrm
__init__.cpython-39.pyc42330644editdlrm
Edit: /usr/lib64/python3.9/dbm/__pycache__/dumb.cpython-39.opt-1.pyc (7915B)
a ´i-ã@sVdZddlZddlZddlZddlZddgZ dZ e Z Gdd„dej jƒZd d d„ZdS) a­A dumb and slow but simple dbm clone. For database spam, spam.dir contains the index (a text file), spam.bak *may* contain a backup of the index (also a text file), while spam.dat contains the data (a binary file). XXX TO DO: - seems to contain a bug when updating... - reclaim free space (currently, space once occupied by deleted or expanded items is never reused) - support concurrent access (currently, if two processes take turns making updates, they can mess up the index) - support efficient access to large databases (currently, the whole index is read when the database is opened, and some updates rewrite the whole index) - support opening for read-only (flag = 'm') éNÚerrorÚopenic@sÂeZdZeZeZd+dd„Zdd„Zdd„Zdd „ZeZ d d „Z d d „Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„ZeZd d!„Zd"d#„ZeZd$d%„Zd&d'„Zd(d)„Zd*S),Ú _DatabaseÚccCsL||_|dk|_|d|_|d|_|d|_d|_| |¡| |¡dS)NÚrz.dirz.datz.bak)Ú_modeÚ _readonlyÚ_dirfileÚ_datfileÚ_bakfileÚ_indexÚ_createÚ_update)ÚselfZ filebasenameÚmodeÚflag©rú /usr/lib64/python3.9/dbm/dumb.pyÚ__init__0s     z_Database.__init__c Cs¾|dkr@|j|j|jfD]&}zt |¡Wqty<Yq0qztj|jddd�}WnZty°|dvrn‚tj|jddd��}| |j¡Wdƒn1s¢0YYn 0|  ¡dS)NÚnrúLatin-1©Úencoding©rrÚw) r r r Ú_osÚremoveÚOSErrorÚ_iorÚ_chmodÚclose)rrÚfilenameÚfrrrr Is  0z_Database._createcCs¢d|_i|_ztj|jddd�}Wn"tyD|dvr:‚d|_YnZ0|�D|D].}| ¡}t |¡\}}|  d¡}||j|<qPWdƒn1s”0YdS)NFrrrrT) Ú _modifiedr rrr rÚrstripÚ_astZ literal_evalÚencode)rrr"ÚlineÚkeyÚpos_and_siz_pairrrrr\s   z_Database._updatecCsØ|jdus|jsdSz|j |j¡Wnty8Yn0z|j |j|j¡WntybYn0|jj |jddd��L}|  |j¡|j  ¡D]$\}}d|  d¡|f}|  |¡q�Wdƒn1sÊ0YdS)Nrrrú%r, %r )r r#rÚunlinkr rÚrenamer rrrÚitemsÚdecodeÚwrite)rr"r(r)ÚentryrrrÚ_commitps   z_Database._commitcCs|jdurtdƒ‚dS©Nú"DBM object has already been closed)r r©rrrrÚ _verify_open‹s z_Database._verify_opencCspt|tƒr| d¡}| ¡|j|\}}t |jd¡�$}| |¡|  |¡}Wdƒn1sb0Y|S)Núutf-8Úrb) Ú isinstanceÚstrr&r5r rrr ÚseekÚread)rr(ÚposÚsizr"ZdatrrrÚ __getitem__�s   (z_Database.__getitem__cCs†t |jd¡�\}| dd¡t| ¡ƒ}|tdtt}| d||¡|}| |¡Wdƒn1sp0Y|t|ƒfS)Núrb+rééó) rrr r:ÚintÚtellÚ _BLOCKSIZEr/Úlen)rÚvalr"r<ZnposrrrÚ_addval�s  (z_Database._addvalcCsNt |jd¡�$}| |¡| |¡Wdƒn1s80Y|t|ƒfS)Nr?)rrr r:r/rF)rr<rGr"rrrÚ_setval«s (z_Database._setvalcCsd||j|<tj|jddd��4}| |j¡| d| d¡|f¡Wdƒn1sV0YdS)NÚarrr*)r rrr rr/r.)rr(r)r"rrrÚ_addkey´s  z_Database._addkeycCsô|jrtdƒ‚t|tƒr$| d¡}nt|ttfƒs:tdƒ‚t|tƒrP| d¡}nt|ttfƒsftdƒ‚| ¡d|_ ||j vr’|  ||  |¡¡n^|j |\}}|t dt }t|ƒt dt }||krà| ||¡|j |<n|  |¡|j |<dS)Nú'The database is opened for reading onlyr6zkeys must be bytes or stringszvalues must be bytes or stringsTrA)rrr8r9r&ÚbytesÚ bytearrayÚ TypeErrorr5r#r rKrHrErFrI)rr(rGr<r=Z oldblocksZ newblocksrrrÚ __setitem__ºs(     z_Database.__setitem__cCsD|jrtdƒ‚t|tƒr"| d¡}| ¡d|_|j|=| ¡dS)NrLr6T) rrr8r9r&r5r#r r1©rr(rrrÚ __delitem__ßs  z_Database.__delitem__cCs.z t|jƒWSty(tdƒd‚Yn0dSr2)Úlistr rOrr4rrrÚkeysîs  z_Database.keyscs ˆ ¡‡fdd„ˆj ¡DƒS)Ncsg|]}|ˆ|f‘qSrr)Ú.0r(r4rrÚ öóz#_Database.items..)r5r rTr4rr4rr-ôsz_Database.itemscCsPt|tƒr| d¡}z ||jvWStyJ|jdurDtdƒd‚n‚Yn0dS)Nr6r3)r8r9r&r rOrrQrrrÚ __contains__øs      z_Database.__contains__cCs.z t|jƒWSty(tdƒd‚Yn0dSr2)Úiterr rOrr4rrrÚiterkeyss  z_Database.iterkeyscCs.z t|jƒWSty(tdƒd‚Yn0dSr2)rFr rOrr4rrrÚ__len__ s  z_Database.__len__c CsDz$| ¡Wd|_|_|_|_nd|_|_|_|_0dS©N)r1r r r r r4rrrr s z_Database.closecCs|j ||j¡dSr\)rÚchmodr)rÚfilerrrrsz_Database._chmodcCs|Sr\rr4rrrÚ __enter__sz_Database.__enter__cGs | ¡dSr\)r )rÚargsrrrÚ__exit__sz_Database.__exit__N)r)Ú__name__Ú __module__Ú __qualname__rrrr rr1Úsyncr5r>rHrIrKrPrRrTr-rXrZÚ__iter__r[r Ú__del__rr_rarrrrr#s2   % rré¶cCsTzt d¡}t |¡Wnty*Yn 0||@}|dvrFtdƒ‚t|||d�S)aEOpen the database file, filename, and return corresponding object. The flag argument, used to control how the database is opened in the other DBM implementations, supports only the semantics of 'c' and 'n' values. Other values will default to the semantics of 'c' value: the database will always opened for update and will be created if it does not exist. The optional mode argument is the UNIX mode of the file, used only when the database has to be created. It defaults to octal code 0o666 (and will be modified by the prevailing umask). r)rrrrz)Flag must be one of 'r', 'w', 'c', or 'n')r)rÚumaskÚAttributeErrorÚ ValueErrorr)r^rrZumrrrr"s   )rrh)Ú__doc__Úastr%ÚiorÚosrÚcollections.abcÚ collectionsÚ__all__rErrÚabcÚMutableMappingrrrrrrÚs