Your IP : 3.149.255.239


Current Path : /proc/thread-self/root/opt/alt/python37/lib64/python3.7/dbm/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python37/lib64/python3.7/dbm/__pycache__/dumb.cpython-37.opt-2.pyc

B

YI~d�/�@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/python37/lib64/python3.7/dbm/dumb.py�__init__0s




z_Database.__init__cCs�|dkrFx<|j|j|jfD](}yt�|�Wqtk
r@YqXqWytj|jddd�}Wn^tk
r�|dkr�ddl}|j	dt
dd	�tj|jd
dd��}|�|j�WdQRXYn
X|��dS)N�nrzLatin-1)�encoding)rrrzIThe database file is missing, the semantics of the 'c' flag will be used.�)�
stacklevel�w)
r
rr	�_os�remove�OSError�_ior�warnings�warn�DeprecationWarning�_chmod�close)rr�filename�frrrrr
Is 

z_Database._createc	Cs�i|_ytj|jddd�}Wn>tk
rZ|j|_|dkrVddl}|jdt	dd�YnPXd	|_|�>x6|D].}|�
�}t�|�\}}|�
d�}||j|<qnWWdQRXdS)
NrzLatin-1)r)rrrzFThe index file is missing, the semantics of the 'c' flag will be used.r)rF)rrrr	rr�	_modifiedrrr �rstrip�_astZliteral_eval�encode)rrr$r�line�key�pos_and_siz_pairrrrr_s 


z_Database._updatec	Cs�|jdks|jsdSy|j�|j�Wntk
r:YnXy|j�|j|j�Wntk
rfYnX|jj	|jddd��F}|�
|j�x2|j��D]$\}}d|�d�|f}|�
|�q�WWdQRXdS)NrzLatin-1)rz%r, %r
)rr%r�unlinkrr�renamer	rrr!�items�decode�write)rr$r*r+�entryrrr�_commitvsz_Database._commitcCs|jdkrtd��dS)Nz"DBM object has already been closed)rr)rrrr�_verify_open�s
z_Database._verify_openc	Cs\t|t�r|�d�}|��|j|\}}t�|jd��}|�|�|�	|�}WdQRX|S)Nzutf-8�rb)
�
isinstance�strr(r3rrrr
�seek�read)rr*�pos�sizr$Zdatrrr�__getitem__�s


z_Database.__getitem__c	Csrt�|jd��R}|�dd�t|���}|tdtt}|�d||�|}|�|�WdQRX|t|�fS)Nzrb+r���)	rrr
r7�int�tell�
_BLOCKSIZEr0�len)r�valr$r9Znposrrr�_addval�sz_Database._addvalc	Cs:t�|jd��}|�|�|�|�WdQRX|t|�fS)Nzrb+)rrr
r7r0rB)rr9rCr$rrr�_setval�s
z_Database._setvalc	CsP||j|<tj|jddd��*}|�|j�|�d|�d�|f�WdQRXdS)N�azLatin-1)rz%r, %r
)rrrr	r!r0r/)rr*r+r$rrr�_addkey�s
z_Database._addkeycCs|jrddl}|jdtdd�t|t�r4|�d�}nt|ttf�sJt	d��t|t�r`|�d�}nt|ttf�svt	d��|�
�d|_||jkr�|�
||�|��n^|j|\}}|td	t}t|�td	t}||kr�|�||�|j|<n|�|�|j|<dS)
Nrz'The database is opened for reading onlyr<)rzutf-8zkeys must be bytes or stringszvalues must be bytes or stringsTr=)rrrr r5r6r(�bytes�	bytearray�	TypeErrorr3r%rrGrDrArBrE)rr*rCrr9r:Z	oldblocksZ	newblocksrrr�__setitem__�s,



z_Database.__setitem__cCsT|jrddl}|jdtdd�t|t�r2|�d�}|��d|_|j	|=|�
�dS)Nrz'The database is opened for reading onlyr<)rzutf-8T)rrrr r5r6r(r3r%rr2)rr*rrrr�__delitem__�s


z_Database.__delitem__cCs.y
t|j�Stk
r(td�d�YnXdS)Nz"DBM object has already been closed)�listrrJr)rrrr�keys�s
z_Database.keyscs ����fdd��j��D�S)Ncsg|]}|�|f�qSrr)�.0r*)rrr�
<listcomp>sz#_Database.items.<locals>.<listcomp>)r3rrN)rr)rrr.�sz_Database.itemscCsPt|t�r|�d�}y
||jkStk
rJ|jdkrDtd�d�n�YnXdS)Nzutf-8z"DBM object has already been closed)r5r6r(rrJr)rr*rrr�__contains__s



z_Database.__contains__cCs.y
t|j�Stk
r(td�d�YnXdS)Nz"DBM object has already been closed)�iterrrJr)rrrr�iterkeys
s
z_Database.iterkeyscCs.y
t|j�Stk
r(td�d�YnXdS)Nz"DBM object has already been closed)rBrrJr)rrrr�__len__s
z_Database.__len__c	Cs,z|��Wdd|_|_|_|_XdS)N)r2rr
r	r)rrrrr"sz_Database.closecCs t|jd�r|j�||j�dS)N�chmod)�hasattrrrUr)r�filerrrr!"sz_Database._chmodcCs|S)Nr)rrrr�	__enter__&sz_Database.__enter__cGs|��dS)N)r")r�argsrrr�__exit__)sz_Database.__exit__N)r)�__name__�
__module__�__qualname__rrrr
rr2�syncr3r;rDrErGrKrLrNr.rQrS�__iter__rTr"�__del__r!rXrZrrrrr#s2

	'rr�cCsfyt�d�}t�|�Wntk
r,YnX||@}|dkrXddl}|jdtdd�t|||d�S)Nr)rrrrz)Flag must be one of 'r', 'w', 'c', or 'n'r<)r)r)r�umask�AttributeErrorrrr r)rWrrZumrrrrr-s


)rra)Zastr'�ior�osrZcollections.abc�collections�__all__rArr�abc�MutableMappingrrrrrr�<module>s

?>