better error msg
authorEmmanuel Garette <egarette@cadoles.com>
Sun, 23 Oct 2016 21:18:06 +0000 (23:18 +0200)
committerEmmanuel Garette <egarette@cadoles.com>
Sun, 23 Oct 2016 21:18:06 +0000 (23:18 +0200)
tiramisu/error.py
tiramisu/option/baseoption.py
tiramisu/setting.py

index ba7b96e..2ccf27f 100644 (file)
@@ -50,7 +50,7 @@ class PropertiesOptionError(AttributeError):
             else:
                 prop_msg = _('properties')
             msg = display_list(msg)
-            return _('cannot access to {0} {1} because has {2} {3}').format(self._type, self._datas['path'], prop_msg, msg)
+            return _('cannot access to {0} "{1}" because has {2} {3}').format(self._type, self._datas['opt'].impl_get_display_name(), prop_msg, msg)
         else:
             return super(PropertiesOptionError, self).__str__()
 
index 0a3b80d..67210d7 100644 (file)
@@ -362,6 +362,12 @@ class BaseOption(Base):
             if not isinstance(value, unicode) and not isinstance(value, str):
                 return ValueError(_('invalid unicode or string'))
 
+    def impl_get_display_name(self):
+        name = self.impl_getdoc()
+        if name is None or name == '':
+            name = self.impl_getname()
+        return name
+
 
 class OnlyOption(BaseOption):
     __slots__ = tuple()
@@ -633,12 +639,6 @@ class Option(OnlyOption):
         "accesses the Option's doc"
         return self.impl_get_information('doc')
 
-    def impl_get_display_name(self):
-        name = self.impl_getdoc()
-        if name is None or name == '':
-            name = self.impl_getname()
-        return name
-
     def _valid_consistencies(self, other_opts, init=True):
         if self._is_subdyn():
             dynod = self._impl_getsubdyn()
@@ -906,7 +906,6 @@ def validate_requires_arg(multi, requires, name):
                                             inverse, transitive, same_action)
         else:
             ret_requires[action][option][1].append(expected)
-        option._set_has_dependency()
     # transform dict to tuple
     ret = []
     for opt_requires in ret_requires.values():
index e14fc29..212cf3d 100644 (file)
@@ -517,7 +517,7 @@ class Settings(object):
                 return PropertiesOptionError(_("cannot access to {0} {1} "
                                                "because has {2} {3}"
                                                "").format(opt_type,
-                                                          opt_or_descr._name,
+                                                          opt_or_descr.impl_get_display_name(),
                                                           prop_msg,
                                                           display_list(props)), props,
                                                           self, datas, opt_type)
@@ -689,10 +689,10 @@ class Settings(object):
                                 calc_properties.setdefault(action, []).extend(msg)
                         else:
                             if not inverse:
-                                msg = _("the value of {0} is {1}")
+                                msg = _('the value of "{0}" is {1}')
                             else:
-                                msg = _("the value of {0} is not {1}")
-                            calc_properties.setdefault(action, []).append(msg.format(reqpath, display_list(expected, 'or')))
+                                msg = _('the value of "{0}" is not {1}')
+                            calc_properties.setdefault(action, []).append(msg.format(option.impl_get_display_name(), display_list(expected, 'or')))
                     else:
                         calc_properties.add(action)
                         break