From f2614469c5ef9137ca1891d7393396409d275b06 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 11 Sep 2017 22:36:45 +0200 Subject: [PATCH] configuration: converter() -> get_converter() --- cdist/configuration.py | 22 +++++++++++----------- cdist/test/configuration/__init__.py | 14 +++++++------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cdist/configuration.py b/cdist/configuration.py index 4a8274d8..8600cb0c 100644 --- a/cdist/configuration.py +++ b/cdist/configuration.py @@ -53,7 +53,7 @@ class OptionBase: def __init__(self, name): self.name = name - def converter(self, *args, **kwargs): + def get_converter(self, *args, **kwargs): raise NotImplementedError('Subclass should implement this method') def translate(self, val): @@ -83,7 +83,7 @@ class StringOption(OptionBase): def __init__(self, name): super().__init__(name) - def converter(self): + def get_converter(self): def string_converter(val): return self.translate(str(val)) return string_converter @@ -101,7 +101,7 @@ class BooleanOption(OptionBase): def __init__(self, name): super().__init__(name) - def converter(self): + def get_converter(self): def boolean_converter(val): v = val.lower() if v not in self.BOOLEAN_STATES: @@ -118,7 +118,7 @@ class IntOption(OptionBase): def __init__(self, name): super().__init__(name) - def converter(self): + def get_converter(self): def int_converter(val): return self.translate(int(val)) return int_converter @@ -129,9 +129,9 @@ class LowerBoundIntOption(IntOption): super().__init__(name) self.lower_bound = lower_bound - def converter(self): + def get_converter(self): def lower_bound_converter(val): - converted = super(LowerBoundIntOption, self).converter()(val) + converted = super(LowerBoundIntOption, self).get_converter()(val) if converted < self.lower_bound: raise ValueError("Invalid {} value: {} < {}".format( self.name, val, self.lower_bound)) @@ -161,7 +161,7 @@ class SelectOption(OptionBase): super().__init__(name) self.valid_values = valid_values - def converter(self): + def get_converter(self): def select_converter(val): if val in self.valid_values: return self.translate(val) @@ -186,7 +186,7 @@ class DelimitedValuesOption(OptionBase): super().__init__(name) self.delimiter = delimiter - def converter(self): + def get_converter(self): def delimited_values_converter(val): vals = re.split(r'(?