diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index 95fdaf2..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,17 +0,0 @@ -[build-system] -requires = ["flit"] -build-backend = "flit.buildapi" - -[tool.flit.metadata] -module = "tiramisu" -author = "Emmanuel Garette" -author-email = "gnunux@gnunux.info" -home-page = "https://framagit.org/tiramisu/tiramisu" -classifiers = [ - "License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)", - "Programming Language :: Python :: 3", - "Natural Language :: English", - "Natural Language :: French", - "Operating System :: OS Independent", -] -requires-python = ">=3.5" diff --git a/setup.py b/setup.py index 84c557d..a52538c 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- from setuptools import setup, find_packages -from os.path import dirname, abspath, join, normpath, isdir -from os import listdir import os from tiramisu import __version__ @@ -17,6 +15,7 @@ setup( description='an options controller tool', url='https://framagit.org/tiramisu/tiramisu', license='GNU Library or Lesser General Public License (LGPL)', + provides=['tiramisu_api'], classifiers=[ "Programming Language :: Python :: 3", "License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)", diff --git a/tiramisu/__init__.py b/tiramisu/__init__.py index 15c6af8..3e2b21d 100644 --- a/tiramisu/__init__.py +++ b/tiramisu/__init__.py @@ -45,4 +45,4 @@ allfuncs.extend(all_options) del(all_options) __all__ = tuple(allfuncs) del(allfuncs) -__version__ = "3.0rc9" +__version__ = "3.0rc10" diff --git a/tiramisu/api.py b/tiramisu/api.py index e235b41..4591cec 100644 --- a/tiramisu/api.py +++ b/tiramisu/api.py @@ -171,6 +171,11 @@ class _TiramisuOptionOptionDescription(CommonTiramisuOption): option = self._option_bag.option return option.impl_get_display_name() + def description(self): + """Get option description""" + option = self._option_bag.option + return option.impl_get_information('doc', None) + def name(self, follow_symlink: bool=False) -> str: """Get option name""" @@ -802,6 +807,15 @@ class _TiramisuOptionDescription(_TiramisuOption): subconfig, self._config_bag) + def _load_dict(self, + clearable: str="all", + remotable: str="minimum"): + root = self._get_option().impl_getpath() + self._tiramisu_dict = TiramisuDict(Config(self._config_bag.context), + root=root, + clearable=clearable, + remotable=remotable) + def dict(self, clearable: str="all", remotable: str="minimum", @@ -809,21 +823,14 @@ class _TiramisuOptionDescription(_TiramisuOption): force: bool=False) -> Dict: """convert config and option to tiramisu format""" if force or self._tiramisu_dict is None: - option = self._get_option() - name = option.impl_getname() - root = self._subconfig._get_subpath(name) - config = self._config_bag.context - self._tiramisu_dict = TiramisuDict(Config(self._config_bag.context), - root=root, - clearable=clearable, - remotable=remotable) + self._load_dict(clearable, remotable) return self._tiramisu_dict.todict(form) def updates(self, body: List) -> Dict: """updates value with tiramisu format""" if self._tiramisu_dict is None: - raise APIError(_('please use .dict() before .updates()')) + self._load_dict() return self._tiramisu_dict.set_updates(body) @@ -1276,6 +1283,14 @@ class TiramisuContextOption(TiramisuContext): config_bag, config_bag.context) + def _load_dict(self, + clearable="all", + remotable="minimum"): + self._tiramisu_dict = TiramisuDict(Config(self._config_bag.context), + root=None, + clearable=clearable, + remotable=remotable) + def dict(self, clearable="all", remotable="minimum", @@ -1283,17 +1298,14 @@ class TiramisuContextOption(TiramisuContext): force=False): """convert config and option to tiramisu format""" if force or self._tiramisu_dict is None: - self._tiramisu_dict = TiramisuDict(Config(self._config_bag.context), - root=None, - clearable=clearable, - remotable=remotable) + self._load_dict(clearable, remotable) return self._tiramisu_dict.todict(form) def updates(self, body: List) -> Dict: """updates value with tiramisu format""" if self._tiramisu_dict is None: - raise APIError(_('please use .dict() before .updates()')) + self._load_dict() return self._tiramisu_dict.set_updates(body) diff --git a/tiramisu/config.py b/tiramisu/config.py index 626d91b..e773dc6 100644 --- a/tiramisu/config.py +++ b/tiramisu/config.py @@ -238,7 +238,7 @@ class SubConfig(object): context = option_bag.config_bag.context context.cfgimpl_get_settings().validate_properties(option_bag) if option_bag.option.impl_is_leader() and len(value) < self._impl_length: - raise LeadershipError(_('cannot reduce length of a leader "{}"' + raise LeadershipError(_('cannot reduce length of the leader "{}"' '').format(option_bag.option.impl_get_display_name())) return context.cfgimpl_get_values().setvalue(value, option_bag, diff --git a/tiramisu/option/baseoption.py b/tiramisu/option/baseoption.py index ba4b47c..5a25834 100644 --- a/tiramisu/option/baseoption.py +++ b/tiramisu/option/baseoption.py @@ -409,7 +409,7 @@ class BaseOption(Base): def _impl_get_display_name(self, dyn_name: Base=None) -> str: - name = self.impl_get_information('doc') + name = self.impl_get_information('doc', None) if name is None or name == '': if dyn_name is not None: name = dyn_name diff --git a/tiramisu/todict.py b/tiramisu/todict.py index e29cbdf..4b2d7ea 100644 --- a/tiramisu/todict.py +++ b/tiramisu/todict.py @@ -467,7 +467,7 @@ class TiramisuDict: childtype) if schema is not None: if web_type != 'symlink': - schema[path]['title'] = childapi_option.doc() + schema[path]['title'] = childapi_option.description() self.add_help(schema[path], childapi) except Exception as err: