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]:
|
||||
if isinstance(x, dict):
|
||||
return dict(x)
|
||||
try:
|
||||
return dict(x or {})
|
||||
except Exception:
|
||||
return {"raw": str(x)}
|
||||
# Versuche, ein ParsedMarkdown-ähnliches Objekt in ein Dict zu überführen
|
||||
out: Dict[str, Any] = {}
|
||||
# bekannte Attribute übernehmen
|
||||
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]]:
|
||||
path = kwargs.get("path") or (args[0] if args else None)
|
||||
|
||||
Reference in new issue
Block a user