MultiTypeError => ValueError
This commit is contained in:
parent
80438b1495
commit
eea96cc3d1
2 changed files with 18 additions and 22 deletions
|
@ -23,6 +23,8 @@
|
|||
#ValueError if function's parameter not correct
|
||||
# or if not logical
|
||||
# or if validation falied
|
||||
# or multi must be a list
|
||||
# or error with multi length
|
||||
#TypeError if parameter has no good type
|
||||
#AttributeError if no option or optiondescription in optiondescription (also when specified a path)
|
||||
|
||||
|
@ -53,9 +55,3 @@ class PropertiesOptionError(AttributeError):
|
|||
class RequirementRecursionError(StandardError):
|
||||
"recursive error"
|
||||
pass
|
||||
|
||||
|
||||
class MultiTypeError(Exception):
|
||||
"""multi must be a list
|
||||
or error with multi length"""
|
||||
pass
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
# ____________________________________________________________
|
||||
from tiramisu.error import MultiTypeError, ConfigError
|
||||
from tiramisu.error import ConfigError
|
||||
from tiramisu.setting import owners, multitypes
|
||||
from tiramisu.autolib import carry_out_calculation
|
||||
from tiramisu.i18n import _
|
||||
|
@ -49,7 +49,7 @@ class Values(object):
|
|||
mastervalue = getattr(self.context, masterpath)
|
||||
masterlen = len(mastervalue)
|
||||
if len(value) > masterlen:
|
||||
raise MultiTypeError(_("invalid len for the slave: {0}"
|
||||
raise ValueError(_("invalid len for the slave: {0}"
|
||||
" which has {1} as master").format(
|
||||
opt._name, masterpath))
|
||||
if len(value) < masterlen:
|
||||
|
@ -163,7 +163,7 @@ class Values(object):
|
|||
for slave in opt.master_slaves:
|
||||
value_slave = self._get_value(slave)
|
||||
if len(value_slave) > masterlen:
|
||||
raise MultiTypeError(_("invalid len for the slave: {0}"
|
||||
raise ValueError(_("invalid len for the slave: {0}"
|
||||
" which has {1} as master").format(
|
||||
slave._name, opt._name))
|
||||
elif len(value_slave) < masterlen:
|
||||
|
@ -172,7 +172,7 @@ class Values(object):
|
|||
|
||||
elif opt.get_multitype() == multitypes.slave:
|
||||
if len(self._get_value(opt.master_slaves)) != len(value):
|
||||
raise MultiTypeError(_("invalid len for the slave: {0}"
|
||||
raise ValueError(_("invalid len for the slave: {0}"
|
||||
" which has {1} as master").format(
|
||||
opt._name, opt.master_slaves._name))
|
||||
if not isinstance(value, Multi):
|
||||
|
@ -181,7 +181,7 @@ class Values(object):
|
|||
|
||||
def setitem(self, opt, value):
|
||||
if type(value) == list:
|
||||
raise MultiTypeError(_("the type of the value {0} which is multi shall "
|
||||
raise ValueError(_("the type of the value {0} which is multi shall "
|
||||
"be Multi and not list").format(str(value)))
|
||||
self.values[opt] = (self.context.cfgimpl_get_settings().getowner(), value)
|
||||
|
||||
|
@ -236,7 +236,7 @@ class Multi(list):
|
|||
"""
|
||||
if not force:
|
||||
if self.opt.get_multitype() == multitypes.slave:
|
||||
raise MultiTypeError(_("cannot append a value on a multi option {0}"
|
||||
raise ValueError(_("cannot append a value on a multi option {0}"
|
||||
" which is a slave").format(self.opt._name))
|
||||
elif self.opt.get_multitype() == multitypes.master:
|
||||
for slave in self.opt.get_master_slaves():
|
||||
|
@ -264,7 +264,7 @@ class Multi(list):
|
|||
"""
|
||||
if not force:
|
||||
if self.opt.multitype == multitypes.slave:
|
||||
raise MultiTypeError(_("cannot append a value on a multi option {0}"
|
||||
raise ValueError(_("cannot append a value on a multi option {0}"
|
||||
" which is a slave").format(self.opt._name))
|
||||
elif self.opt.multitype == multitypes.master:
|
||||
for slave in self.opt.get_master_slaves():
|
||||
|
|
Loading…
Reference in a new issue