/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: 2018-11-16 23:19:12 UTC
  • mfrom: (7180 work)
  • mto: This revision was merged to the branch mainline in revision 7294.
  • Revision ID: jelmer@jelmer.uk-20181116231912-e043vpq22bdkxa6q
Merge trunk.

Show diffs side-by-side

added added

removed removed

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