require with slaves
This commit is contained in:
@ -703,6 +703,86 @@ class Values(object):
|
||||
|
||||
#______________________________________________________________________
|
||||
# mandatory warnings
|
||||
def _mandatory_warnings(self,
|
||||
context,
|
||||
config_bag,
|
||||
description,
|
||||
currpath,
|
||||
config,
|
||||
od_setting_properties):
|
||||
settings = context.cfgimpl_get_settings()
|
||||
is_masterslaves = description.impl_is_master_slaves()
|
||||
lenmaster = None
|
||||
optmaster = None
|
||||
pathmaster = None
|
||||
for option in description.impl_getchildren(config_bag, context):
|
||||
sconfig_bag = config_bag.copy('nooption')
|
||||
sconfig_bag.option = option
|
||||
name = option.impl_getname()
|
||||
path = '.'.join(currpath + [name])
|
||||
|
||||
if option.impl_is_optiondescription():
|
||||
sconfig_bag.setting_properties = od_setting_properties
|
||||
try:
|
||||
subconfig = config.getattr(name,
|
||||
None,
|
||||
sconfig_bag)
|
||||
except PropertiesOptionError as err:
|
||||
pass
|
||||
else:
|
||||
for path in self._mandatory_warnings(context,
|
||||
config_bag,
|
||||
option,
|
||||
currpath + [name],
|
||||
subconfig,
|
||||
od_setting_properties):
|
||||
yield path
|
||||
elif not option.impl_is_symlinkoption():
|
||||
# don't verifying symlink
|
||||
try:
|
||||
if not option.impl_is_master_slaves('slave'):
|
||||
self_properties = settings.getproperties(path,
|
||||
None,
|
||||
sconfig_bag)
|
||||
|
||||
sconfig_bag.properties = self_properties
|
||||
if 'mandatory' in self_properties or 'empty' in self_properties:
|
||||
value = config.getattr(name,
|
||||
None,
|
||||
sconfig_bag)
|
||||
if is_masterslaves:
|
||||
lenmaster = len(value)
|
||||
pathmaster = name
|
||||
optmaster = option
|
||||
else:
|
||||
if lenmaster is None:
|
||||
# master is a length (so int) if value is already calculated
|
||||
# otherwise get value and calculate length
|
||||
nconfig_bag = config_bag.copy('nooption')
|
||||
nconfig_bag.option = optmaster
|
||||
values = config.getattr(pathmaster,
|
||||
None,
|
||||
nconfig_bag)
|
||||
lenmaster = len(values)
|
||||
for index in range(lenmaster):
|
||||
self_properties = settings.getproperties(path,
|
||||
index,
|
||||
sconfig_bag)
|
||||
|
||||
sconfig_bag.properties = self_properties
|
||||
values = config.getattr(name,
|
||||
index,
|
||||
sconfig_bag)
|
||||
except PropertiesOptionError as err:
|
||||
if err.proptype == ['mandatory']:
|
||||
yield path
|
||||
if is_masterslaves and lenmaster is None:
|
||||
break
|
||||
except ConfigError as err:
|
||||
#assume that uncalculated value is an empty value
|
||||
yield path
|
||||
if is_masterslaves and lenmaster is None:
|
||||
break
|
||||
|
||||
def mandatory_warnings(self,
|
||||
config_bag):
|
||||
@ -712,7 +792,6 @@ class Values(object):
|
||||
:returns: generator of mandatory Option's path
|
||||
"""
|
||||
context = self._getcontext()
|
||||
settings = context.cfgimpl_get_settings()
|
||||
# copy
|
||||
od_setting_properties = config_bag.setting_properties - {'mandatory', 'empty'}
|
||||
setting_properties = set(config_bag.setting_properties)
|
||||
@ -720,77 +799,12 @@ class Values(object):
|
||||
config_bag.setting_properties = frozenset(setting_properties)
|
||||
config_bag.force_permissive = True
|
||||
config_bag.display_warnings = False
|
||||
def _mandatory_warnings(description, currpath, config):
|
||||
is_masterslaves = description.impl_is_master_slaves()
|
||||
lenmaster = None
|
||||
optmaster = None
|
||||
pathmaster = None
|
||||
for option in description.impl_getchildren(config_bag, context):
|
||||
sconfig_bag = config_bag.copy('nooption')
|
||||
sconfig_bag.option = option
|
||||
name = option.impl_getname()
|
||||
path = '.'.join(currpath + [name])
|
||||
|
||||
if option.impl_is_optiondescription():
|
||||
sconfig_bag.setting_properties = od_setting_properties
|
||||
try:
|
||||
subconfig = config.getattr(name,
|
||||
None,
|
||||
sconfig_bag)
|
||||
except PropertiesOptionError as err:
|
||||
pass
|
||||
else:
|
||||
for path in _mandatory_warnings(option,
|
||||
currpath + [name],
|
||||
subconfig):
|
||||
yield path
|
||||
elif not option.impl_is_symlinkoption():
|
||||
# don't check symlink
|
||||
self_properties = settings.getproperties(path,
|
||||
None,
|
||||
sconfig_bag)
|
||||
|
||||
sconfig_bag.properties = self_properties
|
||||
if 'mandatory' in self_properties or 'empty' in self_properties:
|
||||
try:
|
||||
if option.impl_is_master_slaves('slave'):
|
||||
if lenmaster is None:
|
||||
# master is a length (so int) if value is already calculated
|
||||
# otherwise get value and calculate length
|
||||
nconfig_bag = config_bag.copy('nooption')
|
||||
nconfig_bag.option = optmaster
|
||||
values = config.getattr(pathmaster,
|
||||
None,
|
||||
nconfig_bag)
|
||||
lenmaster = len(values)
|
||||
#if not lenmaster:
|
||||
# settings.validate_properties(path,
|
||||
# None,
|
||||
# sconfig_bag)
|
||||
#else:
|
||||
for index in range(lenmaster):
|
||||
values = config.getattr(name,
|
||||
index,
|
||||
sconfig_bag)
|
||||
else:
|
||||
value = config.getattr(name,
|
||||
None,
|
||||
sconfig_bag)
|
||||
if is_masterslaves:
|
||||
lenmaster = len(value)
|
||||
pathmaster = name
|
||||
optmaster = option
|
||||
except PropertiesOptionError as err:
|
||||
if err.proptype == ['mandatory']:
|
||||
yield path
|
||||
if is_masterslaves and lenmaster is None:
|
||||
break
|
||||
except ConfigError as err:
|
||||
#assume that uncalculated value is an empty value
|
||||
yield path
|
||||
if is_masterslaves and lenmaster is None:
|
||||
break
|
||||
|
||||
descr = context.cfgimpl_get_description()
|
||||
for path in _mandatory_warnings(descr, [], context):
|
||||
for path in self._mandatory_warnings(context,
|
||||
config_bag,
|
||||
descr,
|
||||
[],
|
||||
context,
|
||||
od_setting_properties):
|
||||
yield path
|
||||
|
Reference in New Issue
Block a user