reorganise symlinkoption

This commit is contained in:
2017-12-04 20:05:36 +01:00
parent e40a1e78a2
commit 924ac4e597
9 changed files with 636 additions and 506 deletions

View File

@ -291,6 +291,9 @@ class Settings(object):
apply_requires=True):
"""
"""
if opt.impl_is_symlinkoption():
opt = opt.impl_getopt()
path = opt.impl_getpath(self._getcontext())
is_cached = False
if apply_requires:
@ -325,7 +328,8 @@ class Settings(object):
props = copy(props)
props |= requires
props -= self.getpermissive(path)
props -= self.getpermissive(opt,
path)
if apply_requires and 'cache' in setting_properties:
if 'expire' in setting_properties:
ntime = ntime + expires_time
@ -336,14 +340,19 @@ class Settings(object):
return props
def get_context_permissive(self):
return self.getpermissive(None)
return self.getpermissive(None, None)
def getpermissive(self,
opt,
path):
if opt and opt.impl_is_symlinkoption():
opt = opt.impl_getopt()
path = opt.impl_getpath(self._getcontext())
meta = self._getcontext().cfgimpl_get_meta()
if meta is None:
return self._pp_.getpermissive(path)
return meta.cfgimpl_get_settings().getpermissive(path)
return meta.cfgimpl_get_settings().getpermissive(opt,
path)
def apply_requires(self,
opt,
@ -503,6 +512,9 @@ class Settings(object):
"""
if self._getcontext().cfgimpl_get_meta() is not None:
raise ConfigError(_('cannot change property with metaconfig'))
if opt and opt.impl_is_symlinkoption():
raise TypeError(_("can't assign properties to the SymLinkOption \"{}\""
"").format(opt.impl_get_display_name()))
forbidden_properties = forbidden_set_properties & properties
if forbidden_properties:
raise ConfigError(_('cannot add those properties: {0}').format(
@ -535,6 +547,9 @@ class Settings(object):
raise ConfigError(_('cannot change permissive with metaconfig'))
if not isinstance(permissives, frozenset):
raise TypeError(_('permissive must be a frozenset'))
if opt and opt.impl_is_symlinkoption():
raise TypeError(_("can't assign permissive to the SymLinkOption \"{}\""
"").format(opt.impl_get_display_name()))
forbidden_permissives = forbidden_set_permissives & permissives
if forbidden_permissives:
raise ConfigError(_('cannot add those permissives: {0}').format(
@ -548,21 +563,24 @@ class Settings(object):
def reset(self,
opt=None,
_path=None,
path=None,
all_properties=False):
if self._getcontext().cfgimpl_get_meta() is not None:
raise ConfigError(_('cannot change property with metaconfig'))
if all_properties and (_path or opt): # pragma: optional cover
if opt and opt.impl_is_symlinkoption():
raise TypeError(_("can't reset properties to the SymLinkOption \"{}\""
"").format(opt.impl_get_display_name()))
if all_properties and (path or opt): # pragma: optional cover
raise ValueError(_('opt and all_properties must not be set '
'together in reset'))
if all_properties:
self._p_.reset_all_properties()
else:
if opt is not None and _path is None:
_path = opt.impl_getpath(self._getcontext())
self._p_.delproperties(_path)
if opt is not None and path is None:
path = opt.impl_getpath(self._getcontext())
self._p_.delproperties(path)
self._getcontext().cfgimpl_reset_cache(opt=opt,
path=_path)
path=path)
#____________________________________________________________
# validate properties