properties=properties,
warnings_only=warnings_only)
- def impl_get_values(self, context):
+ def impl_get_values(self, context, current_opt=undefined):
+ if current_opt is undefined:
+ current_opt = self
#FIXME cache? but in context...
values = self._choice_values
if isinstance(values, FunctionType):
values_params = self._choice_values_params
if values_params is None:
values_params = {}
- values = carry_out_calculation(self, context=context,
+ values = carry_out_calculation(current_opt, context=context,
callback=values,
callback_params=values_params)
if not isinstance(values, list): # pragma: optional cover
'').format(self.impl_getname()))
return values
- def _validate(self, value, context=undefined):
+ def _validate(self, value, context=undefined, current_opt=undefined):
try:
- values = self.impl_get_values(context)
+ values = self.impl_get_values(context, current_opt=current_opt)
if not value in values: # pragma: optional cover
raise ValueError(_('value {0} is not permitted, '
'only {1} is allowed'
"represents a choice between ``True`` and ``False``"
__slots__ = tuple()
- def _validate(self, value, context=undefined):
+ def _validate(self, value, context=undefined, current_opt=undefined):
if not isinstance(value, bool):
raise ValueError(_('invalid boolean')) # pragma: optional cover
"represents a choice of an integer"
__slots__ = tuple()
- def _validate(self, value, context=undefined):
+ def _validate(self, value, context=undefined, current_opt=undefined):
if not isinstance(value, int):
raise ValueError(_('invalid integer')) # pragma: optional cover
"represents a choice of a floating point number"
__slots__ = tuple()
- def _validate(self, value, context=undefined):
+ def _validate(self, value, context=undefined, current_opt=undefined):
if not isinstance(value, float):
raise ValueError(_('invalid float')) # pragma: optional cover
"represents the choice of a string"
__slots__ = tuple()
- def _validate(self, value, context=undefined):
+ def _validate(self, value, context=undefined, current_opt=undefined):
if not isinstance(value, str):
raise ValueError(_('invalid string')) # pragma: optional cover
__slots__ = tuple()
_empty = u''
- def _validate(self, value, context=undefined):
+ def _validate(self, value, context=undefined, current_opt=undefined):
if not isinstance(value, unicode):
raise ValueError(_('invalid unicode')) # pragma: optional cover
warnings_only=warnings_only,
extra=extra)
- def _validate(self, value, context=undefined):
+ def _validate(self, value, context=undefined, current_opt=undefined):
# sometimes an ip term starts with a zero
# but this does not fit in some case, for example bind does not like it
self._impl_valid_unicode(value)
warnings_only=warnings_only,
extra=extra)
- def _validate(self, value, context=undefined):
+ def _validate(self, value, context=undefined, current_opt=undefined):
if isinstance(value, int):
value = unicode(value)
self._impl_valid_unicode(value)
"represents the choice of a network"
__slots__ = tuple()
- def _validate(self, value, context=undefined):
+ def _validate(self, value, context=undefined, current_opt=undefined):
self._impl_valid_unicode(value)
try:
IP(value)
"represents the choice of a netmask"
__slots__ = tuple()
- def _validate(self, value, context=undefined):
+ def _validate(self, value, context=undefined, current_opt=undefined):
self._impl_valid_unicode(value)
try:
IP('0.0.0.0/{0}'.format(value))
class BroadcastOption(Option):
__slots__ = tuple()
- def _validate(self, value, context=undefined):
+ def _validate(self, value, context=undefined, current_opt=undefined):
self._impl_valid_unicode(value)
try:
IP('{0}/32'.format(value))
warnings_only=warnings_only,
extra=extra)
- def _validate(self, value, context=undefined):
+ def _validate(self, value, context=undefined, current_opt=undefined):
self._impl_valid_unicode(value)
def _valid_length(val):
__slots__ = tuple()
username_re = re.compile(r"^[\w!#$%&'*+\-/=?^`{|}~.]+$")
- def _validate(self, value, context=undefined):
+ def _validate(self, value, context=undefined, current_opt=undefined):
self._impl_valid_unicode(value)
splitted = value.split('@', 1)
try:
proto_re = re.compile(r'(http|https)://')
path_re = re.compile(r"^[A-Za-z0-9\-\._~:/\?#\[\]@!%\$&\'\(\)\*\+,;=]+$")
- def _validate(self, value, context=undefined):
+ def _validate(self, value, context=undefined, current_opt=undefined):
self._impl_valid_unicode(value)
match = self.proto_re.search(value)
if not match: # pragma: optional cover
#regexp build with 'man 8 adduser' informations
username_re = re.compile(r"^[a-z_][a-z0-9_-]{0,30}[$a-z0-9_-]{0,1}$")
- def _validate(self, value, context=undefined):
+ def _validate(self, value, context=undefined, current_opt=undefined):
self._impl_valid_unicode(value)
match = self.username_re.search(value)
if not match:
__slots__ = tuple()
path_re = re.compile(r"^[a-zA-Z0-9\-\._~/+]+$")
- def _validate(self, value, context=undefined):
+ def _validate(self, value, context=undefined, current_opt=undefined):
self._impl_valid_unicode(value)
match = self.path_re.search(value)
if not match: