~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to tools/capture_tree.py

  • Committer: Martin Pool
  • Date: 2005-10-04 10:20:39 UTC
  • mto: (1185.13.3)
  • mto: This revision was merged to the branch mainline in revision 1403.
  • Revision ID: mbp@sourcefrog.net-20051004102039-70c6306aaa352a62
- improved capture-tree representation

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
This can be useful in tests that need to recreate directory
9
9
contents."""
10
10
 
11
 
# TODO: It'd be nice if this split long strings across 
12
 
# multiple lines, relying on Python concatenation of consecutive
13
 
# string constants.
14
 
 
15
11
import sys
16
12
import os
17
 
import pprint
18
13
 
19
14
from bzrlib.trace import enable_default_logging
20
15
enable_default_logging()
21
16
from bzrlib.selftest.treeshape import capture_tree_contents
22
17
 
23
18
def main(argv):
 
19
    # a lame reimplementation of pformat that splits multi-line
 
20
    # strings into concatenated string literals.
24
21
    print '['
25
22
    for tt in capture_tree_contents('.'):
26
 
        print `tt`, ','
 
23
        assert isinstance(tt, tuple)
 
24
        print '  ('
 
25
        for val in tt:
 
26
            if val == '':
 
27
                print "    ''"
 
28
            else:
 
29
                for valline in val.splitlines(True):
 
30
                    print '   ', repr(valline)
 
31
            print '    ,'
 
32
        print '  ),'
27
33
    print ']'
28
34
 
29
35
if __name__ == '__main__':