tests/list_md_seen_by_importer.py hinzugefügt
All checks were successful
Deploy mindnet to llm-node / deploy (push) Successful in 3s

This commit is contained in:
Lars 2025-10-01 10:24:25 +02:00
parent 18cdbab885
commit 6b4b3ce2ba

View File

@ -0,0 +1,49 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
tests/list_md_seen_by_importer.py
Zeigt, welche Markdown-Dateien der Importer sehen würde (gleiche Filter & Sortierung).
Usage:
python3 tests/list_md_seen_by_importer.py --vault ./test_vault
"""
from __future__ import annotations
import argparse, os, sys, json
def iter_md(root: str):
out = []
for dirpath, _, filenames in os.walk(root):
for fn in filenames:
p = os.path.join(dirpath, fn)
pn = p.replace("\\", "/")
item = {
"path": os.path.abspath(p),
"rel": os.path.relpath(p, root).replace("\\", "/"),
"included": False,
"reason": "",
}
if not fn.lower().endswith(".md"):
item["reason"] = "skip_ext"
elif "/.obsidian/" in pn or "/_backup_frontmatter/" in pn or "/_imported/" in pn:
item["reason"] = "skip_special_dir"
else:
item["included"] = True
item["reason"] = "ok"
out.append(item)
# auch die ausgeschlossenen zeigen:
if not item["included"]:
print(json.dumps(item, ensure_ascii=False))
out_sorted = sorted(out, key=lambda x: x["rel"])
for i, it in enumerate(out_sorted):
it["order"] = i
print(json.dumps(it, ensure_ascii=False))
print(json.dumps({"summary":"done","included":len(out_sorted)}, ensure_ascii=False))
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--vault", required=True)
args = ap.parse_args()
root = os.path.abspath(args.vault)
iter_md(root)
if __name__ == "__main__":
main()