diff options
Diffstat (limited to 'lorrycontroller')
-rw-r--r-- | lorrycontroller/readconf.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/lorrycontroller/readconf.py b/lorrycontroller/readconf.py index b95b9de..875e982 100644 --- a/lorrycontroller/readconf.py +++ b/lorrycontroller/readconf.py @@ -319,8 +319,8 @@ class LorryControllerConfValidator(object): def validate_config(self, conf_obj): try: - self._check_is_list(conf_obj) - self._check_is_list_of_dicts(conf_obj) + self.check_is_list(conf_obj) + self.check_is_list_of_dicts(conf_obj) for section in conf_obj: if 'type' not in section: @@ -343,12 +343,12 @@ class LorryControllerConfValidator(object): return None - def _check_is_list(self, conf_obj): + def check_is_list(self, conf_obj): if type(conf_obj) is not list: raise ValidationError( 'type %r is not a JSON list' % type(conf_obj)) - def _check_is_list_of_dicts(self, conf_obj): + def check_is_list_of_dicts(self, conf_obj): for item in conf_obj: if type(item) is not dict: raise ValidationError('all items must be dicts') @@ -359,14 +359,14 @@ class LorryControllerConfValidator(object): def _check_host_section(self, section): if not any(i in ('trovehost', 'host') for i in section): - self._check_has_required_fields(section, ['host']) - self._check_has_required_fields( + self.check_has_required_fields(section, ['host']) + self.check_has_required_fields( section, ['protocol', 'interval', 'ls-interval', 'prefixmap']) self._check_protocol(section) self._check_prefixmap(section) if 'ignore' in section: - self._check_is_list_of_strings(section, 'ignore') + self.check_is_list_of_strings(section, 'ignore') def _check_protocol(self, section): valid = ('ssh', 'http', 'https') @@ -383,18 +383,18 @@ class LorryControllerConfValidator(object): pass def _check_lorries_section(self, section): - self._check_has_required_fields( + self.check_has_required_fields( section, ['interval', 'prefix', 'globs']) - self._check_is_list_of_strings(section, 'globs') + self.check_is_list_of_strings(section, 'globs') - def _check_has_required_fields(self, section, fields): + def check_has_required_fields(self, section, fields): for field in fields: if field not in section: raise ValidationError( 'mandatory field %s missing in section %r' % (field, section)) - def _check_is_list_of_strings(self, section, field): + def check_is_list_of_strings(self, section, field): obj = section[field] if not isinstance(obj, list) or not all( isinstance(s, str) for s in obj): |