review exception

This commit is contained in:
2013-04-14 12:01:32 +02:00
parent fbcbbfbd2b
commit 9357b342c1
12 changed files with 130 additions and 144 deletions

View File

@ -21,8 +21,8 @@
# the whole pypy projet is under MIT licence
# ____________________________________________________________
from tiramisu.error import (RequirementRecursionError, PropertiesOptionError,
NotFoundError)
from tiramisu.error import RequirementRecursionError, PropertiesOptionError
from tiramisu.i18n import _
class _const:
@ -33,13 +33,13 @@ class _const:
def __setattr__(self, name, value):
if name in self.__dict__:
raise self.ConstError, "Can't rebind group ({})".format(name)
raise self.ConstError, _("Can't rebind group ({})").format(name)
self.__dict__[name] = value
def __delattr__(self, name):
if name in self.__dict__:
raise self.ConstError, "Can't unbind group ({})".format(name)
raise NameError(name)
raise self.ConstError, _("Can't unbind group ({})").format(name)
raise ValueError(name)
# ____________________________________________________________
@ -216,14 +216,14 @@ class Setting(object):
def set_permissive(self, permissive, opt=None):
if not isinstance(permissive, list):
raise TypeError('permissive must be a list')
raise TypeError(_('permissive must be a list'))
self.permissives[opt] = permissive
#____________________________________________________________
def setowner(self, owner):
":param owner: sets the default value for owner at the Config level"
if not isinstance(owner, owners.Owner):
raise TypeError("invalid generic owner {0}".format(str(owner)))
raise TypeError(_("invalid generic owner {0}").format(str(owner)))
self.owner = owner
def getowner(self):
@ -275,18 +275,19 @@ def apply_requires(opt, config):
elif len(require) == 4:
path, expected, action, inverse = require
if path == optpath or path.startswith(optpath + '.'):
raise RequirementRecursionError("malformed requirements "
raise RequirementRecursionError(_("malformed requirements "
"imbrication detected for option: '{0}' "
"with requirement on: '{1}'".format(optpath, path))
"with requirement on: '{1}'").format(optpath, path))
try:
value = config.cfgimpl_get_context()._getattr(path, force_permissive=True)
except PropertiesOptionError, err:
properties = err.proptype
raise NotFoundError("option '{0}' has requirement's property error: "
"{1} {2}".format(opt._name, path, properties))
#FIXME: AttributeError or PropertiesOptionError ?
raise AttributeError(_("option '{0}' has requirement's property error: "
"{1} {2}").format(opt._name, path, properties))
except AttributeError:
raise NotFoundError("required option not found: "
"{0}".format(path))
raise AttributeError(_("required option not found: "
"{0}").format(path))
if value == expected:
if inverse:
setting.del_property(action, opt, False)