AlkantarClanX12

Your IP : 3.138.114.140


Current Path : /proc/self/root/opt/alt/python33/lib64/python3.3/dbm/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python33/lib64/python3.3/dbm/__pycache__/dumb.cpython-33.pyo

�
��f�%c@sqdZddlZddlZddlZddgZdZeZ	Gdd�dej
�Zddd	d�Z
dS(
u�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')

iNuerroruopenicBs�|EeZdZeZeZdd�Zdd�Zdd�ZeZdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�ZeZdd�Zdd�ZeZdd �Zd!S("u	_DatabasecCs�||_|d|_|d|_|d|_d|_ytj|jddd�}Wn=tk
r�tj|jddd�}|j	|j�YnX|j
�|j�dS(Nu.diru.datu.bakuruencodinguLatin-1uw(u_modeu_dirfileu_datfileu_bakfileuNoneu_indexu_iouopenuIOErroru_chmoducloseu_update(uselfufilebasenameumodeuf((u-/opt/alt/python33/lib64/python3.3/dbm/dumb.pyu__init__/s	


	

u_Database.__init__cCs�i|_ytj|jddd�}Wntk
r<YnVXxH|D]@}|j�}t|�\}}|jd�}||j|<qDW|j�dS(NuruencodinguLatin-1(	u_indexu_iouopenu_dirfileuIOErrorurstripuevaluencodeuclose(uselfufulineukeyupos_and_siz_pair((u-/opt/alt/python33/lib64/python3.3/dbm/dumb.pyu_updateMs	

u_Database._updatecCs�|jdkrdSy|jj|j�Wn|jjk
rDYnXy|jj|j|j�Wn|jjk
r|YnX|jj	|jddd�}|j
|j�x=|jj�D],\}}|jd|j
d�|f�q�W|j�dS(NuwuencodinguLatin-1u%r, %r
(u_indexuNoneu_osuunlinku_bakfileuerrorurenameu_dirfileu_iouopenu_chmoduitemsuwriteudecodeuclose(uselfufukeyupos_and_siz_pair((u-/opt/alt/python33/lib64/python3.3/dbm/dumb.pyu_commit^s$u_Database._commitcCsst|t�r!|jd�}n|j|\}}tj|jd�}|j|�|j|�}|j	�|S(Nuutf-8urb(
u
isinstanceustruencodeu_indexu_iouopenu_datfileuseekureaduclose(uselfukeyuposusizufudat((u-/opt/alt/python33/lib64/python3.3/dbm/dumb.pyu__getitem__ys

u_Database.__getitem__cCs�tj|jd�}|jdd�t|j��}|tdtt}|jd||�|}|j|�|j�|t	|�fS(Nurb+iiis(
u_iouopenu_datfileuseekuintutellu
_BLOCKSIZEuwriteucloseulen(uselfuvalufuposunpos((u-/opt/alt/python33/lib64/python3.3/dbm/dumb.pyu_addval�s

u_Database._addvalcCsItj|jd�}|j|�|j|�|j�|t|�fS(Nurb+(u_iouopenu_datfileuseekuwriteucloseulen(uselfuposuvaluf((u-/opt/alt/python33/lib64/python3.3/dbm/dumb.pyu_setval�s



u_Database._setvalcCsf||j|<tj|jddd�}|j|j�|jd|jd�|f�|j�dS(NuauencodinguLatin-1u%r, %r
(u_indexu_iouopenu_dirfileu_chmoduwriteudecodeuclose(uselfukeyupos_and_siz_pairuf((u-/opt/alt/python33/lib64/python3.3/dbm/dumb.pyu_addkey�s

 u_Database._addkeycCs4t|t�r!|jd�}n$t|ttf�sEtd��nt|t�rf|jd�}n$t|ttf�s�td��n||jkr�|j||j|��n{|j|\}}|t	dt	}t
|�t	dt	}||kr|j||�|j|<n|j|�|j|<dS(Nuutf-8ukeys must be bytes or stringsuvalues must be bytes or stringsi(u
isinstanceustruencodeubytesu	bytearrayu	TypeErroru_indexu_addkeyu_addvalu
_BLOCKSIZEulenu_setval(uselfukeyuvaluposusizu	oldblocksu	newblocks((u-/opt/alt/python33/lib64/python3.3/dbm/dumb.pyu__setitem__�s u_Database.__setitem__cCs9t|t�r!|jd�}n|j|=|j�dS(Nuutf-8(u
isinstanceustruencodeu_indexu_commit(uselfukey((u-/opt/alt/python33/lib64/python3.3/dbm/dumb.pyu__delitem__�s
u_Database.__delitem__cCst|jj��S(N(ulistu_indexukeys(uself((u-/opt/alt/python33/lib64/python3.3/dbm/dumb.pyukeys�su_Database.keyscs �fdd��jj�D�S(Ncs g|]}|�|f�qS(((u.0ukey(uself(u-/opt/alt/python33/lib64/python3.3/dbm/dumb.pyu
<listcomp>�s	u#_Database.items.<locals>.<listcomp>(u_indexukeys(uself((uselfu-/opt/alt/python33/lib64/python3.3/dbm/dumb.pyuitems�su_Database.itemscCs.t|t�r!|jd�}n||jkS(Nuutf-8(u
isinstanceustruencodeu_index(uselfukey((u-/opt/alt/python33/lib64/python3.3/dbm/dumb.pyu__contains__�su_Database.__contains__cCst|jj��S(N(uiteru_indexukeys(uself((u-/opt/alt/python33/lib64/python3.3/dbm/dumb.pyuiterkeys�su_Database.iterkeyscCs
t|j�S(N(ulenu_index(uself((u-/opt/alt/python33/lib64/python3.3/dbm/dumb.pyu__len__�su_Database.__len__cCs,|j�d|_|_|_|_dS(N(u_commituNoneu_indexu_datfileu_dirfileu_bakfile(uself((u-/opt/alt/python33/lib64/python3.3/dbm/dumb.pyuclose�s
u_Database.closecCs/t|jd�r+|jj||j�ndS(Nuchmod(uhasattru_osuchmodu_mode(uselfufile((u-/opt/alt/python33/lib64/python3.3/dbm/dumb.pyu_chmod�su_Database._chmodN(u__name__u
__module__u__qualname__u_osu_iou__init__u_updateu_commitusyncu__getitem__u_addvalu_setvalu_addkeyu__setitem__u__delitem__ukeysuitemsu__contains__uiterkeysu__iter__u__len__ucloseu__del__u_chmod(u
__locals__((u-/opt/alt/python33/lib64/python3.3/dbm/dumb.pyu	_Database"s*

!u	_Databasei�cCsMy tjd�}tj|�Wntk
r4YnX||@}t||�S(u�Open the database file, filename, and return corresponding object.

    The flag argument, used to control how the database is opened in the
    other DBM implementations, is ignored in the dbm.dumb module; the
    database is 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).

    i(u_osuumaskuAttributeErroru	_Database(ufileuflagumodeuum((u-/opt/alt/python33/lib64/python3.3/dbm/dumb.pyuopen�s
(u__doc__uiou_iouosu_osucollectionsu__all__u
_BLOCKSIZEuIOErroruerroruMutableMappingu	_DatabaseuNoneuopen(((u-/opt/alt/python33/lib64/python3.3/dbm/dumb.pyu<module>s�