From 44dfd21ff634854c794ba756c2cb694c7eebebc3 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Sun, 23 Oct 2016 23:18:06 +0200 Subject: [PATCH] better error msg --- tiramisu/error.py | 2 +- tiramisu/option/baseoption.py | 13 ++++++------- tiramisu/setting.py | 8 ++++---- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/tiramisu/error.py b/tiramisu/error.py index ba7b96e..2ccf27f 100644 --- a/tiramisu/error.py +++ b/tiramisu/error.py @@ -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__() diff --git a/tiramisu/option/baseoption.py b/tiramisu/option/baseoption.py index 0a3b80d..67210d7 100644 --- a/tiramisu/option/baseoption.py +++ b/tiramisu/option/baseoption.py @@ -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(): diff --git a/tiramisu/setting.py b/tiramisu/setting.py index e14fc29..212cf3d 100644 --- a/tiramisu/setting.py +++ b/tiramisu/setting.py @@ -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