Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3.10/dbm/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3.10/dbm/__pycache__/dumb.cpython-310.pyc
o

�*�g-�@sVdZddlZddlZddlZddlZddgZ	dZ
eZGdd�dej
j�Zdd
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
�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)�self�filebasename�mode�flag�r�/usr/lib/python3.10/dbm/dumb.py�__init__0s




z_Database.__init__cCs�|dkr|j|j|jfD]}zt�|�WqtyYqwztj|jddd�}Wn0tyZ|dvr6�tj|jddd��}|�|j�Wd�YdS1sRwYYdSw|�	�dS)N�nr�Latin-1��encoding�rr�w)
r
rr	�_os�remove�OSError�_ior�_chmod�close)rr�filename�frrrr
Is"�&��z_Database._createcCs�d|_i|_ztj|jddd�}Wnty#|dvr�d|_YdSw|�#|D]}|��}t�|�\}}|�	d�}||j|<q)Wd�dS1sLwYdS)NFrrrrT)
�	_modifiedrrrr	r�rstrip�_ast�literal_eval�encode)rrr#�line�key�pos_and_siz_pairrrrr\s"�
�"�z_Database._updatecCs�|jdus|js
dSz	|j�|j�Wn	tyYnwz|j�|j|j�Wn	ty1Ynw|jj	|jddd��'}|�
|j�|j��D]\}}d|�d�|f}|�
|�qHWd�dS1sfwYdS)Nrrr�%r, %r
)rr$r�unlinkrr�renamer	rrr �items�decode�write)rr#r*r+�entryrrr�_commitps&���"�z_Database._commitcCs|jdur	td��dS�N�"DBM object has already been closed)rr�rrrr�_verify_open�s
�z_Database._verify_opencCsrt|t�r
|�d�}|��|j|\}}t�|jd��}|�|�|�	|�}Wd�|S1s2wY|S)N�utf-8�rb)
�
isinstance�strr(r7rrrr
�seek�read)rr*�pos�sizr#�datrrr�__getitem__�s



��z_Database.__getitem__cCs�t�|jd��.}|�dd�t|���}|tdtt}|�d||�|}|�|�Wd�n1s8wY|t|�fS)N�rb+r���)	rrr
r<�int�tell�
_BLOCKSIZEr1�len)r�valr#r>�nposrrr�_addval�s�z_Database._addvalcCsNt�|jd��}|�|�|�|�Wd�n1swY|t|�fS)NrB)rrr
r<r1rI)rr>rJr#rrr�_setval�s

�z_Database._setvalcCsf||j|<tj|jddd��}|�|j�|�d|�d�|f�Wd�dS1s,wYdS)N�arrr,)rrrr	r r1r0)rr*r+r#rrr�_addkey�s

"�z_Database._addkeycCs�|jrtd��t|t�r|�d�}nt|ttf�std��t|t�r(|�d�}nt|ttf�s3td��|��d|_	||j
vrJ|�||�|��dS|j
|\}}|t
dt
}t|�t
dt
}||krr|�||�|j
|<dS|�|�|j
|<dS)N�'The database is opened for reading onlyr8zkeys must be bytes or stringszvalues must be bytes or stringsTrD)rrr:r;r(�bytes�	bytearray�	TypeErrorr7r$rrOrLrHrIrM)rr*rJr>r?�	oldblocks�	newblocksrrr�__setitem__�s(


z_Database.__setitem__cCsD|jrtd��t|t�r|�d�}|��d|_|j|=|��dS)NrPr8T)	rrr:r;r(r7r$rr3�rr*rrr�__delitem__�s

z_Database.__delitem__cC�&zt|j�WStytd�d�wr4)�listrrSrr6rrr�keys��

�z_Database.keyscs ����fdd��j��D�S)Ncsg|]}|�|f�qSrr)�.0r*r6rr�
<listcomp>�sz#_Database.items.<locals>.<listcomp>)r7rr[r6rr6rr/�sz_Database.itemscCsFt|t�r
|�d�}z||jvWSty"|jdur!td�d��w)Nr8r5)r:r;r(rrSrrWrrr�__contains__�s



�z_Database.__contains__cCrYr4)�iterrrSrr6rrr�iterkeysr\z_Database.iterkeyscCrYr4)rIrrSrr6rrr�__len__
r\z_Database.__len__c	CsBz|��Wd|_|_|_|_dSd|_|_|_|_w�N)r3rr
r	rr6rrrr!s
6z_Database.closecCs|j�||j�dSrc)r�chmodr)r�filerrrr sz_Database._chmodcCs|Srcrr6rrr�	__enter__sz_Database.__enter__cGs|��dSrc)r!)r�argsrrr�__exit__sz_Database.__exit__N)r)�__name__�
__module__�__qualname__rrrr
rr3�syncr7rArLrMrOrVrXr[r/r_ra�__iter__rbr!�__del__r rfrhrrrrr#s4

	%rr�cCsTzt�d�}t�|�Wn	tyYnw||@}|dvr#td��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)rerr�umrrrr"s
�
)rro)�__doc__�astr&�ior�osr�collections.abc�collections�__all__rHrr�abc�MutableMappingrrrrrr�<module>s

Spamworldpro Mini