/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 bzrlib/option.py

  • Committer: Ian Clatworthy
  • Date: 2007-08-31 04:07:57 UTC
  • mto: (2779.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 2783.
  • Revision ID: ian.clatworthy@internode.on.net-20070831040757-30bmwliqsxd7zn6a
Add new option tests for custom help, callbacks and verbose/quiet linkage

Show diffs side-by-side

added added

removed removed

Lines of Context:
151
151
            short_name="v" to enable parsing of -v.
152
152
 
153
153
        :param custom_callback: a callback routine to be called after normal
154
 
            processing. The signature of the callback routine is the same
155
 
            as that for normal option callbacks. See optparse in the standard
156
 
            Python library for details.
 
154
            processing. The signature of the callback routine is
 
155
            (option, name, new_value, parser).
157
156
        """
158
157
        self.name = name
159
158
        self.help = help
210
209
            self.custom_callback(option, self.name, bool_v, parser)
211
210
 
212
211
    def _optparse_callback(self, option, opt, value, parser):
213
 
        setattr(parser.values, self.name, self.type(value))
 
212
        v = self.type(value)
 
213
        setattr(parser.values, self.name, v)
214
214
        if self.custom_callback is not None:
215
 
            self.custom_callback(option, opt, value, parser)
 
215
            self.custom_callback(option, self.name, v, parser)
216
216
 
217
217
    def iter_switches(self):
218
218
        """Iterate through the list of switches provided by the option
257
257
        else:
258
258
            values.append(self.type(value))
259
259
        if self.custom_callback is not None:
260
 
            self.custom_callback(option, opt, value, parser)
 
260
            self.custom_callback(option, self.name, values, parser)
261
261
 
262
262
 
263
263
class RegistryOption(Option):
343
343
 
344
344
    def _optparse_value_callback(self, cb_value):
345
345
        def cb(option, opt, value, parser):
346
 
            setattr(parser.values, self.name, self.type(cb_value))
 
346
            v = self.type(cb_value)
 
347
            setattr(parser.values, self.name, v)
347
348
            if self.custom_callback is not None:
348
 
                self.custom_callback(option, opt, value, parser)
 
349
                self.custom_callback(option, self.name, v, parser)
349
350
        return cb
350
351
 
351
352
    def iter_switches(self):