~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/export/zip_exporter.py

Major code cleanup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
_DIR_ATTR = stat.S_IFDIR | ZIP_DIRECTORY_BIT | DIR_PERMISSIONS
45
45
 
46
46
 
47
 
def zip_exporter(tree, dest, root, subdir=None, filtered=False, force_mtime=None):
 
47
def zip_exporter(tree, dest, root, subdir=None, filtered=False, force_mtime=None, per_file_timestamps=False, fileobj=None):
48
48
    """ Export this tree to a new zip file.
49
49
 
50
50
    `dest` will be created holding the contents of this tree; if it
52
52
    """
53
53
 
54
54
    compression = zipfile.ZIP_DEFLATED
55
 
    if dest == "-":
 
55
    if fileobj is not None:
 
56
        dest = fileobj
 
57
    elif dest == "-":
56
58
        dest = sys.stdout
57
59
    zipf = zipfile.ZipFile(dest, "w", compression)
58
60
    try:
100
102
                zinfo.compress_type = compression
101
103
                zinfo.external_attr = _FILE_ATTR
102
104
                zipf.writestr(zinfo, tree.get_symlink_target(file_id))
 
105
            
103
106
            yield
104
107
 
105
108
        zipf.close()