From 43af9cf7f7c4a9b4e837a3d1bb307d90ace8b5c9 Mon Sep 17 00:00:00 2001 From: gwen Date: Fri, 30 Nov 2012 15:08:34 +0100 Subject: [PATCH] getkey() and __eq__ for a SymLink --- tiramisu/config.py | 2 ++ tiramisu/option.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/tiramisu/config.py b/tiramisu/config.py index 89df89f..eb60364 100644 --- a/tiramisu/config.py +++ b/tiramisu/config.py @@ -375,6 +375,8 @@ class Config(object): def __eq__(self, other): "Config comparison" + if not isinstance(other, OptionDescription): + return False return self.getkey() == other.getkey() def __ne__(self, other): diff --git a/tiramisu/option.py b/tiramisu/option.py index 08b6c11..59b0bdb 100644 --- a/tiramisu/option.py +++ b/tiramisu/option.py @@ -380,6 +380,14 @@ class SymLinkOption(object): def setoption(self, config, value, who): setattr(config, self.path, value) # .setoption(self.path, value, who) + def __getattr__(self, name): + if name not in ('setoption', 'getkey'): + raise TypeError("shall not call {0} method/attribute on " + "SymLinkOption {1}".format(name, self._name)) + + def getkey(self, value): + return value + class IPOption(Option): opt_type = 'ip'