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

  • Committer: Vincent Ladeuil
  • Date: 2007-06-24 15:16:40 UTC
  • mto: (2547.2.1 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 2550.
  • Revision ID: v.ladeuil+lp@free.fr-20070624151640-5tg62jb5g9tqvybd
Fix 121889 by working around urllib2 bug.

* tests/HTTPTestUtil.py:
(DigestAuthRequestHandler.send_header_auth_reqed): python-2.4.1
fail to decode the header without the quotes. The RFC do not
require them, python >= 2.4.4 handles them gracefully. Not a big
deal.

* tests/test_http.py:
(TestAuth.setUp): Add a comment in hope I will not running around
shouting: "Who takes my traces ? Gimme my traces !" when running
the only tests who capture their own traces without showing them.

* transport/http/_urllib2_wrappers.py (BasicAuthHandler,
DigestAuthHandler): Not directly related to the bug, bug good to
fix anyway, the digest auth should be preferred to the basic
one. To do so, the digest handler should be tried before the basic
one.

* builtins.py:
(cmd_selftest.run): Fix typo. Note to reviewers: No, it's not
related to the bug. No there are no tests for that. No I don't
intend to write some :) But I'll understand if you veto that
because you want to take care of it :D

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
# Copyright 2005 Canonical Ltd.
 
4
#
 
5
# This program is free software; you can redistribute it and/or modify
 
6
# it under the terms of the GNU General Public License as published by
 
7
# the Free Software Foundation; either version 2 of the License, or
 
8
# (at your option) any later version.
 
9
#
 
10
# This program is distributed in the hope that it will be useful,
 
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
# GNU General Public License for more details.
 
14
#
 
15
# You should have received a copy of the GNU General Public License
 
16
# along with this program; if not, write to the Free Software
 
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 
 
19
"""%(prog)s - generate information from built-in bzr help
 
20
 
 
21
%(prog)s creates a file with information on bzr in one of
 
22
several different output formats:
 
23
 
 
24
    man              man page
 
25
    bash_completion  bash completion script
 
26
    ...
 
27
 
 
28
Examples: 
 
29
 
 
30
    python2.4 generated-docs.py man
 
31
    python2.4 generated-docs.py bash_completion
 
32
 
 
33
Run "%(prog)s --help" for the option reference.
 
34
"""
 
35
 
 
36
import sys
 
37
from optparse import OptionParser
 
38
 
 
39
import tools.doc_generate
 
40
 
 
41
def main(argv):
 
42
    parser = OptionParser(usage="""%prog [options] OUTPUT_FORMAT
 
43
 
 
44
Available OUTPUT_FORMAT:
 
45
 
 
46
    man              man page
 
47
    rstx             man page in ReStructuredText format
 
48
    bash_completion  bash completion script""")
 
49
 
 
50
    parser.add_option("-s", "--show-filename",
 
51
                      action="store_true", dest="show_filename", default=False,
 
52
                      help="print default filename on stdout")
 
53
 
 
54
    parser.add_option("-o", "--output", dest="filename", metavar="FILE",
 
55
                      help="write output to FILE")
 
56
 
 
57
    parser.add_option("-b", "--bzr-name",
 
58
                      dest="bzr_name", default="bzr", metavar="EXEC_NAME",
 
59
                      help="name of bzr executable")
 
60
 
 
61
    parser.add_option("-e", "--examples",
 
62
                      action="callback", callback=print_extended_help,
 
63
                      help="Examples of ways to call generate_doc")
 
64
 
 
65
 
 
66
    (options, args) = parser.parse_args(argv)
 
67
 
 
68
    if len(args) != 2:
 
69
        parser.print_help()
 
70
        sys.exit(1)
 
71
 
 
72
    infogen_type = args[1]
 
73
    infogen_mod = tools.doc_generate.get_module(infogen_type)
 
74
 
 
75
    if options.filename:
 
76
        outfilename = options.filename
 
77
    else:
 
78
        outfilename = infogen_mod.get_filename(options)
 
79
 
 
80
    if outfilename == "-":
 
81
        outfile = sys.stdout
 
82
    else:
 
83
        outfile = open(outfilename,"w")
 
84
 
 
85
    if options.show_filename and (outfilename != "-"):
 
86
        print >>sys.stdout, outfilename
 
87
    
 
88
    infogen_mod.infogen(options, outfile)
 
89
 
 
90
def print_extended_help(option, opt, value, parser):
 
91
    """ Program help examples
 
92
 
 
93
    Prints out the examples stored in the docstring. 
 
94
 
 
95
    """
 
96
    print >>sys.stdout, __doc__ % {"prog":sys.argv[0]}
 
97
    sys.exit(0)
 
98
 
 
99
if __name__ == '__main__':
 
100
    main(sys.argv)