ž ¬ÿfƒ%c@sqdZddlZddlZddlZddgZdZeZ Gdd„dej ƒZ ddd 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 d d „Z d d„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„ZeZdd„Zdd„ZeZdd „Zd!S("u _Databasec Cs°||_|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|×s u#_Database.items..(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¶c CsMy 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_osu collectionsu__all__u _BLOCKSIZEuIOErroruerroruMutableMappingu _DatabaseuNoneuopen(((u-/opt/alt/python33/lib64/python3.3/dbm/dumb.pyus    Î