/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: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python3
 
1
#!/usr/bin/python
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 brz help
 
19
"""%(prog)s - generate information from built-in bzr help
20
20
 
21
 
%(prog)s creates a file with information on brz in one of
 
21
%(prog)s creates a file with information on bzr 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
 
    python generated-docs.py man
31
 
    python generated-docs.py bash_completion
 
30
    python2.4 generated-docs.py man
 
31
    python2.4 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 breezy
42
 
from breezy import (
 
41
import bzrlib
 
42
from bzrlib 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,
44
47
    doc_generate,
45
48
    )
46
49
 
61
64
    parser.add_option("-o", "--output", dest="filename", metavar="FILE",
62
65
                      help="write output to FILE")
63
66
 
64
 
    parser.add_option("-b", "--brz-name",
65
 
                      dest="brz_name", default="brz", metavar="EXEC_NAME",
66
 
                      help="name of brz executable")
 
67
    parser.add_option("-b", "--bzr-name",
 
68
                      dest="bzr_name", default="bzr", metavar="EXEC_NAME",
 
69
                      help="name of bzr executable")
67
70
 
68
71
    parser.add_option("-e", "--examples",
69
72
                      action="callback", callback=print_extended_help,
76
79
        parser.print_help()
77
80
        sys.exit(1)
78
81
 
79
 
    with breezy.initialize():
80
 
        # Import breezy.bzr for format registration, see <http://pad.lv/956860>
81
 
        from breezy import bzr as _
 
82
    with bzrlib.initialize():
82
83
        commands.install_bzr_command_hooks()
83
84
        infogen_type = args[1]
84
85
        infogen_mod = doc_generate.get_module(infogen_type)
89
90
        if outfilename == "-":
90
91
            outfile = sys.stdout
91
92
        else:
92
 
            outfile = open(outfilename, "w")
 
93
            outfile = open(outfilename,"w")
93
94
        if options.show_filename and (outfilename != "-"):
94
95
            sys.stdout.write(outfilename)
95
96
            sys.stdout.write('\n')
99
100
def print_extended_help(option, opt, value, parser):
100
101
    """ Program help examples
101
102
 
102
 
    Prints out the examples stored in the docstring.
 
103
    Prints out the examples stored in the docstring. 
103
104
 
104
105
    """
105
 
    sys.stdout.write(__doc__ % {"prog": sys.argv[0]})
 
106
    sys.stdout.write(__doc__ % {"prog":sys.argv[0]})
106
107
    sys.stdout.write('\n')
107
108
    sys.exit(0)
108
109