better error msg
This commit is contained in:
parent
9a912376b9
commit
44dfd21ff6
|
@ -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__()
|
||||
|
||||
|
|
|
@ -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():
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue