requires could be apply to a slave and properties could be different

This commit is contained in:
2015-11-29 23:03:08 +01:00
parent c2a6772ec2
commit a521a6d322
20 changed files with 403 additions and 241 deletions

View File

@ -19,9 +19,9 @@ from time import time
from copy import copy
from logging import getLogger
import weakref
from tiramisu.error import (RequirementError, PropertiesOptionError,
ConstError, ConfigError)
from tiramisu.i18n import _
from .error import (RequirementError, PropertiesOptionError,
ConstError, ConfigError)
from .i18n import _
"Default encoding for display a Config if raise UnicodeEncodeError"
@ -367,7 +367,7 @@ class Settings(object):
def _getproperties(self, opt=None, path=None,
setting_properties=undefined, read_write=True,
apply_requires=True):
apply_requires=True, index=None):
"""
"""
if opt is None:
@ -384,17 +384,17 @@ class Settings(object):
ntime = int(time())
else:
ntime = None
if 'cache' in setting_properties and self._p_.hascache(path):
is_cached, props = self._p_.getcache(path, ntime)
if 'cache' in setting_properties and self._p_.hascache(path, index):
is_cached, props = self._p_.getcache(path, ntime, index)
if not is_cached:
props = self._p_.getproperties(path, opt.impl_getproperties())
if apply_requires:
props = copy(props)
props |= self.apply_requires(opt, path, setting_properties)
props |= self.apply_requires(opt, path, setting_properties, index)
if 'cache' in setting_properties:
if 'expire' in setting_properties:
ntime = ntime + expires_time
self._p_.setcache(path, props, ntime)
self._p_.setcache(path, props, ntime, index)
if read_write:
props = copy(props)
return props
@ -458,7 +458,8 @@ class Settings(object):
properties = copy(self_properties)
else:
properties = self._getproperties(opt_or_descr, path,
setting_properties=setting_properties)
setting_properties=setting_properties,
index=index)
# remove opt permissive
# permissive affect option's permission with or without permissive
# global property
@ -571,7 +572,7 @@ class Settings(object):
else:
self._p_.reset_all_cache()
def apply_requires(self, opt, path, setting_properties):
def apply_requires(self, opt, path, setting_properties, index):
"""carries out the jit (just in time) requirements between options
a requirement is a tuple of this form that comes from the option's
@ -633,7 +634,8 @@ class Settings(object):
"'{1}'").format(path, reqpath))
try:
value = context.getattr(reqpath, force_permissive=True,
_setting_properties=setting_properties)
_setting_properties=setting_properties,
index=index)
except PropertiesOptionError as err:
if not transitive:
continue