/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/export/dir_exporter.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-22 00:56:52 UTC
  • mfrom: (6621.2.26 py3_pokes)
  • Revision ID: jelmer@jelmer.uk-20170522005652-yjahcr9hwmjkno7n
Merge Python3 porting work ('py3 pokes')

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import errno
22
22
import os
23
23
 
24
 
from breezy import errors, osutils
25
 
from breezy.export import _export_iter_entries
 
24
from .. import errors, osutils
 
25
from ..export import _export_iter_entries
26
26
 
27
27
 
28
28
def dir_exporter_generator(tree, dest, root, subdir=None,
39
39
    """
40
40
    try:
41
41
        os.mkdir(dest)
42
 
    except OSError, e:
 
42
    except OSError as e:
43
43
        if e.errno == errno.EEXIST:
44
44
            # check if directory empty
45
45
            if os.listdir(dest) != []:
64
64
            try:
65
65
                symlink_target = tree.get_symlink_target(ie.file_id, tp)
66
66
                os.symlink(symlink_target, fullpath)
67
 
            except OSError, e:
 
67
            except OSError as e:
68
68
                raise errors.BzrError(
69
69
                    "Failed to create symlink %r -> %r, error: %s"
70
70
                    % (fullpath, symlink_target, e))
79
79
    for (relpath, treepath, file_id), chunks in tree.iter_files_bytes(to_fetch):
80
80
        fullpath = osutils.pathjoin(dest, relpath)
81
81
        # We set the mode and let the umask sort out the file info
82
 
        mode = 0666
 
82
        mode = 0o666
83
83
        if tree.is_executable(file_id, treepath):
84
 
            mode = 0777
 
84
            mode = 0o777
85
85
        out = os.fdopen(os.open(fullpath, flags, mode), 'wb')
86
86
        try:
87
87
            out.writelines(chunks)