Package s3 :: Module s3sync :: Class S3SyncDataArchive
[frames] | no frames]

Class S3SyncDataArchive

source code

object --+
         |
        S3SyncDataArchive

Simple abstraction layer for (compressed) data archives, currently based on zipfile (Python standard library). Compression additionally requires zlib to be installed (both for write and read).

Instance Methods
 
__init__(self, fileobj=None, compressed=True)
Create or open an archive
source code
 
add(self, name, obj)
Add an object to the archive
source code
 
extract(self, name)
Extract an object from the archive by name
source code
 
close(self)
Close the archive and return it as file-like object; no further add/extract operations will be possible after closing.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, fileobj=None, compressed=True)
(Constructor)

source code 

Create or open an archive

Parameters:
  • fileobj - the file object containing the archive, None to create a new archive
  • compress - enable (or suppress) compression of new archives
Overrides: object.__init__

add(self, name, obj)

source code 

Add an object to the archive

Parameters:
  • name - the file name for the object inside the archive
  • obj - the object to add (string or file-like object)
Raises:
  • UserWarning - when adding a duplicate name (overwrites the existing object in the archive)
  • RuntimeError - if the archive is not writable, or no valid object name has been provided
  • TypeError - if the object is not a unicode, str or file-like object

extract(self, name)

source code 

Extract an object from the archive by name

Parameters:
  • name - the object name
Returns:
the object as file-like object, or None if the object could not be found in the archive

close(self)

source code 

Close the archive and return it as file-like object; no further add/extract operations will be possible after closing.

Returns:
the file-like object containing the archive