AlkantarClanX12

Your IP : 3.16.70.99


Current Path : /proc/thread-self/root/lib64/python2.7/
Upload File :
Current File : //proc/thread-self/root/lib64/python2.7/dumbdbm.pyc

�
zfc@swdZddlZddlZddlZddlZejZdZ	e
Zdejfd��YZ
ddd�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�eZeZeZdd�Zd�Zd�ZeZd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zd�Zd
�ZeZd�Zd�ZeZd�ZRS(tccCs�||_|dk|_|tjd|_|tjd|_|tjd|_d|_yt	|jd�}Wn<t
k
r�t	|jd��}|j|j�WdQXnX|j�|j
�dS(Ntrtdirtdattbaktw(t_modet	_readonlyt_ostextsept_dirfilet_datfilet_bakfiletNonet_indext_opentIOErrort_chmodtcloset_update(tselftfilebasenametmodetflagtf((s/usr/lib64/python2.7/dumbdbm.pyt__init__0s		

cCs�i|_yt|j�}Wntk
r<|j|_nVXt|_|�Dx<|D]4}|j�}tj	|�\}}||j|<qTWWdQXdS(N(
RRRRRt	_modifiedtFalsetrstript_asttliteral_eval(RRtlinetkeytpos_and_siz_pair((s/usr/lib64/python2.7/dumbdbm.pyRPs	
	
c	Cs�|jdks|jrdSy|jj|j�Wn|jjk
rMnXy|jj|j|j�Wn|jjk
r�nX|j	|jd��N}|j
|j�x4|jj�D]#\}}|jd||f�q�WWdQXdS(NRs%r, %r
(
RRRR	tunlinkR
terrortrenameRRRt	iteritemstwrite(RRR!R"((s/usr/lib64/python2.7/dumbdbm.pyt_commitascCsN|j|\}}t|jd��#}|j|�|j|�}WdQX|S(Ntrb(RRRtseektread(RR!tpostsizRR((s/usr/lib64/python2.7/dumbdbm.pyt__getitem__ys

cCs�t|jd��g}|jdd�t|j��}|tdtt}|jd||�|}|j|�WdQX|t|�fS(Nsrb+iiis(RRR*tintttellt
_BLOCKSIZER'tlen(RtvalRR,tnpos((s/usr/lib64/python2.7/dumbdbm.pyt_addval�scCsEt|jd��!}|j|�|j|�WdQX|t|�fS(Nsrb+(RRR*R'R2(RR,R3R((s/usr/lib64/python2.7/dumbdbm.pyt_setval�s
cCsS||j|<t|jd��.}|j|j�|jd||f�WdQXdS(Ntas%r, %r
(RRRRR'(RR!R"R((s/usr/lib64/python2.7/dumbdbm.pyt_addkey�s
cCs�t|�td�ko)t|�kns:td�nt|_||jkrn|j||j|��n{|j|\}}|tdt}t|�tdt}||kr�|j	||�|j|<n|j|�|j|<dS(Ntskeys and values must be stringsi(
ttypet	TypeErrortTrueRRR8R5R1R2R6(RR!R3R,R-t	oldblockst	newblocks((s/usr/lib64/python2.7/dumbdbm.pyt__setitem__�s.	cCs!t|_|j|=|j�dS(N(R<RRR((RR!((s/usr/lib64/python2.7/dumbdbm.pyt__delitem__�s	
cCs
|jj�S(N(Rtkeys(R((s/usr/lib64/python2.7/dumbdbm.pyRA�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(Rtiterkeys(R((s/usr/lib64/python2.7/dumbdbm.pyRD�scCs
t|j�S(N(R2R(R((s/usr/lib64/python2.7/dumbdbm.pyt__len__�scCs4z|j�Wdd|_|_|_|_XdS(N(R(RRRRR
(R((s/usr/lib64/python2.7/dumbdbm.pyR�scCs/t|jd�r+|jj||j�ndS(Ntchmod(thasattrR	RFR(Rtfile((s/usr/lib64/python2.7/dumbdbm.pyR�s(t__name__t
__module__R	RRRR(tsyncR.R5R6R8R?R@RARBRCRDt__iter__RERt__del__R(((s/usr/lib64/python2.7/dumbdbm.pyR#s*
 									
						i�cCsOy 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(R	tumasktAttributeErrorR(RHRRtum((s/usr/lib64/python2.7/dumbdbm.pytopen�s
(t__doc__tastRtosR	t__builtin__tUserDictRQRR1RR$t	DictMixinRR(((s/usr/lib64/python2.7/dumbdbm.pyt<module>s	�