aboutsummaryrefslogtreecommitdiff
path: root/mu4web/xapian.py
diff options
context:
space:
mode:
Diffstat (limited to 'mu4web/xapian.py')
-rw-r--r--mu4web/xapian.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/mu4web/xapian.py b/mu4web/xapian.py
new file mode 100644
index 0000000..8aebf72
--- /dev/null
+++ b/mu4web/xapian.py
@@ -0,0 +1,16 @@
+import subprocess
+from typing import Optional
+
+def metadata_list(db, prefix: Optional[str] = None) -> list[str]:
+ cmdline = ['xapian-metadata', 'list', db]
+ if prefix:
+ cmdline.append(prefix)
+ cmd = subprocess.run(cmdline, capture_output=True, text=True)
+ return cmd.stdout.split('\n')
+
+
+def metadata_get(db, key: str) -> str:
+ cmd = subprocess.run(['xapian-metadata', 'get', db, key],
+ capture_output=True, text=True)
+ return cmd.stdout.strip()
+