/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 tools/generate_docs.py

  • Committer: Breezy landing bot
  • Author(s): Colin Watson
  • Date: 2020-11-16 21:47:08 UTC
  • mfrom: (7521.1.1 remove-lp-workaround)
  • Revision ID: breezy.the.bot@gmail.com-20201116214708-jos209mgxi41oy15
Remove breezy.git workaround for bazaar.launchpad.net.

Merged from https://code.launchpad.net/~cjwatson/brz/remove-lp-workaround/+merge/393710

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
 
1
#!/usr/bin/python3
2
2
 
3
3
# Copyright 2005 Canonical Ltd.
4
4
#
16
16
# along with this program; if not, write to the Free Software
17
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
 
19
 
"""%(prog)s - generate information from built-in bzr help
 
19
"""%(prog)s - generate information from built-in brz help
20
20
 
21
 
%(prog)s creates a file with information on bzr in one of
 
21
%(prog)s creates a file with information on brz in one of
22
22
several different output formats:
23
23
 
24
24
    man              man page
25
25
    bash_completion  bash completion script
26
26
    ...
27
27
 
28
 
Examples: 
 
28
Examples:
29
29
 
30
 
    python2.4 generated-docs.py man
31
 
    python2.4 generated-docs.py bash_completion
 
30
    python generated-docs.py man
 
31
    python generated-docs.py bash_completion
32
32
 
33
33
Run "%(prog)s --help" for the option reference.
34
34
"""
38
38
 
39
39
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
40
40
 
41
 
import bzrlib
42
 
from bzrlib import (
 
41
import breezy
 
42
from breezy import (
43
43
    commands,
44
 
    # Don't remove the following import, it triggers a format registration that
45
 
    # avoid http://pad.lv/956860
46
 
    branch,
47
44
    doc_generate,
48
45
    )
49
46
 
64
61
    parser.add_option("-o", "--output", dest="filename", metavar="FILE",
65
62
                      help="write output to FILE")
66
63
 
67
 
    parser.add_option("-b", "--bzr-name",
68
 
                      dest="bzr_name", default="bzr", metavar="EXEC_NAME",
69
 
                      help="name of bzr executable")
 
64
    parser.add_option("-b", "--brz-name",
 
65
                      dest="brz_name", default="brz", metavar="EXEC_NAME",
 
66
                      help="name of brz executable")
70
67
 
71
68
    parser.add_option("-e", "--examples",
72
69
                      action="callback", callback=print_extended_help,
79
76
        parser.print_help()
80
77
        sys.exit(1)
81
78
 
82
 
    with bzrlib.initialize():
 
79
    with breezy.initialize():
 
80
        # Import breezy.bzr for format registration, see <http://pad.lv/956860>
 
81
        from breezy import bzr as _
83
82
        commands.install_bzr_command_hooks()
84
83
        infogen_type = args[1]
85
84
        infogen_mod = doc_generate.get_module(infogen_type)
90
89
        if outfilename == "-":
91
90
            outfile = sys.stdout
92
91
        else:
93
 
            outfile = open(outfilename,"w")
 
92
            outfile = open(outfilename, "w")
94
93
        if options.show_filename and (outfilename != "-"):
95
94
            sys.stdout.write(outfilename)
96
95
            sys.stdout.write('\n')
100
99
def print_extended_help(option, opt, value, parser):
101
100
    """ Program help examples
102
101
 
103
 
    Prints out the examples stored in the docstring. 
 
102
    Prints out the examples stored in the docstring.
104
103
 
105
104
    """
106
 
    sys.stdout.write(__doc__ % {"prog":sys.argv[0]})
 
105
    sys.stdout.write(__doc__ % {"prog": sys.argv[0]})
107
106
    sys.stdout.write('\n')
108
107
    sys.exit(0)
109
108