~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzr_man.py

  • Committer: John Arbash Meinel
  • Date: 2005-12-01 17:36:29 UTC
  • mto: (1185.50.19 bzr-jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1532.
  • Revision ID: john@arbash-meinel.com-20051201173629-aecb08238e0976a2
Removing instances of os.sep

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
import os, sys
23
23
 
24
 
try:
25
 
    version_info = sys.version_info
26
 
except AttributeError:
27
 
    version_info = 1, 5 # 1.5 or older
28
 
 
29
 
 
30
 
REINVOKE = "__BZR_REINVOKE"    
31
 
NEED_VERS = (2, 3)
32
 
 
33
 
if version_info < NEED_VERS:
34
 
    if not os.environ.has_key(REINVOKE):
35
 
        # mutating os.environ doesn't work in old Pythons
36
 
        os.putenv(REINVOKE, "1")
37
 
        for python in 'python2.4', 'python2.3':
38
 
            try:
39
 
                os.execvp(python, [python] + sys.argv)
40
 
            except OSError:
41
 
                pass
42
 
    print >>sys.stderr, "bzr-man.py: error: cannot find a suitable python interpreter"
43
 
    print >>sys.stderr, "  (need %d.%d or later)" % NEED_VERS
44
 
    sys.exit(1)
45
 
os.unsetenv(REINVOKE)
46
 
 
47
24
import bzrlib, bzrlib.help
48
25
 
49
26
#>>> code taken from bzr (C) Canonical
90
67
 
91
68
    def parse_line(self, line):
92
69
        m = self.usage_exp.match(line)
 
70
        if line == '':
 
71
                return
93
72
        if m:
94
73
            if self.state == 0:
95
74
                if self.usage:
96
75
                    self.command_usage.append((self.command,self.usage,self.descr))
97
76
                    self.all_commands.append(self.command)
98
 
                self.usage = line
 
77
                self.usage = " ".join(line.split(" ")[1:])
99
78
                self.command = m.groups()[0]
100
79
            else:
101
 
                raise Error, "matching usage line in state %d" % state
 
80
                raise RuntimeError, "matching usage line in state %d" % state
102
81
            self.state = 1
103
82
            return
104
83
        m = self.descr_exp.match(line)
106
85
            if self.state == 1:
107
86
                self.descr = m.groups()[0]
108
87
            else:
109
 
                raise Error, "matching descr line in state %d" % state
 
88
                raise RuntimeError, "matching descr line in state %d" % state
110
89
            self.state = 0
111
90
            return
112
 
        raise Error, "Cannot parse this line"
 
91
        raise RuntimeError, "Cannot parse this line ('%s')." % line
113
92
 
114
93
    def end_parse(self):
115
94
        if self.state == 0:
117
96
                self.command_usage.append((self.command,self.usage,self.descr))
118
97
                self.all_commands.append(self.command)
119
98
        else:
120
 
            raise Error, "ending parse in state %d" % state
 
99
            raise RuntimeError, "ending parse in state %d" % state
121
100
 
122
101
    def write_to_manpage(self, outfile):
123
102
        bzrcmd = self.params["bzrcmd"]
124
103
        outfile.write('.SH "COMMAND OVERVIEW"\n')
125
104
        for (command,usage,descr) in self.command_usage:
126
 
            outfile.write('.TP\n.B "%s %s"\n%s\n\n' % (bzrcmd, usage, descr))
 
105
            outfile.write('.TP\n.B "%s %s"\n%s\n' % (bzrcmd, usage, descr))
127
106
 
128
107
 
129
108
class HelpReader:
193
172
Path where
194
173
.B "%(bzrcmd)s"
195
174
is to look for external command.
196
 
 
197
175
.TP
198
176
.I "BZREMAIL"
199
177
E-Mail address of the user. Overrides
201
179
.IR "EMAIL" .
202
180
Example content:
203
181
.I "John Doe <john@example.com>"
204
 
 
205
182
.TP
206
183
.I "EMAIL"
207
184
E-Mail address of the user. Overridden by the content of the file
208
185
.I "~/.bzr.conf/email"
209
186
and of the environment variable
210
187
.IR "BZREMAIL" .
211
 
 
212
188
.SH "FILES"
213
189
.TP
214
190
.I "~/.bzr.conf/"
219
195
.I "EMAIL"
220
196
environment variable. Example content:
221
197
.I "John Doe <john@example.com>"
222
 
 
223
198
.SH "SEE ALSO"
224
199
.UR http://www.bazaar-ng.org/
225
200
.BR http://www.bazaar-ng.org/,