fix: compat trilium-py 0.7 (attributeId), stub magic sans libmagic, requirements figes

This commit is contained in:
2026-07-12 23:50:31 +02:00
parent 7c56f125ad
commit d1e67431b6
3 changed files with 53 additions and 2 deletions
+3 -2
View File
@@ -2,6 +2,7 @@
trilium_api.py — Wrapper trilium-py pour TriliumNext 0.95+
Tous les autres scripts importent depuis ce module uniquement.
"""
import secrets
import os
from typing import Optional
from dotenv import load_dotenv
@@ -114,7 +115,7 @@ def set_label(note_id: str, name: str, value: str = ""):
if existants:
ea.patch_attribute(attributeId=existants[0].get("attributeId"), value=value)
else:
ea.create_attribute(noteId=note_id, type="label",
ea.create_attribute(attributeId=secrets.token_hex(6), noteId=note_id, type="label",
name=name, value=value, isInheritable=False)
def get_label_value(note_id: str, name: str) -> Optional[str]:
@@ -220,7 +221,7 @@ def add_relation_safe(source_id, nom, cible_id):
if a.get("type") == "relation" and a.get("name") == nom and a.get("value") == cible_id:
return (True, "Relation deja presente: %s ~%s %s" % (source_id, nom, cible_id))
try:
_ea().create_attribute(noteId=source_id, type="relation",
_ea().create_attribute(attributeId=secrets.token_hex(6), noteId=source_id, type="relation",
name=nom, value=cible_id, isInheritable=False)
except Exception as e:
return (False, "Echec creation relation: %s" % e)