/
lib64
/
python2.7
/
Upload File
HOME
� �mec @ sk d Z d d l Z d d l Z d d l Z e j Z d Z e Z d e j 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') i����Ni t _Databasec B s� e 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 d � Z RS( c C s� | | _ | t j d | _ | t j d | _ | t j d | _ d | _ y t | j d � } Wn3 t k r� t | j d � } | j | j � n X| j � | j � d S( Nt dirt datt bakt rt w( t _modet _ost extsept _dirfilet _datfilet _bakfilet Nonet _indext _opent IOErrort _chmodt closet _update( t selft filebasenamet modet f( ( s /usr/lib64/python2.7/dumbdbm.pyt __init__/ s c C sz i | _ y t | j � } Wn t k r/ nG Xx9 | D]1 } | j � } t | � \ } } | | j | <q7 W| j � d S( N( R R R R t rstript evalR ( R R t linet keyt pos_and_siz_pair( ( s /usr/lib64/python2.7/dumbdbm.pyR M s c C s� | j d k r d Sy | j j | j � Wn | j j k rC n Xy | j j | j | j � Wn | j j k rz n X| j | j d � } | j | j � x4 | j j � D]# \ } } | j d | | f � q� W| j � d S( NR s %r, %r ( R R R t unlinkR t errort renameR R R t iteritemst writeR ( R R R R ( ( s /usr/lib64/python2.7/dumbdbm.pyt _commit] s c C sO | j | \ } } t | j d � } | j | � | j | � } | j � | S( Nt rb( R R R t seekt readR ( R R t post sizR R ( ( s /usr/lib64/python2.7/dumbdbm.pyt __getitem__v s c C s� t | j d � } | j d d � t | j � � } | t d t t } | j d | | � | } | j | � | j � | t | � f S( Ns rb+i i i t ( R R R$ t intt tellt _BLOCKSIZER! R t len( R t valR R&