doc + description + can updates with dict
This commit is contained in:
parent
613ae47573
commit
c5ce9be699
7 changed files with 31 additions and 37 deletions
|
@ -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"
|
|
3
setup.py
3
setup.py
|
@ -1,8 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
from os.path import dirname, abspath, join, normpath, isdir
|
|
||||||
from os import listdir
|
|
||||||
import os
|
import os
|
||||||
from tiramisu import __version__
|
from tiramisu import __version__
|
||||||
|
|
||||||
|
@ -17,6 +15,7 @@ setup(
|
||||||
description='an options controller tool',
|
description='an options controller tool',
|
||||||
url='https://framagit.org/tiramisu/tiramisu',
|
url='https://framagit.org/tiramisu/tiramisu',
|
||||||
license='GNU Library or Lesser General Public License (LGPL)',
|
license='GNU Library or Lesser General Public License (LGPL)',
|
||||||
|
provides=['tiramisu_api'],
|
||||||
classifiers=[
|
classifiers=[
|
||||||
"Programming Language :: Python :: 3",
|
"Programming Language :: Python :: 3",
|
||||||
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
|
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
|
||||||
|
|
|
@ -45,4 +45,4 @@ allfuncs.extend(all_options)
|
||||||
del(all_options)
|
del(all_options)
|
||||||
__all__ = tuple(allfuncs)
|
__all__ = tuple(allfuncs)
|
||||||
del(allfuncs)
|
del(allfuncs)
|
||||||
__version__ = "3.0rc9"
|
__version__ = "3.0rc10"
|
||||||
|
|
|
@ -171,6 +171,11 @@ class _TiramisuOptionOptionDescription(CommonTiramisuOption):
|
||||||
option = self._option_bag.option
|
option = self._option_bag.option
|
||||||
return option.impl_get_display_name()
|
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,
|
def name(self,
|
||||||
follow_symlink: bool=False) -> str:
|
follow_symlink: bool=False) -> str:
|
||||||
"""Get option name"""
|
"""Get option name"""
|
||||||
|
@ -802,6 +807,15 @@ class _TiramisuOptionDescription(_TiramisuOption):
|
||||||
subconfig,
|
subconfig,
|
||||||
self._config_bag)
|
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,
|
def dict(self,
|
||||||
clearable: str="all",
|
clearable: str="all",
|
||||||
remotable: str="minimum",
|
remotable: str="minimum",
|
||||||
|
@ -809,21 +823,14 @@ class _TiramisuOptionDescription(_TiramisuOption):
|
||||||
force: bool=False) -> Dict:
|
force: bool=False) -> Dict:
|
||||||
"""convert config and option to tiramisu format"""
|
"""convert config and option to tiramisu format"""
|
||||||
if force or self._tiramisu_dict is None:
|
if force or self._tiramisu_dict is None:
|
||||||
option = self._get_option()
|
self._load_dict(clearable, remotable)
|
||||||
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)
|
|
||||||
return self._tiramisu_dict.todict(form)
|
return self._tiramisu_dict.todict(form)
|
||||||
|
|
||||||
def updates(self,
|
def updates(self,
|
||||||
body: List) -> Dict:
|
body: List) -> Dict:
|
||||||
"""updates value with tiramisu format"""
|
"""updates value with tiramisu format"""
|
||||||
if self._tiramisu_dict is None:
|
if self._tiramisu_dict is None:
|
||||||
raise APIError(_('please use .dict() before .updates()'))
|
self._load_dict()
|
||||||
return self._tiramisu_dict.set_updates(body)
|
return self._tiramisu_dict.set_updates(body)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1276,6 +1283,14 @@ class TiramisuContextOption(TiramisuContext):
|
||||||
config_bag,
|
config_bag,
|
||||||
config_bag.context)
|
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,
|
def dict(self,
|
||||||
clearable="all",
|
clearable="all",
|
||||||
remotable="minimum",
|
remotable="minimum",
|
||||||
|
@ -1283,17 +1298,14 @@ class TiramisuContextOption(TiramisuContext):
|
||||||
force=False):
|
force=False):
|
||||||
"""convert config and option to tiramisu format"""
|
"""convert config and option to tiramisu format"""
|
||||||
if force or self._tiramisu_dict is None:
|
if force or self._tiramisu_dict is None:
|
||||||
self._tiramisu_dict = TiramisuDict(Config(self._config_bag.context),
|
self._load_dict(clearable, remotable)
|
||||||
root=None,
|
|
||||||
clearable=clearable,
|
|
||||||
remotable=remotable)
|
|
||||||
return self._tiramisu_dict.todict(form)
|
return self._tiramisu_dict.todict(form)
|
||||||
|
|
||||||
def updates(self,
|
def updates(self,
|
||||||
body: List) -> Dict:
|
body: List) -> Dict:
|
||||||
"""updates value with tiramisu format"""
|
"""updates value with tiramisu format"""
|
||||||
if self._tiramisu_dict is None:
|
if self._tiramisu_dict is None:
|
||||||
raise APIError(_('please use .dict() before .updates()'))
|
self._load_dict()
|
||||||
return self._tiramisu_dict.set_updates(body)
|
return self._tiramisu_dict.set_updates(body)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -238,7 +238,7 @@ class SubConfig(object):
|
||||||
context = option_bag.config_bag.context
|
context = option_bag.config_bag.context
|
||||||
context.cfgimpl_get_settings().validate_properties(option_bag)
|
context.cfgimpl_get_settings().validate_properties(option_bag)
|
||||||
if option_bag.option.impl_is_leader() and len(value) < self._impl_length:
|
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()))
|
'').format(option_bag.option.impl_get_display_name()))
|
||||||
return context.cfgimpl_get_values().setvalue(value,
|
return context.cfgimpl_get_values().setvalue(value,
|
||||||
option_bag,
|
option_bag,
|
||||||
|
|
|
@ -409,7 +409,7 @@ class BaseOption(Base):
|
||||||
|
|
||||||
def _impl_get_display_name(self,
|
def _impl_get_display_name(self,
|
||||||
dyn_name: Base=None) -> str:
|
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 name is None or name == '':
|
||||||
if dyn_name is not None:
|
if dyn_name is not None:
|
||||||
name = dyn_name
|
name = dyn_name
|
||||||
|
|
|
@ -467,7 +467,7 @@ class TiramisuDict:
|
||||||
childtype)
|
childtype)
|
||||||
if schema is not None:
|
if schema is not None:
|
||||||
if web_type != 'symlink':
|
if web_type != 'symlink':
|
||||||
schema[path]['title'] = childapi_option.doc()
|
schema[path]['title'] = childapi_option.description()
|
||||||
self.add_help(schema[path],
|
self.add_help(schema[path],
|
||||||
childapi)
|
childapi)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
|
Loading…
Reference in a new issue