This commit is contained in:
1 parent
3374c41f07
commit
f1f4358dee
1 file changed
+12
-4
@@ -26,10 +26,18 @@ except Exception:
|
|||||||
def _as_dict(x) -> Dict[str, Any]:
|
def _as_dict(x) -> Dict[str, Any]:
|
||||||
if isinstance(x, dict):
|
if isinstance(x, dict):
|
||||||
return dict(x)
|
return dict(x)
|
||||||
try:
|
# Versuche, ein ParsedMarkdown-ähnliches Objekt in ein Dict zu überführen
|
||||||
return dict(x or {})
|
out: Dict[str, Any] = {}
|
||||||
except Exception:
|
# bekannte Attribute übernehmen
|
||||||
return {"raw": str(x)}
|
for attr in ("frontmatter", "body", "id", "note_id", "title", "path", "tags", "type", "created", "modified", "date"):
|
||||||
|
if hasattr(x, attr):
|
||||||
|
val = getattr(x, attr)
|
||||||
|
if val is not None:
|
||||||
|
out[attr] = val
|
||||||
|
# Fallback: wenn immer noch leer, raw speichern
|
||||||
|
if not out:
|
||||||
|
out["raw"] = str(x)
|
||||||
|
return out
|
||||||
|
|
||||||
def _pick_args(*args, **kwargs) -> Tuple[Optional[str], Optional[dict]]:
|
def _pick_args(*args, **kwargs) -> Tuple[Optional[str], Optional[dict]]:
|
||||||
path = kwargs.get("path") or (args[0] if args else None)
|
path = kwargs.get("path") or (args[0] if args else None)
|
||||||
|
|||||||
Reference in new issue
Block a user