doc + description + can updates with dict
This commit is contained in:
parent
613ae47573
commit
c5ce9be699
|
@ -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
|
||||
# -*- 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)",
|
||||
|
|
|
@ -45,4 +45,4 @@ allfuncs.extend(all_options)
|
|||
del(all_options)
|
||||
__all__ = tuple(allfuncs)
|
||||
del(allfuncs)
|
||||
__version__ = "3.0rc9"
|
||||
__version__ = "3.0rc10"
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue