4 Commits

Author SHA1 Message Date
b9e2268f43 is to equal 2020-08-12 08:08:42 +02:00
dc3a3b00c6 new version (0.5) 2020-04-07 17:53:55 +02:00
b75e12c00c add float support 2020-03-20 22:18:49 +01:00
14bd5e8829 schema is not mandatory 2020-03-14 08:43:18 +01:00
2 changed files with 18 additions and 13 deletions

View File

@ -1,5 +1,5 @@
from .api import Config
__version__ = "0.4"
__version__ = "0.5"
__all__ = ('Config',)

View File

@ -26,7 +26,8 @@ TYPE = {'boolean': bool,
'broadcast_address': str,
'port': str,
'domainname': str,
'date': str}
'date': str,
'float': float}
class Option:
@ -225,13 +226,14 @@ class _Value:
withwarning: bool=False,
flatten: bool=False):
ret = {}
self._dict_walk(ret,
self.schema,
self.path,
fullpath,
withwarning,
flatten,
None)
if self.schema:
self._dict_walk(ret,
self.schema,
self.path,
fullpath,
withwarning,
flatten,
None)
return ret
@ -609,9 +611,12 @@ class ContextValue(_Value):
config: 'Config',
schema: Dict) -> None:
self.config = config
first = next(iter(schema.keys()))
self.path = first.rsplit('.', 1)[0]
self.schema = {'properties': schema}
if schema:
first = next(iter(schema.keys()))
self.path = first.rsplit('.', 1)[0]
self.schema = {'properties': schema}
else:
self.schema = {}
def __call__(self) -> TiramisuOptionValue:
return TiramisuOptionValue(self.config,
@ -1190,7 +1195,7 @@ class Config:
value: Any) -> bool:
if not path in self.form or not 'pattern' in self.form[path]:
return True
if value is None or value is '':
if value is None or value == '':
match = True
else:
if isinstance(value, int):