~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/option.py

  • Committer: Patch Queue Manager
  • Date: 2011-09-08 11:01:15 UTC
  • mfrom: (6123.1.16 gpg-typo)
  • Revision ID: pqm@cupuasso-20110908110115-gbb9benwkdksvzk5
(jelmer) Fix a typo (invalid format identifier) in an error message in
 bzrlib.gpg. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
from bzrlib import (
26
26
    errors,
27
27
    revisionspec,
 
28
    i18n,
28
29
    )
29
30
""")
30
31
 
429
430
 
430
431
    DEFAULT_VALUE = object()
431
432
 
 
433
    def __init__(self):
 
434
        optparse.OptionParser.__init__(self)
 
435
        self.formatter = GettextIndentedHelpFormatter()
 
436
 
432
437
    def error(self, message):
433
438
        raise errors.BzrCommandError(message)
434
439
 
 
440
class GettextIndentedHelpFormatter(optparse.IndentedHelpFormatter):
 
441
    """Adds gettext() call to format_option()"""
 
442
    def __init__(self):
 
443
        optparse.IndentedHelpFormatter.__init__(self)
 
444
 
 
445
    def format_option(self, option):
 
446
        """code taken from Python's optparse.py"""
 
447
        if option.help:
 
448
            option.help = i18n.gettext(option.help)
 
449
        return optparse.IndentedHelpFormatter.format_option(self, option)
435
450
 
436
451
def get_optparser(options):
437
452
    """Generate an optparse parser for bzrlib-style options"""