getkey() and __eq__ for a SymLink

This commit is contained in:
gwen 2012-11-30 15:08:34 +01:00
parent e0490c2bed
commit 43af9cf7f7
2 changed files with 10 additions and 0 deletions

View file

@ -375,6 +375,8 @@ class Config(object):
def __eq__(self, other): def __eq__(self, other):
"Config comparison" "Config comparison"
if not isinstance(other, OptionDescription):
return False
return self.getkey() == other.getkey() return self.getkey() == other.getkey()
def __ne__(self, other): def __ne__(self, other):

View file

@ -380,6 +380,14 @@ class SymLinkOption(object):
def setoption(self, config, value, who): def setoption(self, config, value, who):
setattr(config, self.path, value) # .setoption(self.path, 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): class IPOption(Option):
opt_type = 'ip' opt_type = 'ip'