/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
2624.1.1 by Adeodato Simó
Loose python2.4-specific shebangs; use generic python instead.
1
#! /usr/bin/env python
1393.1.36 by Martin Pool
- capture_tree tool to help in preparing test cases
2
3
# Copyright (C) 2005 Canonical Ltd
4
7183.2.1 by Martin
Fix E999 lint error for Python 2 flake8
5
"""Print to stdout a description of the current directory,
1393.1.36 by Martin Pool
- capture_tree tool to help in preparing test cases
6
formatted as a Python data structure.
7
8
This can be useful in tests that need to recreate directory
9
contents."""
10
7183.2.1 by Martin
Fix E999 lint error for Python 2 flake8
11
import os
1393.1.36 by Martin Pool
- capture_tree tool to help in preparing test cases
12
import sys
13
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
14
from breezy.trace import enable_default_logging
1393.1.36 by Martin Pool
- capture_tree tool to help in preparing test cases
15
enable_default_logging()
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
16
from breezy.selftest.treeshape import capture_tree_contents
1393.1.36 by Martin Pool
- capture_tree tool to help in preparing test cases
17
18
def main(argv):
1393.1.37 by Martin Pool
- improved capture-tree representation
19
    # a lame reimplementation of pformat that splits multi-line
20
    # strings into concatenated string literals.
6619.3.3 by Jelmer Vernooij
Apply 2to3 print fix.
21
    print('[')
1393.1.36 by Martin Pool
- capture_tree tool to help in preparing test cases
22
    for tt in capture_tree_contents('.'):
1393.1.37 by Martin Pool
- improved capture-tree representation
23
        assert isinstance(tt, tuple)
6619.3.3 by Jelmer Vernooij
Apply 2to3 print fix.
24
        print('    (', repr(tt[0]) + ',', end=' ')
1393.1.39 by Martin Pool
- tweak capture_tree formatting
25
        if len(tt) == 1:
6619.3.3 by Jelmer Vernooij
Apply 2to3 print fix.
26
            print('),')
1393.1.39 by Martin Pool
- tweak capture_tree formatting
27
        else:
28
            assert len(tt) == 2
29
            val = tt[1]
6619.3.3 by Jelmer Vernooij
Apply 2to3 print fix.
30
            print()
1393.1.37 by Martin Pool
- improved capture-tree representation
31
            if val == '':
6619.3.3 by Jelmer Vernooij
Apply 2to3 print fix.
32
                print("        ''")
1393.1.37 by Martin Pool
- improved capture-tree representation
33
            else:
34
                for valline in val.splitlines(True):
6619.3.3 by Jelmer Vernooij
Apply 2to3 print fix.
35
                    print('       ', repr(valline))
36
            print('    ),')
37
    print(']')
1393.1.36 by Martin Pool
- capture_tree tool to help in preparing test cases
38
39
if __name__ == '__main__':
40
    sys.exit(main(sys.argv))