~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-08-12 10:54:51 UTC
  • mfrom: (6059.1.7 integer-option)
  • Revision ID: pqm@pqm.ubuntu.com-20110812105451-s1i361x4d409godc
(vila) Implement integer config options. (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2293
2293
 
2294
2294
        :param invalid: the action to be taken when an invalid value is
2295
2295
            encountered in a store. This is called only when from_unicode is
2296
 
            invoked to convert a string and returns None or raise
2297
 
            ValueError. Accepted values are: None (ignore invalid values),
2298
 
            'warning' (emit a warning), 'error' emit an error message and
2299
 
            terminates.
 
2296
            invoked to convert a string and returns None or raise ValueError or
 
2297
            TypeError. Accepted values are: None (ignore invalid values),
 
2298
            'warning' (emit a warning), 'error' (emit an error message and
 
2299
            terminates).
2300
2300
        """
2301
2301
        self.name = name
2302
2302
        self.default = default
2315
2315
    return ui.bool_from_string(unicode_str)
2316
2316
 
2317
2317
 
 
2318
def int_from_store(unicode_str):
 
2319
    return int(unicode_str)
 
2320
 
 
2321
 
2318
2322
class OptionRegistry(registry.Registry):
2319
2323
    """Register config options by their name.
2320
2324
 
2855
2859
            # If a value exists and the option provides a converter, use it
2856
2860
            try:
2857
2861
                converted = opt.from_unicode(value)
2858
 
            except ValueError:
 
2862
            except (ValueError, TypeError):
2859
2863
                # Invalid values are ignored
2860
2864
                converted = None
2861
2865
            if converted is None and opt.invalid is not None: