fix(helper/config::typecast): add boolean evaluation
This commit is contained in:
parent
843354e18d
commit
0fb50c5a57
1 changed files with 3 additions and 1 deletions
|
|
@ -3,6 +3,7 @@ from pathlib import Path
|
||||||
from configparser import ConfigParser, NoSectionError
|
from configparser import ConfigParser, NoSectionError
|
||||||
from typing import Optional, NamedTuple
|
from typing import Optional, NamedTuple
|
||||||
from os import environ
|
from os import environ
|
||||||
|
from ast import literal_eval
|
||||||
|
|
||||||
|
|
||||||
CONFIGPATH_ENVIRON = 'HTTPASTE_CONFIGPATH'
|
CONFIGPATH_ENVIRON = 'HTTPASTE_CONFIGPATH'
|
||||||
|
|
@ -49,8 +50,9 @@ def typecast(obj: dict, aclass: type, dirname:Optional[Path] = None) -> dict:
|
||||||
|
|
||||||
casted[k] = casted_val = dirname / v
|
casted[k] = casted_val = dirname / v
|
||||||
elif issubclass(bclass, bytes):
|
elif issubclass(bclass, bytes):
|
||||||
|
|
||||||
casted[k] = bclass(v.encode('utf-8'))
|
casted[k] = bclass(v.encode('utf-8'))
|
||||||
|
elif issubclass(bclass, bool):
|
||||||
|
casted[k] = literal_eval(v)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
casted_val = bclass(v)
|
casted_val = bclass(v)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue