[REFACTOR] do not throw an exception in list_parse_fallback (#1891)
This commit is contained in:
parent
c54f48ee73
commit
1efec9bb80
1 changed files with 8 additions and 8 deletions
|
|
@ -12,15 +12,15 @@ from loguru import logger
|
||||||
from pydantic import BaseSettings, Extra, Field, validator
|
from pydantic import BaseSettings, Extra, Field, validator
|
||||||
|
|
||||||
|
|
||||||
def list_parse_fallback(v):
|
def list_parse_fallback(v: str):
|
||||||
try:
|
v = v.replace(" ", "")
|
||||||
return json.loads(v)
|
if len(v) > 0:
|
||||||
except Exception:
|
if v.startswith("[") or v.startswith("{"):
|
||||||
replaced = v.replace(" ", "")
|
return json.loads(v)
|
||||||
if replaced:
|
|
||||||
return replaced.split(",")
|
|
||||||
else:
|
else:
|
||||||
return []
|
return v.split(",")
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
class LNbitsSettings(BaseSettings):
|
class LNbitsSettings(BaseSettings):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue