mandatory_warnings is now in values and add force_cache to values
This commit is contained in:
@@ -716,19 +716,5 @@ class MetaConfig(GroupConfig):
|
||||
|
||||
|
||||
def mandatory_warnings(config):
|
||||
"""convenience function to trace Options that are mandatory and
|
||||
where no value has been set
|
||||
|
||||
:returns: generator of mandatory Option's path
|
||||
|
||||
"""
|
||||
#if value in cache, properties are not calculated
|
||||
config.cfgimpl_reset_cache(only=('values',))
|
||||
for path in config.cfgimpl_get_description().impl_getpaths(
|
||||
include_groups=True):
|
||||
try:
|
||||
config._getattr(path, force_properties=frozenset(('mandatory',)))
|
||||
except PropertiesOptionError as err:
|
||||
if err.proptype == ['mandatory']:
|
||||
yield path
|
||||
config.cfgimpl_reset_cache(only=('values',))
|
||||
#only for retro-compatibility
|
||||
config.cfgimpl_get_values().mandatory_warnings()
|
||||
|
@@ -21,7 +21,7 @@ from time import time
|
||||
from copy import copy
|
||||
import sys
|
||||
import weakref
|
||||
from tiramisu.error import ConfigError, SlaveError
|
||||
from tiramisu.error import ConfigError, SlaveError, PropertiesOptionError
|
||||
from tiramisu.setting import owners, multitypes, expires_time, undefined
|
||||
from tiramisu.autolib import carry_out_calculation
|
||||
from tiramisu.i18n import _
|
||||
@@ -395,6 +395,42 @@ class Values(object):
|
||||
raise ValueError(_("information's item"
|
||||
" not found: {0}").format(key))
|
||||
|
||||
def mandatory_warnings(self):
|
||||
"""convenience function to trace Options that are mandatory and
|
||||
where no value has been set
|
||||
|
||||
:returns: generator of mandatory Option's path
|
||||
|
||||
"""
|
||||
#if value in cache, properties are not calculated
|
||||
self.reset_cache(False)
|
||||
context = self.context()
|
||||
for path in context.cfgimpl_get_description().impl_getpaths(
|
||||
include_groups=True):
|
||||
try:
|
||||
context._getattr(path,
|
||||
force_properties=frozenset(('mandatory',)))
|
||||
except PropertiesOptionError as err:
|
||||
if err.proptype == ['mandatory']:
|
||||
yield path
|
||||
self.reset_cache(False)
|
||||
|
||||
def force_cache(self):
|
||||
"""parse all option to force data in cache
|
||||
"""
|
||||
context = self.context()
|
||||
if not 'cache' in context.cfgimpl_get_settings():
|
||||
raise PropertiesOptionError(_('can force cache only if cache '
|
||||
'is actived in config'))
|
||||
#remove all cached properties and value to update "expired" time
|
||||
context.cfgimpl_reset_cache()
|
||||
for path in context.cfgimpl_get_description().impl_getpaths(
|
||||
include_groups=True):
|
||||
try:
|
||||
context._getattr(path)
|
||||
except PropertiesOptionError:
|
||||
pass
|
||||
|
||||
def __getstate__(self):
|
||||
return {'_p_': self._p_}
|
||||
|
||||
|
Reference in New Issue
Block a user