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
+23
View File
@@ -0,0 +1,23 @@
"""Stub magic — trilium_py importe ce module pour deviner les types MIME
lors des uploads de fichiers, fonctionnalité que le MCP n'utilise pas.
libmagic (bibliothèque C) est absente de DSM et non installable par pip
sur ARM64. Ce stub satisfait l'import sans la lib native."""
def from_buffer(buffer, mime=False):
return "application/octet-stream" if mime else "data"
def from_file(filename, mime=False):
return "application/octet-stream" if mime else "data"
class Magic:
def __init__(self, *args, **kwargs):
pass
def from_buffer(self, buffer):
return "application/octet-stream"
def from_file(self, filename):
return "application/octet-stream"
+27
View File
@@ -0,0 +1,27 @@
anyio==4.5.2
beautifulsoup4==4.15.0
certifi==2026.6.17
charset-normalizer==3.4.9
click==8.1.8
exceptiongroup==1.3.1
h11==0.16.0
idna==3.15
loguru==0.7.3
markdown2==2.5.1
minify_html==0.18.1
natsort==8.4.0
Pygments==2.19.2
python-dotenv==1.0.1
python-multipart==0.0.20
PyYAML==6.0.3
requests==2.32.4
six==1.17.0
sniffio==1.3.1
soupsieve==2.7
starlette==0.44.0
svgwrite==1.4.3
trilium-py==0.7.0
typing_extensions==4.13.2
urllib3==2.2.3
uvicorn==0.33.0
wavedrom==2.0.3.post3
+3 -2
View File
@@ -2,6 +2,7 @@
trilium_api.py — Wrapper trilium-py pour TriliumNext 0.95+ trilium_api.py — Wrapper trilium-py pour TriliumNext 0.95+
Tous les autres scripts importent depuis ce module uniquement. Tous les autres scripts importent depuis ce module uniquement.
""" """
import secrets
import os import os
from typing import Optional from typing import Optional
from dotenv import load_dotenv from dotenv import load_dotenv
@@ -114,7 +115,7 @@ def set_label(note_id: str, name: str, value: str = ""):
if existants: if existants:
ea.patch_attribute(attributeId=existants[0].get("attributeId"), value=value) ea.patch_attribute(attributeId=existants[0].get("attributeId"), value=value)
else: 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) name=name, value=value, isInheritable=False)
def get_label_value(note_id: str, name: str) -> Optional[str]: 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: 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)) return (True, "Relation deja presente: %s ~%s %s" % (source_id, nom, cible_id))
try: 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) name=nom, value=cible_id, isInheritable=False)
except Exception as e: except Exception as e:
return (False, "Echec creation relation: %s" % e) return (False, "Echec creation relation: %s" % e)