~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to tools/generate_docs.py

  • Committer: Patch Queue Manager
  • Date: 2011-09-29 16:16:31 UTC
  • mfrom: (6161.1.6 491196-cmdline-options)
  • Revision ID: pqm@pqm.ubuntu.com-20110929161631-39y752x3cwcljl5w
(vila) Allow configuration options to be overridden from the command line.
 (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
 
39
39
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
40
40
 
41
 
from bzrlib import commands, doc_generate
 
41
import bzrlib
 
42
from bzrlib import (
 
43
    commands,
 
44
    doc_generate,
 
45
    )
 
46
 
42
47
 
43
48
def main(argv):
44
49
    parser = OptionParser(usage="""%prog [options] OUTPUT_FORMAT
71
76
        parser.print_help()
72
77
        sys.exit(1)
73
78
 
74
 
    commands.install_bzr_command_hooks()
75
 
 
76
 
    infogen_type = args[1]
77
 
    infogen_mod = doc_generate.get_module(infogen_type)
78
 
 
79
 
    if options.filename:
80
 
        outfilename = options.filename
81
 
    else:
82
 
        outfilename = infogen_mod.get_filename(options)
83
 
 
84
 
    if outfilename == "-":
85
 
        outfile = sys.stdout
86
 
    else:
87
 
        outfile = open(outfilename,"w")
88
 
 
89
 
    if options.show_filename and (outfilename != "-"):
90
 
        sys.stdout.write(outfilename)
91
 
        sys.stdout.write('\n')
92
 
    
93
 
    infogen_mod.infogen(options, outfile)
 
79
    with bzrlib.initialize():
 
80
        commands.install_bzr_command_hooks()
 
81
        infogen_type = args[1]
 
82
        infogen_mod = doc_generate.get_module(infogen_type)
 
83
        if options.filename:
 
84
            outfilename = options.filename
 
85
        else:
 
86
            outfilename = infogen_mod.get_filename(options)
 
87
        if outfilename == "-":
 
88
            outfile = sys.stdout
 
89
        else:
 
90
            outfile = open(outfilename,"w")
 
91
        if options.show_filename and (outfilename != "-"):
 
92
            sys.stdout.write(outfilename)
 
93
            sys.stdout.write('\n')
 
94
        infogen_mod.infogen(options, outfile)
 
95
 
94
96
 
95
97
def print_extended_help(option, opt, value, parser):
96
98
    """ Program help examples