Compare commits
2 commits
c8b7d09b41
...
f68d56017c
| Author | SHA1 | Date | |
|---|---|---|---|
| f68d56017c | |||
| 61f90cb530 |
4 changed files with 13 additions and 14 deletions
|
|
@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "tiramisu"
|
name = "tiramisu"
|
||||||
version = "5.2.0a25"
|
version = "5.2.0a26"
|
||||||
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
description = "an options controller tool"
|
description = "an options controller tool"
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
__version__ = "5.2.0a25"
|
__version__ = "5.2.0a26"
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,9 @@ TiramisuErrorCode = Literal[
|
||||||
def display_list(
|
def display_list(
|
||||||
lst,
|
lst,
|
||||||
*,
|
*,
|
||||||
separator="and",
|
separator: str="and",
|
||||||
add_quote=False,
|
add_quote: bool=False,
|
||||||
|
sort: bool=True,
|
||||||
) -> str():
|
) -> str():
|
||||||
if not lst:
|
if not lst:
|
||||||
return '""'
|
return '""'
|
||||||
|
|
@ -61,15 +62,13 @@ def display_list(
|
||||||
for l in lst:
|
for l in lst:
|
||||||
if not isinstance(l, str):
|
if not isinstance(l, str):
|
||||||
l = str(l)
|
l = str(l)
|
||||||
lst_.append(_(l))
|
|
||||||
lst__ = []
|
|
||||||
for l in lst_:
|
|
||||||
if add_quote and not l.startswith('"'):
|
if add_quote and not l.startswith('"'):
|
||||||
l = '"{}"'.format(l)
|
l = '"{}"'.format(l)
|
||||||
lst__.append(l)
|
lst_.append(_(l))
|
||||||
lst__.sort()
|
if sort:
|
||||||
last = lst__[-1]
|
lst_.sort()
|
||||||
return ", ".join(lst__[:-1]) + _(" {} ").format(separator) + "{}".format(last)
|
last = lst_[-1]
|
||||||
|
return ", ".join(lst_[:-1]) + _(" {} ").format(separator) + "{}".format(last)
|
||||||
|
|
||||||
|
|
||||||
# Exceptions for an Option
|
# Exceptions for an Option
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ FUNCTION_WAITING_FOR_ERROR = []
|
||||||
|
|
||||||
def function_waiting_for_dict(function):
|
def function_waiting_for_dict(function):
|
||||||
"""functions (calculation or validation) receive by default only the value of other options
|
"""functions (calculation or validation) receive by default only the value of other options
|
||||||
all functions declared with this function recieve a dict with option informations
|
if you use this decoractor, it will recieve a dict with option informations
|
||||||
(value, name, ...)
|
(value, name, ...)
|
||||||
"""
|
"""
|
||||||
name = function.__name__
|
name = function.__name__
|
||||||
|
|
@ -38,8 +38,8 @@ def function_waiting_for_dict(function):
|
||||||
|
|
||||||
|
|
||||||
def function_waiting_for_error(function):
|
def function_waiting_for_error(function):
|
||||||
"""functions (calculation or validation) receive by default only the value of other options
|
"""functions (calculation or validation) receiven by default, only the value of other options
|
||||||
set PropertyError too
|
if you use this decoractor, it will pass PropertyError too
|
||||||
"""
|
"""
|
||||||
name = function.__name__
|
name = function.__name__
|
||||||
if name not in FUNCTION_WAITING_FOR_ERROR:
|
if name not in FUNCTION_WAITING_FOR_ERROR:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue