masterlen > instead of !=
This commit is contained in:
parent
ea7d297c9b
commit
a02cb26d5f
|
@ -20,6 +20,7 @@
|
||||||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||||
# the whole pypy projet is under MIT licence
|
# the whole pypy projet is under MIT licence
|
||||||
# ____________________________________________________________
|
# ____________________________________________________________
|
||||||
|
import re
|
||||||
from types import FunctionType
|
from types import FunctionType
|
||||||
from tiramisu.basetype import HiddenBaseType, DisabledBaseType
|
from tiramisu.basetype import HiddenBaseType, DisabledBaseType
|
||||||
from tiramisu.error import (ConfigError, ConflictConfigError, NotFoundError,
|
from tiramisu.error import (ConfigError, ConflictConfigError, NotFoundError,
|
||||||
|
@ -37,6 +38,11 @@ for act1, act2 in requires_actions:
|
||||||
reverse_actions[act1] = act2
|
reverse_actions[act1] = act2
|
||||||
reverse_actions[act2] = act1
|
reverse_actions[act2] = act1
|
||||||
# ____________________________________________________________
|
# ____________________________________________________________
|
||||||
|
name_regexp = re.compile(r'^\d+')
|
||||||
|
|
||||||
|
def valid_name(name):
|
||||||
|
return re.match(name_regexp, name)
|
||||||
|
|
||||||
#
|
#
|
||||||
class Option(HiddenBaseType, DisabledBaseType):
|
class Option(HiddenBaseType, DisabledBaseType):
|
||||||
"""
|
"""
|
||||||
|
@ -68,6 +74,7 @@ class Option(HiddenBaseType, DisabledBaseType):
|
||||||
validation of the value
|
validation of the value
|
||||||
:param validator_args: the validator's parameters
|
:param validator_args: the validator's parameters
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self._name = name
|
self._name = name
|
||||||
self.doc = doc
|
self.doc = doc
|
||||||
self._requires = requires
|
self._requires = requires
|
||||||
|
|
|
@ -144,10 +144,15 @@ class Values(object):
|
||||||
if opt in self.masters:
|
if opt in self.masters:
|
||||||
masterlen = len(value)
|
masterlen = len(value)
|
||||||
for slave in self.masters[opt]:
|
for slave in self.masters[opt]:
|
||||||
if len(self._get_value(slave)) != masterlen:
|
value_slave = self._get_value(slave)
|
||||||
|
if len(value_slave) > masterlen:
|
||||||
raise MultiTypeError("invalid len for the slave: {0}"
|
raise MultiTypeError("invalid len for the slave: {0}"
|
||||||
" which has {1} as master".format(slave._name,
|
" which has {1} as master".format(slave._name,
|
||||||
opt._name))
|
opt._name))
|
||||||
|
elif len(value_slave) < masterlen:
|
||||||
|
for num in range(0, masterlen - len(value_slave)):
|
||||||
|
value_slave.append(None, force=True)
|
||||||
|
|
||||||
elif opt in self.slaves:
|
elif opt in self.slaves:
|
||||||
if len(self._get_value(self.slaves[opt])) != len(value):
|
if len(self._get_value(self.slaves[opt])) != len(value):
|
||||||
raise MultiTypeError("invalid len for the slave: {0}"
|
raise MultiTypeError("invalid len for the slave: {0}"
|
||||||
|
@ -204,7 +209,7 @@ class Multi(list):
|
||||||
if not force:
|
if not force:
|
||||||
if self.multitype == multitypes.slave:
|
if self.multitype == multitypes.slave:
|
||||||
raise MultiTypeError("cannot append a value on a multi option {0}"
|
raise MultiTypeError("cannot append a value on a multi option {0}"
|
||||||
" wich is a slave".format(self.opt._name))
|
" which is a slave".format(self.opt._name))
|
||||||
elif self.multitype == multitypes.master:
|
elif self.multitype == multitypes.master:
|
||||||
for slave in self.slaves:
|
for slave in self.slaves:
|
||||||
self.values[slave].append(None, force=True)
|
self.values[slave].append(None, force=True)
|
||||||
|
@ -227,7 +232,7 @@ class Multi(list):
|
||||||
if not force:
|
if not force:
|
||||||
if self.multitype == multitypes.slave:
|
if self.multitype == multitypes.slave:
|
||||||
raise MultiTypeError("cannot append a value on a multi option {0}"
|
raise MultiTypeError("cannot append a value on a multi option {0}"
|
||||||
" wich is a slave".format(self.opt._name))
|
" which is a slave".format(self.opt._name))
|
||||||
elif self.multitype == multitypes.master:
|
elif self.multitype == multitypes.master:
|
||||||
for slave in self.slaves:
|
for slave in self.slaves:
|
||||||
self.values[slave].pop(key, force=True)
|
self.values[slave].pop(key, force=True)
|
||||||
|
|
Loading…
Reference in New Issue