[chimera-dev] compression

Eric Pettersen pett at cgl.ucsf.edu
Thu May 15 15:40:23 PDT 2003


	So, I've implemented my proposed suggestions to support compressed 
files (more exactly, just gzipped files for now) in OpenSave.  By 
default, open panels will show  (and possibly return) .gz file names 
while save panels will not.  This behavior can be overridden by 
supplying the boolean keyword 'compress' to the panel constructor.  New 
functions/attributes in OpenSave are:

compressSuffixes:  a list of file-name suffixes where compression is 
assumed.  Currently just ['.gz'].

osOpen(filename, *args, **kw):  should be used to open files where 
compression is relevant.  Will return a file-like object.  If the file 
is opened for input, compression will be handled automatically.  If 
opened for output, will use compression if the file name has a suffix 
in compressSuffixes unless a boolean 'compress' keyword is supplied.  
Other args and kw are compatible with the underlying open() used 
[built-in for uncompressed; gzip.open() for compressed].

osUncompressedPath(inPath):  will return a path to an uncompressed 
version of 'inPath'.  Designed to be used to hand off uncompressed 
files to C++ layer interfaces.  Returns 'inPath' if 'inPath' is already 
uncompressed.  Otherwise it uncompresses into a temp file that gets 
deleted at APPQUIT.

	I've modified all uses of OpenSave that I could find to allow for 
compression where appropriate.  Besides the main open panel, it works 
with the start-up command-line args and in the Chimera command line as 
far as I've tested.  Let me know if anyone finds problems.

--Eric



More information about the Chimera-dev mailing list