From 151bc83ba59b21b8b3643ac704a60499d0c8acf6 Mon Sep 17 00:00:00 2001 From: gwen Date: Tue, 26 Feb 2013 14:56:15 +0100 Subject: [PATCH] previous value api --- tiramisu/option.py | 3 +++ tiramisu/value.py | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/tiramisu/option.py b/tiramisu/option.py index 9fc559a..88ce51e 100644 --- a/tiramisu/option.py +++ b/tiramisu/option.py @@ -225,6 +225,9 @@ class Option(HiddenBaseType, DisabledBaseType): "config *must* be only the **parent** config (not the toplevel config)" return config._cfgimpl_context._cfgimpl_values.getowner(self) + def get_previous_value(self, config): + return config._cfgimpl_context._cfgimpl_values.get_previous_value(self) + def reset(self, config): """resets the default value and owner """ diff --git a/tiramisu/value.py b/tiramisu/value.py index 237dd7c..d62d558 100644 --- a/tiramisu/value.py +++ b/tiramisu/value.py @@ -76,6 +76,13 @@ class Values(object): else: self.previous_values[opt] = old_value + def get_previous_value(self, opt): + if opt in self.previous_values: + prec_value = self.previous_values[opt] + else: + prec_value = None + return prec_value + def _is_empty(self, opt, value=None): "convenience method to know if an option is empty" if value is not None: