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

  • Committer: Jelmer Vernooij
  • Date: 2019-05-29 03:22:34 UTC
  • mfrom: (7303 work)
  • mto: This revision was merged to the branch mainline in revision 7306.
  • Revision ID: jelmer@jelmer.uk-20190529032234-mt3fuws8gq03tapi
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
    )
30
30
from .sixish import (
31
31
    text_type,
32
 
    viewitems,
33
32
    )
34
33
 
35
34
 
124
123
def _parse_merge_type(typestring):
125
124
    return get_merge_type(typestring)
126
125
 
 
126
 
127
127
def get_merge_type(typestring):
128
128
    """Attempt to find the merge class/factory associated with a string."""
129
129
    from merge import merge_types
130
130
    try:
131
131
        return merge_types[typestring][0]
132
132
    except KeyError:
133
 
        templ = '%s%%7s: %%s' % (' '*12)
 
133
        templ = '%s%%7s: %%s' % (' ' * 12)
134
134
        lines = [templ % (f[0], f[1][1]) for f in merge_types.items()]
135
135
        type_list = '\n'.join(lines)
136
136
        msg = "No known merge type %s. Supported types are:\n%s" %\
256
256
 
257
257
        :return: an iterator of (name, short_name, argname, help)
258
258
        """
259
 
        argname =  self.argname
 
259
        argname = self.argname
260
260
        if argname is not None:
261
261
            argname = argname.upper()
262
262
        yield self.name, self.short_name(), argname, self.help
319
319
            return self.converter(value)
320
320
 
321
321
    def __init__(self, name, help, registry=None, converter=None,
322
 
        value_switches=False, title=None, enum_switch=True,
323
 
        lazy_registry=None, short_name=None, short_value_switches=None):
 
322
                 value_switches=False, title=None, enum_switch=True,
 
323
                 lazy_registry=None, short_name=None, short_value_switches=None):
324
324
        """
325
325
        Constructor.
326
326
 
384
384
                if not help.endswith("."):
385
385
                    help = help + "."
386
386
        return RegistryOption(name_, help, reg, title=title,
387
 
            value_switches=value_switches, enum_switch=enum_switch)
 
387
                              value_switches=value_switches, enum_switch=enum_switch)
388
388
 
389
389
    def add_option(self, parser, short_name):
390
390
        """Add this option to an Optparse parser"""
407
407
                else:
408
408
                    help = self.registry.get_help(key)
409
409
                if (self.short_value_switches and
410
 
                    key in self.short_value_switches):
 
410
                        key in self.short_value_switches):
411
411
                    option_strings.append('-%s' %
412
412
                                          self.short_value_switches[key])
413
413
                parser.add_option(action='callback',
414
 
                              callback=self._optparse_value_callback(key),
 
414
                                  callback=self._optparse_value_callback(key),
415
415
                                  help=help,
416
416
                                  *option_strings)
417
417
 
461
461
 
462
462
class GettextIndentedHelpFormatter(optparse.IndentedHelpFormatter):
463
463
    """Adds gettext() call to format_option()"""
 
464
 
464
465
    def __init__(self):
465
466
        optparse.IndentedHelpFormatter.__init__(self)
466
467
 
496
497
    Option.STD_OPTIONS[name] = Option(name, **kwargs)
497
498
    Option.OPTIONS[name] = Option.STD_OPTIONS[name]
498
499
 
 
500
 
499
501
def _standard_list_option(name, **kwargs):
500
502
    """Register a standard option."""
501
503
    # All standard options are implicitly 'global' ones
572
574
               short_name='m',
573
575
               help='Message string.')
574
576
_global_option('null', short_name='0',
575
 
                 help='Use an ASCII NUL (\\0) separator rather than '
576
 
                      'a newline.')
 
577
               help='Use an ASCII NUL (\\0) separator rather than '
 
578
               'a newline.')
577
579
_global_option('overwrite', help='Ignore differences between branches and '
578
580
               'overwrite unconditionally.')
579
581
_global_option('remember', help='Remember the specified location as a'