-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5fec93
commit 5a3e9cb
Showing
12 changed files
with
1,418 additions
and
609 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,32 +177,35 @@ class Bz2Shelf(CompressShelf): | |
extensions = '.tbz' , '.tbz2' , '.bz2' | ||
## | ||
def __init__( | ||
self , | ||
filename , | ||
mode = 'c' , | ||
protocol = PROTOCOL , | ||
compress = 9 , | ||
writeback = False , | ||
silent = False , | ||
keyencoding = ENCODING ) : | ||
|
||
self , | ||
filename , | ||
mode = 'c' , | ||
dbtype = '' , | ||
protocol = PROTOCOL , | ||
compress = 9 , | ||
writeback = False , | ||
silent = False , | ||
keyencoding = ENCODING ) : | ||
|
||
## save arguments for pickling.... | ||
self.__init_args = ( filename , | ||
mode , | ||
dbtype , | ||
protocol , | ||
compress , | ||
writeback , | ||
silent ) | ||
|
||
## initialize the base class | ||
CompressShelf.__init__ ( self , | ||
filename , | ||
mode , | ||
protocol , | ||
compress , | ||
writeback , | ||
silent , | ||
keyencoding ) | ||
CompressShelf.__init__ ( self , | ||
filename , | ||
mode = mode , | ||
dbtype = dbtype , | ||
protocol = protocol , | ||
compress = compress , | ||
writeback = writeback , | ||
silent = silent , | ||
keyencoding = keyencoding ) | ||
|
||
## needed for proper (un)pickling | ||
def __getinitargs__ ( self ) : | ||
|
@@ -266,10 +269,6 @@ def compress_item ( self , value ) : | |
"""Compress (zip) the item using ``bz2.compress'' | ||
- see bz2.compress | ||
""" | ||
## f = BytesIO () | ||
## p = Pickler ( f , self.protocol ) | ||
## p.dump ( value ) | ||
## return bz2.compress ( f.getvalue() , self.compresslevel ) | ||
return bz2.compress ( self.pickle ( value ) , self.compresslevel ) | ||
|
||
# ========================================================================= | ||
|
@@ -278,8 +277,6 @@ def uncompress_item ( self , value ) : | |
"""Uncompress (bzip2) the item using ``bz2.decompress'' | ||
- see bz2.decompress | ||
""" | ||
## f = BytesIO ( bz2.decompress ( value ) ) | ||
## return Unpickler ( f ) . load ( ) | ||
return self.unpickle ( bz2.decompress ( value ) ) | ||
|
||
# ========================================================================= | ||
|
@@ -295,6 +292,7 @@ def clone ( self , new_name , keys = () ) : | |
""" | ||
new_db = Bz2Shelf ( new_name , | ||
mode = 'c' , | ||
dbtype = self.dbtype , | ||
protocol = self.protocol , | ||
compress = self.compresslevel , | ||
writeback = self.writeback , | ||
|
@@ -313,8 +311,9 @@ def clone ( self , new_name , keys = () ) : | |
# @date 2010-04-30 | ||
def open ( filename , | ||
mode = 'c' , | ||
dbtype = '' , | ||
protocol = PROTOCOL , | ||
compresslevel = 9 , | ||
compress = 9 , | ||
writeback = False , | ||
silent = True , | ||
keyencoding = ENCODING ) : | ||
|
@@ -331,13 +330,14 @@ def open ( filename , | |
See the module's __doc__ string for an overview of the interface. | ||
""" | ||
|
||
return Bz2Shelf ( filename , | ||
mode , | ||
protocol , | ||
compresslevel , | ||
writeback , | ||
silent , | ||
keyencoding ) | ||
return Bz2Shelf ( filename , | ||
mode = mode , | ||
dbtype = dbtype , | ||
protocol = protocol , | ||
compress = compress , | ||
writeback = writeback , | ||
silent = silent , | ||
keyencoding = keyencoding ) | ||
|
||
# ============================================================================= | ||
## @class TmpBz2Shelf | ||
|
@@ -349,6 +349,7 @@ class TmpBz2Shelf(Bz2Shelf,TmpDB): | |
TEMPORARY ``bzip2''-version of ``shelve''-database | ||
""" | ||
def __init__( self , | ||
dbtype = '' , | ||
protocol = HIGHEST_PROTOCOL , | ||
compress = 9 , | ||
silent = False , | ||
|
@@ -360,14 +361,15 @@ def __init__( self , | |
TmpDB.__init__ ( self , suffix = '.bz2db' , remove = remove , keep = keep ) | ||
|
||
## open DB | ||
Bz2Shelf.__init__ ( self , | ||
self.tmp_name , | ||
'c' , | ||
protocol , | ||
compress , | ||
False , ## writeback | ||
silent , | ||
keyencoding ) | ||
Bz2Shelf.__init__ ( self , | ||
self.tmp_name , | ||
dbtype = dbtype , | ||
mode = 'c' , | ||
protocol = protocol , | ||
compress = compress , | ||
writeback = False , ## writeback | ||
silent = silent , | ||
keyencoding = keyencoding ) | ||
|
||
## close and delete the file | ||
def close ( self ) : | ||
|
@@ -380,25 +382,27 @@ def close ( self ) : | |
## helper function to open TEMPORARY ZipShelve data base# | ||
# @author Vanya BELYAEV [email protected] | ||
# @date 2010-04-30 | ||
def tmpdb ( protocol = HIGHEST_PROTOCOL , | ||
compresslevel = 9 , | ||
silent = True , | ||
keyencoding = ENCODING , | ||
remove = True , ## immediate remove | ||
keep = False ) : ## keep it | ||
def tmpdb ( dbtype = '' , | ||
protocol = HIGHEST_PROTOCOL , | ||
compress = 9 , | ||
silent = True , | ||
keyencoding = ENCODING , | ||
remove = True , ## immediate remove | ||
keep = False ) : ## keep it | ||
"""Open a TEMPORARY persistent dictionary for reading and writing. | ||
The optional protocol parameter specifies the | ||
version of the pickle protocol (0, 1, or 2). | ||
See the module's __doc__ string for an overview of the interface. | ||
""" | ||
return TmpBz2Shelf ( protocol , | ||
compresslevel , | ||
silent , | ||
keyencoding , | ||
remove , | ||
keep ) | ||
return TmpBz2Shelf ( dbtype = dbtype , | ||
protocol = protocol , | ||
compress = compress , | ||
silent = silent , | ||
keyencoding = keyencoding , | ||
remove = remove , | ||
keep = keep ) | ||
|
||
# ============================================================================= | ||
if '__main__' == __name__ : | ||
|
Oops, something went wrong.