Commit 01d2e287 authored by Wout De Nolf's avatar Wout De Nolf
Browse files

UnknownVariableError

parent 2687ee4f
......@@ -326,6 +326,10 @@ class MutableVariableContainer(VariableContainer, MutableMapping):
del self.value[name]
class UnknownVariableError(AttributeError):
pass
class VariableContainerNamespace:
"""Expose getting/setting variable values through attributes"""
......@@ -344,7 +348,13 @@ class VariableContainerNamespace:
if name in self._reserved_variable_names():
super().__setattr__(name, value)
else:
self._container[name].value = value
self._get_variable(name).value = value
def __getattr__(self, name):
return self._container[name].value
return self._get_variable(name).value
def _get_variable(self, name):
try:
return self._container[name]
except (KeyError, TypeError):
raise UnknownVariableError(name)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment