# -*- coding: utf-8 -*- # Copyright (C) 2018 Team tiramisu (see AUTHORS for all contributors) # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see . # # The original `Config` design model is unproudly borrowed from # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the whole pypy projet is under MIT licence # ____________________________________________________________ from ..setting import undefined, OptionBag class DynSymLinkOption(object): __slots__ = ('_rootpath', '_opt', '_suffix') def __init__(self, opt, rootpath, suffix): self._opt = opt self._rootpath = rootpath self._suffix = suffix def __getattr__(self, name): return getattr(self._opt, name) def __eq__(self, left): if not isinstance(left, DynSymLinkOption): return False return self._opt == left._opt and \ self._rootpath == left._rootpath and \ self._suffix == left._suffix def impl_getname(self): return self._opt.impl_getname() + self._suffix def impl_get_display_name(self): return self._opt.impl_get_display_name(dyn_name=self.impl_getname()) def impl_getsuffix(self): return self._suffix def impl_getpath(self): return self._rootpath + '.' + self.impl_getname() def impl_validate(self, value, option_bag, check_error=True): context = option_bag.config_bag.context soption_bag = OptionBag() soption_bag.set_option(self._opt, self.impl_getpath(), option_bag.index, option_bag.config_bag) soption_bag.ori_option = option_bag.option soption_bag.fromconsistency = option_bag.fromconsistency.copy() self._opt.impl_validate(value, soption_bag, check_error=check_error) def impl_is_dynsymlinkoption(self): return True