better hidden/display support
This commit is contained in:
@ -183,6 +183,7 @@ class ConfigBag:
|
||||
__slots__ = ('context', # link to the current context
|
||||
'properties', # properties for current context
|
||||
'true_properties', # properties for current context
|
||||
'is_unrestraint',
|
||||
'permissives', # permissives for current context
|
||||
'expiration_time' # EXPIRATION_TIME
|
||||
)
|
||||
@ -206,6 +207,8 @@ class ConfigBag:
|
||||
if key == 'expiration_time':
|
||||
self.expiration_time = EXPIRATION_TIME
|
||||
return self.expiration_time
|
||||
if key == 'is_unrestraint':
|
||||
return False
|
||||
raise KeyError('unknown key {} for ConfigBag'.format(key)) # pragma: no cover
|
||||
|
||||
def remove_warnings(self):
|
||||
@ -215,6 +218,7 @@ class ConfigBag:
|
||||
self.properties = frozenset(self.properties - {'validator'})
|
||||
|
||||
def unrestraint(self):
|
||||
self.is_unrestraint = True
|
||||
self.true_properties = self.properties
|
||||
self.properties = frozenset(['cache'])
|
||||
|
||||
@ -437,7 +441,8 @@ class Settings(object):
|
||||
search_properties=search_properties)
|
||||
props -= self.getpermissives(opt,
|
||||
path)
|
||||
if apply_requires:
|
||||
#if apply_requires and config_bag.properties == config_bag.true_properties:
|
||||
if apply_requires and not config_bag.is_unrestraint:
|
||||
self._p_.setcache(path,
|
||||
index,
|
||||
props,
|
||||
@ -761,15 +766,23 @@ class Settings(object):
|
||||
def calc_raises_properties(self,
|
||||
option_bag,
|
||||
apply_requires=True):
|
||||
raises_properties = option_bag.config_bag.properties - SPECIAL_PROPERTIES
|
||||
# remove global permissive properties
|
||||
if raises_properties and ('permissive' in raises_properties):
|
||||
raises_properties -= option_bag.config_bag.permissives
|
||||
if apply_requires and option_bag.properties_setted:
|
||||
option_properties = option_bag.properties
|
||||
else:
|
||||
option_properties = self.getproperties(option_bag,
|
||||
apply_requires=apply_requires)
|
||||
return self._calc_raises_properties(option_bag.config_bag.properties,
|
||||
option_bag.config_bag.permissives,
|
||||
option_properties)
|
||||
|
||||
def _calc_raises_properties(self,
|
||||
context_properties,
|
||||
context_permissives,
|
||||
option_properties):
|
||||
raises_properties = context_properties - SPECIAL_PROPERTIES
|
||||
# remove global permissive properties
|
||||
if raises_properties and ('permissive' in raises_properties):
|
||||
raises_properties -= context_permissives
|
||||
properties = option_properties & raises_properties
|
||||
# at this point an option should not remain in properties
|
||||
return properties
|
||||
|
Reference in New Issue
Block a user