/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 brzlib/tests/treeshape.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 12:41:27 UTC
  • mto: This revision was merged to the branch mainline in revision 6623.
  • Revision ID: jelmer@jelmer.uk-20170521124127-iv8etg0vwymyai6y
s/bzr/brz/ in apport config.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
import os
31
31
import stat
32
32
 
33
 
from ..trace import warning
34
 
from ..osutils import pathjoin
35
 
 
 
33
from brzlib.trace import warning
 
34
from brzlib.osutils import pathjoin
36
35
 
37
36
def build_tree_contents(template):
38
37
    """Reconstitute some files from a text description.
54
53
        elif name[-1] == '@':
55
54
            os.symlink(tt[1], tt[0][:-1])
56
55
        else:
57
 
            with open(name, 'w' + ('b' if isinstance(tt[1], bytes) else '')) as f:
 
56
            f = file(name, 'wb')
 
57
            try:
58
58
                f.write(tt[1])
 
59
            finally:
 
60
                f.close()
59
61
 
60
62
 
61
63
def capture_tree_contents(top):
73
75
            if stat.S_ISLNK(info.st_mode):
74
76
                yield (fullpath + '@', os.readlink(fullpath))
75
77
            elif stat.S_ISREG(info.st_mode):
76
 
                with open(fullpath, 'rb') as f:
77
 
                    file_bytes = f.read()
78
 
                yield (fullpath, file_bytes)
 
78
                yield (fullpath, file(fullpath, 'rb').read())
79
79
            else:
80
80
                warning("can't capture file %s with mode %#o",
81
81
                        fullpath, info.st_mode)