Compare commits
No commits in common. "dda10f76f826764ababbe200b52ec3096fa513f1" and "43d3046e4c3a183aa43296747b96091dcf62c02d" have entirely different histories.
dda10f76f8
...
43d3046e4c
6 changed files with 11 additions and 43 deletions
|
|
@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
|
|||
|
||||
[project]
|
||||
name = "tiramisu"
|
||||
version = "5.2.0a17"
|
||||
version = "5.2.0a16"
|
||||
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
||||
readme = "README.md"
|
||||
description = "an options controller tool"
|
||||
|
|
|
|||
|
|
@ -87,14 +87,11 @@ def test_none():
|
|||
conf2 = meta.config('conf2')
|
||||
assert meta.option('od1.i3').value.get() is conf1.option('od1.i3').value.get() is conf2.option('od1.i3').value.get() is None
|
||||
assert meta.option('od1.i3').owner.get() is conf1.option('od1.i3').owner.get() is conf2.option('od1.i3').owner.get() is owners.default
|
||||
assert meta.option('od1.i3').owner.isdefault() and conf1.option('od1.i3').owner.isdefault()
|
||||
#
|
||||
#assert meta.option('od1.i3').value.set(3) == []
|
||||
meta.option('od1.i3').value.set(3)
|
||||
assert meta.option('od1.i3').value.get() == conf1.option('od1.i3').value.get() == conf2.option('od1.i3').value.get() == 3
|
||||
assert meta.option('od1.i3').owner.get() is conf1.option('od1.i3').owner.get() is conf2.option('od1.i3').owner.get() is owners.meta1
|
||||
assert not meta.option('od1.i3').owner.isdefault()
|
||||
assert conf1.option('od1.i3').owner.isdefault()
|
||||
#
|
||||
conf1.option('od1.i3').value.set(2)
|
||||
assert meta.option('od1.i3').value.get() == conf2.option('od1.i3').value.get() == 3
|
||||
|
|
@ -113,8 +110,6 @@ def test_none():
|
|||
assert conf1.option('od1.i3').value.get() == 2
|
||||
assert meta.option('od1.i3').owner.get() is conf2.option('od1.i3').owner.get() is owners.default
|
||||
assert conf1.option('od1.i3').owner.get() is owners.user
|
||||
assert meta.option("od1.i3").owner.default() is owners.default
|
||||
assert conf1.option("od1.i3").owner.default() is owners.default
|
||||
#
|
||||
conf1.option('od1.i3').value.reset()
|
||||
assert meta.option('od1.i3').value.get() is conf1.option('od1.i3').value.get() is conf2.option('od1.i3').value.get() is None
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
__version__ = "5.2.0a17"
|
||||
__version__ = "5.2.0a16"
|
||||
|
|
|
|||
|
|
@ -717,27 +717,10 @@ class TiramisuOptionOwner(CommonTiramisuOption):
|
|||
self._subconfig, validate_meta=not only_self
|
||||
)
|
||||
|
||||
@option_type(["symlink", "option", "with_index"])
|
||||
def default(self):
|
||||
values = self._config_bag.context.get_values()
|
||||
return values.get_default_owner(self._subconfig)
|
||||
|
||||
@option_type(["symlink", "option", "with_index"])
|
||||
def isdefault(self):
|
||||
"""Is option has defaut value"""
|
||||
subconfig = self._subconfig
|
||||
s_properties = subconfig.properties
|
||||
if (
|
||||
"frozen" in s_properties
|
||||
and "force_default_on_freeze" in s_properties
|
||||
):
|
||||
return True
|
||||
context = self._config_bag.context
|
||||
subconfig = context._get(
|
||||
subconfig,
|
||||
True,
|
||||
)
|
||||
return not context.get_values().hasvalue(subconfig.path, index=subconfig.index)
|
||||
return self._config_bag.context.get_owner(self._subconfig) == owners.default
|
||||
|
||||
@option_type(["option", "with_index"])
|
||||
def set(
|
||||
|
|
@ -1792,7 +1775,7 @@ class TiramisuContextOption(TiramisuConfig, _TiramisuOptionWalk):
|
|||
self,
|
||||
):
|
||||
"""Get option path"""
|
||||
return self._config_bag.context.get_config_path()
|
||||
return None
|
||||
|
||||
def has_dependency(
|
||||
self,
|
||||
|
|
@ -1857,9 +1840,6 @@ class TiramisuContextOption(TiramisuConfig, _TiramisuOptionWalk):
|
|||
self._load_dict()
|
||||
return self._tiramisu_dict.set_updates(body)
|
||||
|
||||
def __repr__(self):
|
||||
return f'<{self.__class__.__name__} path="{self.path()}">'
|
||||
|
||||
|
||||
class _TiramisuContextConfigReset:
|
||||
def reset(self):
|
||||
|
|
@ -2095,7 +2075,9 @@ class TiramisuAPI(TiramisuHelp):
|
|||
|
||||
|
||||
class ConfigProp(TiramisuAPI, TiramisuContextOption):
|
||||
pass
|
||||
def __repr__(self):
|
||||
return f"<Config path=None>"
|
||||
|
||||
|
||||
class Config(TiramisuAPI, TiramisuContextOption):
|
||||
"""Root config object that enables us to handle the configuration options"""
|
||||
|
|
@ -2132,6 +2114,9 @@ class Config(TiramisuAPI, TiramisuContextOption):
|
|||
except ConfigError:
|
||||
pass
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Config path=None>"
|
||||
|
||||
|
||||
class MetaConfig(TiramisuAPI, TiramisuContextOption):
|
||||
"""MetaConfig object that enables us to handle the sub configuration's options
|
||||
|
|
|
|||
|
|
@ -1881,5 +1881,5 @@ class KernelMetaConfig(KernelMixConfig):
|
|||
config,
|
||||
):
|
||||
if self._impl_descr is not config.get_description():
|
||||
raise ValueError(_("metaconfig must have the same optiondescription"))
|
||||
raise ValueError(_("metaconfig must " "have the same optiondescription"))
|
||||
super().add_config(config)
|
||||
|
|
|
|||
|
|
@ -126,18 +126,6 @@ class Values:
|
|||
)
|
||||
return value, has_calculation
|
||||
|
||||
def get_default_owner(
|
||||
self,
|
||||
subconfig: "SubConfig",
|
||||
) -> Any:
|
||||
msubconfig = self._get_modified_parent(subconfig)
|
||||
if msubconfig is not None:
|
||||
# retrieved value from parent config
|
||||
return msubconfig.config_bag.context.get_values().getowner(
|
||||
msubconfig
|
||||
)
|
||||
return owners.default
|
||||
|
||||
def get_default_value(
|
||||
self,
|
||||
subconfig: "SubConfig",
|
||||
|
|
|
|||
Loading…
Reference in a new issue