~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to tools/generate_docs.py

  • Committer: Martin Packman
  • Date: 2012-03-27 17:32:19 UTC
  • mto: (6437.54.3 2.5)
  • mto: This revision was merged to the branch mainline in revision 6525.
  • Revision ID: martin.packman@canonical.com-20120327173219-401pil42gke8j0xh
Fall back to sys.prefix not /usr when looking for .mo files

Show diffs side-by-side

added added

removed removed

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