~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzr-man.py

  • Committer: Martin Pool
  • Date: 2005-09-22 13:32:02 UTC
  • Revision ID: mbp@sourcefrog.net-20050922133202-347cfd35d2941dd5
- simple weave-based annotate code (not complete)

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
    print >>sys.stderr, "bzr-man.py: error: cannot find a suitable python interpreter"
43
43
    print >>sys.stderr, "  (need %d.%d or later)" % NEED_VERS
44
44
    sys.exit(1)
45
 
if hasattr(os, "unsetenv"):
46
 
    os.unsetenv(REINVOKE)
 
45
os.unsetenv(REINVOKE)
47
46
 
48
47
import bzrlib, bzrlib.help
49
48
 
91
90
 
92
91
    def parse_line(self, line):
93
92
        m = self.usage_exp.match(line)
94
 
        if line == '':
95
 
                return
96
93
        if m:
97
94
            if self.state == 0:
98
95
                if self.usage:
99
96
                    self.command_usage.append((self.command,self.usage,self.descr))
100
97
                    self.all_commands.append(self.command)
101
 
                self.usage = " ".join(line.split(" ")[1:])
 
98
                self.usage = line
102
99
                self.command = m.groups()[0]
103
100
            else:
104
 
                raise RuntimeError, "matching usage line in state %d" % state
 
101
                raise Error, "matching usage line in state %d" % state
105
102
            self.state = 1
106
103
            return
107
104
        m = self.descr_exp.match(line)
109
106
            if self.state == 1:
110
107
                self.descr = m.groups()[0]
111
108
            else:
112
 
                raise RuntimeError, "matching descr line in state %d" % state
 
109
                raise Error, "matching descr line in state %d" % state
113
110
            self.state = 0
114
111
            return
115
 
        raise RuntimeError, "Cannot parse this line ('%s')." % line
 
112
        raise Error, "Cannot parse this line"
116
113
 
117
114
    def end_parse(self):
118
115
        if self.state == 0:
120
117
                self.command_usage.append((self.command,self.usage,self.descr))
121
118
                self.all_commands.append(self.command)
122
119
        else:
123
 
            raise RuntimeError, "ending parse in state %d" % state
 
120
            raise Error, "ending parse in state %d" % state
124
121
 
125
122
    def write_to_manpage(self, outfile):
126
123
        bzrcmd = self.params["bzrcmd"]