mirror of
https://github.com/lnbits/lnbits.git
synced 2025-03-17 21:31:55 +01:00
[REFACTOR] do not throw an exception in list_parse_fallback (#1891)
This commit is contained in:
parent
c54f48ee73
commit
1efec9bb80
@ -12,15 +12,15 @@ from loguru import logger
|
||||
from pydantic import BaseSettings, Extra, Field, validator
|
||||
|
||||
|
||||
def list_parse_fallback(v):
|
||||
try:
|
||||
return json.loads(v)
|
||||
except Exception:
|
||||
replaced = v.replace(" ", "")
|
||||
if replaced:
|
||||
return replaced.split(",")
|
||||
def list_parse_fallback(v: str):
|
||||
v = v.replace(" ", "")
|
||||
if len(v) > 0:
|
||||
if v.startswith("[") or v.startswith("{"):
|
||||
return json.loads(v)
|
||||
else:
|
||||
return []
|
||||
return v.split(",")
|
||||
else:
|
||||
return []
|
||||
|
||||
|
||||
class LNbitsSettings(BaseSettings):
|
||||
|
Loading…
x
Reference in New Issue
Block a user