~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/export/zip_exporter.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-02-11 04:02:41 UTC
  • mfrom: (5017.2.2 tariff)
  • Revision ID: pqm@pqm.ubuntu.com-20100211040241-w6n021dz0uus341n
(mbp) add import-tariff tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2008, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2005 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
42
42
_DIR_ATTR = stat.S_IFDIR | ZIP_DIRECTORY_BIT
43
43
 
44
44
 
45
 
def zip_exporter(tree, dest, root, subdir, filtered=False,
46
 
                 per_file_timestamps=False):
 
45
def zip_exporter(tree, dest, root, subdir, filtered=False):
47
46
    """ Export this tree to a new zip file.
48
47
 
49
48
    `dest` will be created holding the contents of this tree; if it
63
62
 
64
63
            # zipfile.ZipFile switches all paths to forward
65
64
            # slashes anyway, so just stick with that.
66
 
            if per_file_timestamps:
67
 
                mtime = tree.get_file_mtime(ie.file_id, dp)
68
 
            else:
69
 
                mtime = now
70
65
            filename = osutils.pathjoin(root, dp).encode('utf8')
71
66
            if ie.kind == "file":
72
67
                zinfo = zipfile.ZipInfo(
73
68
                            filename=filename,
74
 
                            date_time=mtime)
 
69
                            date_time=now)
75
70
                zinfo.compress_type = compression
76
71
                zinfo.external_attr = _FILE_ATTR
77
72
                if filtered:
89
84
                # not just empty files.
90
85
                zinfo = zipfile.ZipInfo(
91
86
                            filename=filename + '/',
92
 
                            date_time=mtime)
 
87
                            date_time=now)
93
88
                zinfo.compress_type = compression
94
89
                zinfo.external_attr = _DIR_ATTR
95
90
                zipf.writestr(zinfo,'')
96
91
            elif ie.kind == "symlink":
97
92
                zinfo = zipfile.ZipInfo(
98
93
                            filename=(filename + '.lnk'),
99
 
                            date_time=mtime)
 
94
                            date_time=now)
100
95
                zinfo.compress_type = compression
101
96
                zinfo.external_attr = _FILE_ATTR
102
97
                zipf.writestr(zinfo, ie.symlink_target)