ok

Mini Shell

Direktori : /proc/thread-self/root/proc/self/root/lib64/python2.7/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/lib64/python2.7/dumbdbm.pyo

�
\цdc@skdZddlZddlZddlZejZdZeZ	dej
fd��YZddd�ZdS(s�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')

i����Nit	_DatabasecBs�eZeZeZd�Zd�Zd�ZeZd�Zd�Z	d�Z
d�Zd�Zd�Z
d	�Zd
�Zd�Zd�ZeZd
�Zd�ZeZd�ZRS(cCs�||_|tjd|_|tjd|_|tjd|_d|_yt|jd�}Wn3t	k
r�t|jd�}|j
|j�nX|j�|j�dS(Ntdirtdattbaktrtw(
t_modet_ostextsept_dirfilet_datfilet_bakfiletNonet_indext_opentIOErrort_chmodtcloset_update(tselftfilebasenametmodetf((s/usr/lib64/python2.7/dumbdbm.pyt__init__/s		

cCszi|_yt|j�}Wntk
r/nGXx9|D]1}|j�}t|�\}}||j|<q7W|j�dS(N(R
RR	RtrstriptevalR(RRtlinetkeytpos_and_siz_pair((s/usr/lib64/python2.7/dumbdbm.pyRMs	

cCs�|jdkrdSy|jj|j�Wn|jjk
rCnXy|jj|j|j�Wn|jjk
rznX|j|jd�}|j	|j�x4|jj
�D]#\}}|jd||f�q�W|j�dS(NRs%r, %r
(
R
RRtunlinkRterrortrenameR	RRt	iteritemstwriteR(RRRR((s/usr/lib64/python2.7/dumbdbm.pyt_commit]scCsO|j|\}}t|jd�}|j|�|j|�}|j�|S(Ntrb(R
RR
tseektreadR(RRtpostsizRR((s/usr/lib64/python2.7/dumbdbm.pyt__getitem__vs

cCs�t|jd�}|jdd�t|j��}|tdtt}|jd||�|}|j|�|j�|t|�fS(Nsrb+iiit(	RR
R$tintttellt
_BLOCKSIZER!Rtlen(RtvalRR&tnpos((s/usr/lib64/python2.7/dumbdbm.pyt_addval�s

cCsFt|jd�}|j|�|j|�|j�|t|�fS(Nsrb+(RR
R$R!RR-(RR&R.R((s/usr/lib64/python2.7/dumbdbm.pyt_setval�s



cCsT||j|<t|jd�}|j|j�|jd||f�|j�dS(Ntas%r, %r
(R
RR	RR!R(RRRR((s/usr/lib64/python2.7/dumbdbm.pyt_addkey�s

cCs�t|�td�ko)t|�kns:td�n||jkre|j||j|��n{|j|\}}|tdt}t|�tdt}||kr�|j||�|j|<n|j|�|j|<dS(Ntskeys and values must be stringsi(ttypet	TypeErrorR
R3R0R,R-R1(RRR.R&R't	oldblockst	newblocks((s/usr/lib64/python2.7/dumbdbm.pyt__setitem__�s.cCs|j|=|j�dS(N(R
R"(RR((s/usr/lib64/python2.7/dumbdbm.pyt__delitem__�s
cCs
|jj�S(N(R
tkeys(R((s/usr/lib64/python2.7/dumbdbm.pyR;�scCs
||jkS(N(R
(RR((s/usr/lib64/python2.7/dumbdbm.pythas_key�scCs
||jkS(N(R
(RR((s/usr/lib64/python2.7/dumbdbm.pyt__contains__�scCs
|jj�S(N(R
titerkeys(R((s/usr/lib64/python2.7/dumbdbm.pyR>�scCs
t|j�S(N(R-R
(R((s/usr/lib64/python2.7/dumbdbm.pyt__len__�scCs,|j�d|_|_|_|_dS(N(R"RR
R
R	R(R((s/usr/lib64/python2.7/dumbdbm.pyR�s
cCs/t|jd�r+|jj||j�ndS(Ntchmod(thasattrRR@R(Rtfile((s/usr/lib64/python2.7/dumbdbm.pyR�s(t__name__t
__module__RRRRR"tsyncR(R0R1R3R9R:R;R<R=R>t__iter__R?Rt__del__R(((s/usr/lib64/python2.7/dumbdbm.pyR"s*
						
										i�cCsLy tjd�}tj|�Wntk
r3nX||@}t||�S(s�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 dumbdbm 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 0666 (and
    will be modified by the prevailing umask).

    i(RtumasktAttributeErrorR(RBtflagRtum((s/usr/lib64/python2.7/dumbdbm.pytopen�s
(
t__doc__tosRt__builtin__tUserDictRLRR,RRt	DictMixinRR(((s/usr/lib64/python2.7/dumbdbm.pyt<module>s	�

Zerion Mini Shell 1.0