generate _has_dependency
This commit is contained in:
parent
81f450fd7b
commit
0711fa5e62
@ -84,6 +84,7 @@ def validate_callback(callback, callback_params, type_):
|
||||
raise ValueError(_('{0}_params must have an option'
|
||||
' not a {0} for first argument'
|
||||
).format(type_, type(option)))
|
||||
option._set_has_dependency()
|
||||
if force_permissive not in [True, False]: # pragma: optional cover
|
||||
raise ValueError(_('{0}_params must have a boolean'
|
||||
' not a {0} for second argument'
|
||||
@ -133,6 +134,7 @@ class Base(StorageBase):
|
||||
if validator is not None:
|
||||
validate_callback(validator, validator_params, 'validator')
|
||||
self._set_validator(validator, validator_params)
|
||||
self._set_has_dependency()
|
||||
if calc_properties != frozenset([]) and properties is not tuple(): # pragma: optional cover
|
||||
set_forbidden_properties = calc_properties & set(properties)
|
||||
if set_forbidden_properties != frozenset():
|
||||
@ -155,6 +157,13 @@ class Base(StorageBase):
|
||||
self.impl_set_callback(callback, callback_params, _init=True)
|
||||
self.commit(session)
|
||||
|
||||
def _set_has_dependency(self):
|
||||
if not isinstance(self, SymLinkOption):
|
||||
self._has_dependency = True
|
||||
|
||||
def impl_has_dependency(self):
|
||||
return getattr(self, '_has_dependency', False)
|
||||
|
||||
def impl_set_callback(self, callback, callback_params=None, _init=False):
|
||||
if callback is None and callback_params is not None: # pragma: optional cover
|
||||
raise ValueError(_("params defined for a callback function but "
|
||||
@ -630,7 +639,7 @@ class Option(OnlyOption):
|
||||
name = self.impl_getname()
|
||||
return name
|
||||
|
||||
def _valid_consistencies(self, other_opts):
|
||||
def _valid_consistencies(self, other_opts, init=True):
|
||||
if self._is_subdyn():
|
||||
dynod = self._impl_getsubdyn()
|
||||
else:
|
||||
@ -659,6 +668,9 @@ class Option(OnlyOption):
|
||||
if is_multi != opt.impl_is_multi(): # pragma: optional cover
|
||||
raise ConfigError(_('every options in consistency must be '
|
||||
'multi or none'))
|
||||
if init:
|
||||
#consistency could generate warnings or errors
|
||||
opt._set_has_dependency()
|
||||
|
||||
def impl_add_consistency(self, func, *other_opts, **params):
|
||||
"""Add consistency means that value will be validate with other_opts
|
||||
@ -689,6 +701,8 @@ class Option(OnlyOption):
|
||||
if err:
|
||||
self._del_consistency()
|
||||
raise err
|
||||
#consistency could generate warnings or errors
|
||||
self._set_has_dependency()
|
||||
|
||||
def _valid_consistency(self, option, value, context, index, submulti_idx):
|
||||
if context is not undefined:
|
||||
@ -892,6 +906,7 @@ 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():
|
||||
@ -915,6 +930,7 @@ class SymLinkOption(OnlyOption):
|
||||
super(Base, self).__init__(name, undefined, undefined, undefined,
|
||||
undefined, undefined, undefined, undefined,
|
||||
undefined, opt, session=session)
|
||||
opt._set_has_dependency()
|
||||
self.commit(session)
|
||||
|
||||
def __getattr__(self, name, context=undefined):
|
||||
|
@ -242,6 +242,8 @@ class OptionDescription(BaseOption, StorageOptionDescription):
|
||||
"in group {1}"
|
||||
": this option is not a multi"
|
||||
"").format(child.impl_getname(), self.impl_getname()))
|
||||
#length of master change slaves length
|
||||
self._set_has_dependency()
|
||||
MasterSlaves(self.impl_getname(), children)
|
||||
else: # pragma: optional cover
|
||||
raise ValueError(_('group_type: {0}'
|
||||
|
@ -53,6 +53,7 @@ class StorageBase(object):
|
||||
'_choice_values',
|
||||
'_choice_values_params',
|
||||
#other
|
||||
'_has_dependency',
|
||||
'_state_master_slaves',
|
||||
'_state_val_call',
|
||||
'_state_requires',
|
||||
|
Loading…
Reference in New Issue
Block a user