Merge branch 'master' into orm
authorEmmanuel Garette <egarette@cadoles.com>
Tue, 4 Feb 2014 20:48:20 +0000 (21:48 +0100)
committerEmmanuel Garette <egarette@cadoles.com>
Tue, 4 Feb 2014 20:54:30 +0000 (21:54 +0100)
Conflicts:
tiramisu/config.py
tiramisu/option.py

1  2 
test/test_config_api.py
tiramisu/config.py
tiramisu/option.py
tiramisu/setting.py
tiramisu/value.py

Simple merge
@@@ -434,22 -449,16 +434,19 @@@ class SubConfig(object)
  
      def _make_sub_dict(self, opt, path, pathsvalues, _currpath, flatten):
          if isinstance(opt, OptionDescription):
-             try:
-                 pathsvalues += getattr(self, path).make_dict(flatten,
-                                                              _currpath +
-                                                              path.split('.'))
-             except PropertiesOptionError:
-                 pass  # this just a hidden or disabled option
+             pathsvalues += getattr(self, path).make_dict(flatten,
+                                                          _currpath +
+                                                          path.split('.'))
          else:
 -            value = self._getattr(opt._name)
 -            if flatten:
 -                name = opt._name
 -            else:
 -                name = '.'.join(_currpath + [opt._name])
 -            pathsvalues.append((name, value))
 +            try:
 +                value = self._getattr(opt.impl_getname())
 +                if flatten:
 +                    name = opt.impl_getname()
 +                else:
 +                    name = '.'.join(_currpath + [opt.impl_getname()])
 +                pathsvalues.append((name, value))
 +            except PropertiesOptionError:
 +                pass  # this just a hidden or disabled option
  
      def cfgimpl_get_path(self):
          descr = self.cfgimpl_get_description()
@@@ -704,21 -653,19 +704,21 @@@ class ChoiceOption(Option)
                                             validator=validator,
                                             validator_params=validator_params,
                                             properties=properties,
 -                                           warnings_only=warnings_only)
 +                                           warnings_only=warnings_only,
 +                                           choice_values=values,
 +                                           choice_open_values=open_values)
  
      def impl_get_values(self):
 -        return self._values
 +        return self._choice_values
  
      def impl_is_openvalues(self):
 -        return self._open_values
 +        return self._choice_open_values
  
      def _validate(self, value):
-         if not self._choice_open_values and not value in self._choice_values:
+         if not self.impl_is_openvalues() and not value in self.impl_get_values():
              raise ValueError(_('value {0} is not permitted, '
                                 'only {1} is allowed'
 -                               '').format(value, self._values))
 +                               '').format(value, self._choice_values))
  
  
  class BoolOption(Option):
@@@ -899,24 -855,27 +903,29 @@@ class PortOption(Option)
                                           validator_params=validator_params,
                                           properties=properties,
                                           warnings_only=warnings_only)
 +        self._extra = extra
  
      def _validate(self, value):
 -        if self._allow_range and ":" in str(value):
 +        if self._extra['_allow_range'] and ":" in str(value):
              value = str(value).split(':')
              if len(value) != 2:
-                 raise ValueError('invalid part, range must have two values '
-                                  'only')
+                 raise ValueError(_('invalid part, range must have two values '
+                                  'only'))
              if not value[0] < value[1]:
-                 raise ValueError('invalid port, first port in range must be'
-                                  ' smaller than the second one')
+                 raise ValueError(_('invalid port, first port in range must be'
+                                  ' smaller than the second one'))
          else:
              value = [value]
  
          for val in value:
-             if not self._extra['_min_value'] <= int(val) <= self._extra['_max_value']:
-                 raise ValueError('invalid port, must be an between {0} and {1}'
-                                  ''.format(self._extra['_min_value'], self._extra['_max_value']))
+             try:
 -                if not self._min_value <= int(val) <= self._max_value:
 -                    raise ValueError(_('invalid port, must be an between {0} '
 -                                     'and {1}').format(self._min_value,
 -                                                      self._max_value))
++                if not self._extra['_min_value'] <= int(val) <= self._extra['_max_value']:
++                    raise ValueError('invalid port, must be an between {0} '
++                                     'and {1}'.format(
++                                         self._extra['_min_value'],
++                                         self._extra['_max_value']))
+             except ValueError:
+                 raise ValueError(_('invalid port'))
  
  
  class NetworkOption(Option):
Simple merge
Simple merge