~bzr-pqm/bzr/bzr.dev

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#! /usr/bin/env python2.4

# Copyright (C) 2005 Canonical Ltd

"""Print to stdout a description of the current directory, 
formatted as a Python data structure.

This can be useful in tests that need to recreate directory
contents."""

import sys
import os

from bzrlib.trace import enable_default_logging
enable_default_logging()
from bzrlib.selftest.treeshape import capture_tree_contents

def main(argv):
    # a lame reimplementation of pformat that splits multi-line
    # strings into concatenated string literals.
    print '['
    for tt in capture_tree_contents('.'):
        assert isinstance(tt, tuple)
        print '  ('
        for val in tt:
            if val == '':
                print "    ''"
            else:
                for valline in val.splitlines(True):
                    print '   ', repr(valline)
            print '    ,'
        print '  ),'
    print ']'

if __name__ == '__main__':
    sys.exit(main(sys.argv))