Skip to content

Commit

Permalink
Merge branch 'CURA-4358_buildplate' into 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
diegopradogesto committed Oct 13, 2017
2 parents fe9a72d + f0e8d26 commit a228929
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
20 changes: 15 additions & 5 deletions UM/Settings/ContainerStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def setDirty(self, dirty: bool) -> None:
# result of evaluating that property with the current stack. If you need the
# actual function, use getRawProperty()
def getProperty(self, key: str, property_name: str, context: Optional[PropertyEvaluationContext] = None):
value = self.getRawProperty(key, property_name)
value = self.getRawProperty(key, property_name, context = context)
if isinstance(value, SettingFunction):
if context is not None:
context.pushContainer(self)
Expand All @@ -222,18 +222,28 @@ def getProperty(self, key: str, property_name: str, context: Optional[PropertyEv
# \return The raw property value of the property, or None if not found. Note that
# the value might be a SettingFunction instance.
#
def getRawProperty(self, key, property_name, *, use_next = True, skip_until_container = None):
for container in self._containers:
def getRawProperty(self, key, property_name, *, context: Optional[PropertyEvaluationContext] = None,
use_next = True, skip_until_container = None):
containers = self._containers
if context is not None:
# if context is provided, check if there is any container that needs to be skipped.
start_index = context.context.get("evaluate_from_container_index", 0)
if start_index >= len(self._containers):
return None
containers = self._containers[start_index:]

for container in containers:
if skip_until_container and container.getId() != skip_until_container:
continue #Skip.
skip_until_container = None #When we find the container, stop skipping.

value = container.getProperty(key, property_name)
value = container.getProperty(key, property_name, context)
if value is not None:
return value

if self._next_stack and use_next:
return self._next_stack.getRawProperty(key, property_name, use_next = use_next, skip_until_container = skip_until_container)
return self._next_stack.getRawProperty(key, property_name, context = context,
use_next = use_next, skip_until_container = skip_until_container)
else:
return None

Expand Down
3 changes: 3 additions & 0 deletions UM/Settings/SettingFunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ def __call__(self, value_provider: ContainerInterface, context: Optional[Propert
g = {} # type: Dict[str, Any]
g.update(globals())
g.update(self.__operators)
# override operators if there is any in the context
if context is not None:
g.update(context.context.get("override_operators", {}))

try:
return eval(self._compiled, g, locals)
Expand Down

0 comments on commit a228929

Please sign in to comment.