mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
Better data handling
This commit is contained in:
@@ -59,13 +59,15 @@ def readfile(filename: str, silent: bool = False, lock: bool = False, *, as_type
|
||||
except Exception:
|
||||
locking_available = False
|
||||
if isinstance(data, list) and as_type == "dict":
|
||||
log.warning(f"Read: Expected dictionary from '{filename}' but got list")
|
||||
if not data:
|
||||
return {}
|
||||
data0 = data[0]
|
||||
if isinstance(data0, dict):
|
||||
return data0
|
||||
return {}
|
||||
if isinstance(data, dict) and as_type == "list":
|
||||
log.warning(f"Read: Expected list from '{filename}' but got dictionary")
|
||||
if not data:
|
||||
return []
|
||||
return [data]
|
||||
return data
|
||||
|
||||
|
||||
Reference in New Issue
Block a user