suppression of the notion of normal and expert mode

This commit is contained in:
gwen 2012-08-13 09:32:33 +02:00
parent a88d203790
commit d05feb78f9
6 changed files with 16 additions and 52 deletions

View File

@ -92,7 +92,8 @@ corresponding convenience API provided:
`enable()`:
set the `disabled` attribute to `False`
mode
..
mode
a mode is `normal` or `expert`, just a category of `Option()` or
group wich determines if an option is easy to choose or not,

View File

@ -250,16 +250,6 @@ def test_setoption_from_option():
cfg = Config(descr)
booloption.setoption(cfg, False, 'owner')
assert cfg.bool == False
# ____________________________________________________________
def test_set_mode_in_config():
booloption = BoolOption('bool', 'Test boolean option', default=True,
mode='expert')
descr = OptionDescription('descr', '', [booloption])
cfg = Config(descr)
cfg.cfgimpl_set_mode('expert')
raises(ModeOptionError, "cfg.bool")
cfg.cfgimpl_set_mode('normal')
assert cfg.bool == True
#____________________________________________________________
def test_dwim_set():
descr = OptionDescription("opt", "", [

View File

@ -20,8 +20,6 @@
# the rough gus of pypy: pypy: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence
# ____________________________________________________________
# Option and OptionDescription modes
modes = ['normal', 'expert']
class HiddenBaseType(object):
hidden = False
@ -42,12 +40,3 @@ class DisabledBaseType(object):
def _is_disabled(self):
return self.disabled
class ModeBaseType(object):
mode = 'normal'
def get_mode(self):
return self.mode
def set_mode(self, mode):
if mode not in modes:
raise TypeError("Unknown mode: {0}".format(mode))
self.mode = mode

View File

@ -24,9 +24,9 @@ from copy import copy
from tiramisu.error import (HiddenOptionError, ConfigError, NotFoundError,
AmbigousOptionError, ConflictConfigError, NoMatchingOptionFound,
SpecialOwnersError, MandatoryError, MethodCallError,
DisabledOptionError, ModeOptionError)
DisabledOptionError)
from tiramisu.option import (OptionDescription, Option, SymLinkOption, group_types,
Multi, apply_requires, modes)
Multi, apply_requires)
from tiramisu.autolib import special_owners, special_owner_factory
# ______________________________________________________________________
# generic owner. 'default' is the general config owner after init time
@ -39,7 +39,6 @@ class Config(object):
_cfgimpl_frozen = False
_cfgimpl_owner = default_owner
_cfgimpl_toplevel = None
_cfgimpl_mode = 'normal'
def __init__(self, descr, parent=None, **overrides):
self._cfgimpl_descr = descr
@ -184,12 +183,6 @@ class Config(object):
(opt_or_descr._is_disabled() or self._cfgimpl_descr._is_disabled()):
raise DisabledOptionError("this option is disabled:"
" {0}".format(name))
# expert options
# XXX currently doesn't look at the group, is it really necessary ?
if self._cfgimpl_toplevel._cfgimpl_mode != 'normal':
if opt_or_descr.get_mode() != 'normal':
raise ModeOptionError("this option's mode is not normal:"
" {0}".format(name))
def __getattr__(self, name):
# attribute access by passing a path,
@ -441,13 +434,6 @@ class Config(object):
rootconfig._cfgimpl_disabled = True
rootconfig._cfgimpl_mandatory = True
def cfgimpl_set_mode(self, mode):
# normal or expert mode
rootconfig = self._cfgimpl_get_toplevel()
if mode not in modes:
raise ConfigError("mode {0} not available".format(mode))
rootconfig._cfgimpl_mode = mode
def cfgimpl_read_write(self):
# hung up on freeze, hidden and disabled concepts
self.cfgimpl_unfreeze()

View File

@ -22,6 +22,4 @@ class MandatoryError(Exception):
pass
class SpecialOwnersError(Exception):
pass
class ModeOptionError(Exception):
pass

View File

@ -21,7 +21,7 @@
# the whole pypy projet is under MIT licence
# ____________________________________________________________
from tiramisu.autolib import special_owners
from tiramisu.basetype import HiddenBaseType, DisabledBaseType, ModeBaseType, modes
from tiramisu.basetype import HiddenBaseType, DisabledBaseType
from tiramisu.error import (ConfigError, ConflictConfigError, NotFoundError,
SpecialOwnersError, RequiresError, RequirementRecursionError)
available_actions = ['hide', 'show', 'enable', 'disable']
@ -80,7 +80,7 @@ class Multi(list):
super(Multi, self).pop(key)
# ____________________________________________________________
#
class Option(HiddenBaseType, DisabledBaseType, ModeBaseType):
class Option(HiddenBaseType, DisabledBaseType):
#reminder: an Option object is **not** a container for the value
_frozen = False
def __init__(self, name, doc, default=None, default_multi=None,
@ -379,7 +379,7 @@ class ArbitraryOption(Option):
return self.defaultfactory()
return self.default
class OptionDescription(HiddenBaseType, DisabledBaseType, ModeBaseType):
class OptionDescription(HiddenBaseType, DisabledBaseType):
group_type = 'default'
def __init__(self, name, doc, children, requires=None):