~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/export/zip_exporter.py

  • Committer: Jonathan Riddell
  • Date: 2011-06-30 11:14:06 UTC
  • mfrom: (6002 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6003.
  • Revision ID: jriddell@canonical.com-20110630111406-eimf301w6x92xkk7
mergeĀ inĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
"""Export a Tree to a non-versioned directory.
 
17
"""Export a Tree to a zip file.
18
18
"""
19
19
 
20
20
import os
34
34
from bzrlib.trace import mutter
35
35
 
36
36
 
37
 
# Windows expects this bit to be set in the 'external_attr' section
38
 
# Or it won't consider the entry a directory
 
37
# Windows expects this bit to be set in the 'external_attr' section,
 
38
# or it won't consider the entry a directory.
39
39
ZIP_DIRECTORY_BIT = (1 << 4)
40
40
FILE_PERMISSIONS = (0644 << 16)
41
41
DIR_PERMISSIONS = (0755 << 16)
44
44
_DIR_ATTR = stat.S_IFDIR | ZIP_DIRECTORY_BIT | DIR_PERMISSIONS
45
45
 
46
46
 
47
 
def zip_exporter_generator(tree, dest, root, subdir=None, filtered=False, 
48
 
                 force_mtime=None, fileobj=None):
 
47
def zip_exporter_generator(tree, dest, root, subdir=None, filtered=False,
 
48
    force_mtime=None, fileobj=None):
49
49
    """ Export this tree to a new zip file.
50
50
 
51
51
    `dest` will be created holding the contents of this tree; if it
95
95
                            date_time=date_time)
96
96
                zinfo.compress_type = compression
97
97
                zinfo.external_attr = _DIR_ATTR
98
 
                zipf.writestr(zinfo,'')
 
98
                zipf.writestr(zinfo, '')
99
99
            elif ie.kind == "symlink":
100
100
                zinfo = zipfile.ZipInfo(
101
101
                            filename=(filename + '.lnk'),
112
112
        os.remove(dest)
113
113
        from bzrlib.errors import BzrError
114
114
        raise BzrError("Can't export non-ascii filenames to zip")
115
 
 
116
 
 
117
 
def zip_exporter(tree, dest, root, subdir=None, filtered=False,
118
 
                 force_mtime=None, fileobj=None):
119
 
    for _ in zip_exporter_generator(tree, dest, root, subdir, filtered,
120
 
                                    force_mtime, fileobj):
121
 
        pass