symlink has an option's API

This commit is contained in:
gwen 2012-11-30 16:23:40 +01:00
parent 43af9cf7f7
commit 2dfc906966

View File

@ -373,20 +373,19 @@ class StrOption(Option):
class SymLinkOption(object):
opt_type = 'symlink'
def __init__(self, name, path):
def __init__(self, name, path, opt):
self._name = name
self.path = path
self.opt = opt
def setoption(self, config, value, who):
setattr(config, self.path, value) # .setoption(self.path, value, who)
setattr(config, self.path, value)
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
if name in ('_name', 'path', 'opt', 'setoption'):
return self.__dict__[name]
else:
return getattr(self.opt, name)
class IPOption(Option):
opt_type = 'ip'