aboutsummaryrefslogtreecommitdiff
path: root/mu4web/xapian.py
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-07-25 21:42:27 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2023-07-25 22:05:20 +0200
commit210ee835662877c4e5a94450d0656680875e0e18 (patch)
tree79823306a0aea842541a8b2586fcf47b0ced0eb5 /mu4web/xapian.py
parentConfigure linters. (diff)
downloadmu4web-210ee835662877c4e5a94450d0656680875e0e18.tar.gz
mu4web-210ee835662877c4e5a94450d0656680875e0e18.tar.xz
Fix and harden linter checks.
Harden the requirements of mypy, and also check against flake8 docstrings. And fix all errors and warnings resulting from that.
Diffstat (limited to '')
-rw-r--r--mu4web/xapian.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/mu4web/xapian.py b/mu4web/xapian.py
index d23b2d1..94e597d 100644
--- a/mu4web/xapian.py
+++ b/mu4web/xapian.py
@@ -1,8 +1,24 @@
+"""
+Extra xapian procedures.
+
+The python-xapian library exists, but doesn't seem to export metadata.
+"""
+
import subprocess
from typing import Optional
def metadata_list(db: str, prefix: Optional[str] = None) -> list[str]:
+ """
+ Enumerate all metadata entries in the given database.
+
+ :param db:
+ File system path to an Xapian "database". This is the
+ directory containing iamglass, flintlock, and .glass files.
+
+ :param prefix:
+ Limit list to entries starting with this string.
+ """
cmdline = ['xapian-metadata', 'list', db]
if prefix:
cmdline.append(prefix)
@@ -11,6 +27,15 @@ def metadata_list(db: str, prefix: Optional[str] = None) -> list[str]:
def metadata_get(db: str, key: str) -> str:
+ """
+ Get a xapian metadata value.
+
+ :param db:
+ Same as for metadata_list
+
+ :param key:
+ Exact name of key to look up.
+ """
cmd = subprocess.run(['xapian-metadata', 'get', db, key],
capture_output=True, text=True)
return cmd.stdout.strip()