File: //usr/local/ssl/local/ssl/lib/python2.4/dumbdbm.pyc
mς
=5Dc @ sb d Z d k Z d k Z d k Z e i Z d Z e Z d e i
f d YZ d d d Z d S( 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')
Ni t _Databasec B s t Z e Z e Z d Z d Z d Z e Z d Z d Z d Z
d Z d Z d Z
d
Z d Z d Z d
Z e Z d Z d Z e Z RS( Nc C sͺ | | _ | t i d | _ | t i d | _ | t i d | _ d | _
y t | i d } Wn+ t
j
o t | i d | i } n X| i | i d S( Nt dirt datt bakt rt w( t modet selft _modet filebasenamet _ost extsept _dirfilet _datfilet _bakfilet Nonet _indext _opent ft IOErrort closet _update( R R R R ( ( t /usr/lib/python2.4/dumbdbm.pyt __init__/ s
c C s| h | _ y t | i } Wn t j
o nH Xx9 | D]1 } | i } t | \ } } | | i | <q9 W| i d S( N( R R R R R R t linet rstript evalt keyt pos_and_siz_pairR ( R R R R R ( ( R R L s c C sδ | i d j o d Sn y | i i | i Wn | i i j
o n Xy | i i | i | i Wn | i i j
o n X| i | i d | i
} x4 | i i D]# \ } } | i d | | f q― W| i d S( NR s %r, %r
( R R R R
t unlinkR t errort renameR R R R t iteritemsR R t writeR ( R R R R ( ( R t _commit\ s c C sO | i | \ } } t | i d } | i | | i | } | i | S( Nt rb( R R R t post sizR R
R t seekt readR R ( R R R R% R$ R ( ( R t __getitem__t s
c C s t | i d } | i d d t | i } | t d t t } | i
d | | | } | i
| | i | t
| f S( Ns rb+i i i t ( R R R
R R&