AlkantarClanX12

Your IP : 18.219.15.112


Current Path : /proc/self/root/opt/alt/python39/lib64/python3.9/dbm/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python39/lib64/python3.9/dbm/__pycache__/dumb.cpython-39.opt-2.pyc

a

R�f-�@sRddlZddlZddlZddlZddgZdZ	e
ZGdd�dejj
�Zd
d	d�ZdS)�N�error�openic@s�eZdZeZeZd+dd�Zdd�Zdd�Zdd	�ZeZ	d
d�Z
dd
�Zdd�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�-/opt/alt/python39/lib64/python3.9/dbm/dumb.py�__init__0s




z_Database.__init__cCs�|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
rr	�_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�unlinkrr�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�
<listcomp>��z#_Database.items.<locals>.<listcomp>)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	rr4rrrr 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)Nr)rrrrz)Flag must be one of 'r', 'w', 'c', or 'n')r)r�umask�AttributeError�
ValueErrorr)r^rrZumrrrr"s

)rrh)�astr%�ior�osr�collections.abc�collections�__all__rErr�abc�MutableMappingrrrrrr�<module>s