opt.hidden and opt.disabled is replaced by opt.properties
This commit is contained in:
parent
f48c4c229b
commit
1d5330f15e
3 changed files with 20 additions and 17 deletions
|
@ -22,21 +22,23 @@
|
||||||
# ____________________________________________________________
|
# ____________________________________________________________
|
||||||
|
|
||||||
class HiddenBaseType(object):
|
class HiddenBaseType(object):
|
||||||
hidden = False
|
|
||||||
def hide(self):
|
def hide(self):
|
||||||
self.hidden = True
|
if not 'hidden' in self.properties:
|
||||||
|
self.properties.append('hidden')
|
||||||
def show(self):
|
def show(self):
|
||||||
self.hidden = False
|
if 'hidden' in self.properties:
|
||||||
|
self.properties.remove('hidden')
|
||||||
def _is_hidden(self):
|
def _is_hidden(self):
|
||||||
# dangerous method: how an Option can determine its status by itself ?
|
# dangerous method: how an Option() can determine its status by itself ?
|
||||||
return self.hidden
|
return 'hidden' in self.properties
|
||||||
|
|
||||||
class DisabledBaseType(object):
|
class DisabledBaseType(object):
|
||||||
disabled = False
|
|
||||||
def disable(self):
|
def disable(self):
|
||||||
self.disabled = True
|
if not 'disabled' in self.properties:
|
||||||
|
self.properties.append('disabled')
|
||||||
def enable(self):
|
def enable(self):
|
||||||
self.disabled = False
|
if 'disabled' in self.properties:
|
||||||
|
self.properties.remove('disabled')
|
||||||
def _is_disabled(self):
|
def _is_disabled(self):
|
||||||
return self.disabled
|
return 'disabled' in self.properties
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,9 @@
|
||||||
from copy import copy
|
from copy import copy
|
||||||
from tiramisu.error import (HiddenOptionError, ConfigError, NotFoundError,
|
from tiramisu.error import (HiddenOptionError, ConfigError, NotFoundError,
|
||||||
AmbigousOptionError, ConflictConfigError, NoMatchingOptionFound,
|
AmbigousOptionError, ConflictConfigError, NoMatchingOptionFound,
|
||||||
SpecialOwnersError, MandatoryError, MethodCallError,
|
SpecialOwnersError, MandatoryError, MethodCallError, DisabledOptionError)
|
||||||
DisabledOptionError)
|
from tiramisu.option import (OptionDescription, Option, SymLinkOption,
|
||||||
from tiramisu.option import (OptionDescription, Option, SymLinkOption, group_types,
|
group_types, Multi, apply_requires)
|
||||||
Multi, apply_requires)
|
|
||||||
from tiramisu.autolib import special_owners, special_owner_factory
|
from tiramisu.autolib import special_owners, special_owner_factory
|
||||||
# ______________________________________________________________________
|
# ______________________________________________________________________
|
||||||
# generic owner. 'default' is the general config owner after init time
|
# generic owner. 'default' is the general config owner after init time
|
||||||
|
|
|
@ -119,6 +119,7 @@ class Option(HiddenBaseType, DisabledBaseType):
|
||||||
raise ConfigError("invalid default value {0} "
|
raise ConfigError("invalid default value {0} "
|
||||||
"for option {1}".format(str(default), name))
|
"for option {1}".format(str(default), name))
|
||||||
self.default = default
|
self.default = default
|
||||||
|
self.properties = [] # 'hidden', 'disabled'...
|
||||||
|
|
||||||
def validate(self, value):
|
def validate(self, value):
|
||||||
if self.multi == False:
|
if self.multi == False:
|
||||||
|
@ -371,7 +372,6 @@ class ArbitraryOption(Option):
|
||||||
return self.default
|
return self.default
|
||||||
|
|
||||||
class OptionDescription(HiddenBaseType, DisabledBaseType):
|
class OptionDescription(HiddenBaseType, DisabledBaseType):
|
||||||
group_type = 'default'
|
|
||||||
|
|
||||||
def __init__(self, name, doc, children, requires=None):
|
def __init__(self, name, doc, children, requires=None):
|
||||||
self._name = name
|
self._name = name
|
||||||
|
@ -379,6 +379,8 @@ class OptionDescription(HiddenBaseType, DisabledBaseType):
|
||||||
self._children = children
|
self._children = children
|
||||||
self._requires = requires
|
self._requires = requires
|
||||||
self._build()
|
self._build()
|
||||||
|
self.properties = [] # 'hidden', 'disabled'...
|
||||||
|
self.group_type = 'default'
|
||||||
|
|
||||||
def getdoc(self):
|
def getdoc(self):
|
||||||
return self.doc
|
return self.doc
|
||||||
|
|
Loading…
Reference in a new issue