/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
from __future__ import print_function
12
13
import os
1393.1.36 by Martin Pool
- capture_tree tool to help in preparing test cases
14
import sys
15
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
16
from breezy.trace import enable_default_logging
1393.1.36 by Martin Pool
- capture_tree tool to help in preparing test cases
17
enable_default_logging()
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
18
from breezy.selftest.treeshape import capture_tree_contents
1393.1.36 by Martin Pool
- capture_tree tool to help in preparing test cases
19
20
def main(argv):
1393.1.37 by Martin Pool
- improved capture-tree representation
21
    # a lame reimplementation of pformat that splits multi-line
22
    # strings into concatenated string literals.
6619.3.3 by Jelmer Vernooij
Apply 2to3 print fix.
23
    print('[')
1393.1.36 by Martin Pool
- capture_tree tool to help in preparing test cases
24
    for tt in capture_tree_contents('.'):
1393.1.37 by Martin Pool
- improved capture-tree representation
25
        assert isinstance(tt, tuple)
6619.3.3 by Jelmer Vernooij
Apply 2to3 print fix.
26
        print('    (', repr(tt[0]) + ',', end=' ')
1393.1.39 by Martin Pool
- tweak capture_tree formatting
27
        if len(tt) == 1:
6619.3.3 by Jelmer Vernooij
Apply 2to3 print fix.
28
            print('),')
1393.1.39 by Martin Pool
- tweak capture_tree formatting
29
        else:
30
            assert len(tt) == 2
31
            val = tt[1]
6619.3.3 by Jelmer Vernooij
Apply 2to3 print fix.
32
            print()
1393.1.37 by Martin Pool
- improved capture-tree representation
33
            if val == '':
6619.3.3 by Jelmer Vernooij
Apply 2to3 print fix.
34
                print("        ''")
1393.1.37 by Martin Pool
- improved capture-tree representation
35
            else:
36
                for valline in val.splitlines(True):
6619.3.3 by Jelmer Vernooij
Apply 2to3 print fix.
37
                    print('       ', repr(valline))
38
            print('    ),')
39
    print(']')
1393.1.36 by Martin Pool
- capture_tree tool to help in preparing test cases
40
41
if __name__ == '__main__':
42
    sys.exit(main(sys.argv))