diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-12-09 23:57:31 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-12-09 23:57:31 +0100 |
commit | 34bef1cd82dadd97dba9c1a7b61751312cc64c09 (patch) | |
tree | 5f690c57ac74834287c5e4994921bfb6d59791ec /mu4web/xapian.py | |
parent | Add comment that python-pam is recomended. (diff) | |
download | mu4web-34bef1cd82dadd97dba9c1a7b61751312cc64c09.tar.gz mu4web-34bef1cd82dadd97dba9c1a7b61751312cc64c09.tar.xz |
Change info gathering to proper db reads.
Running `xapian info` and parsing the output breaks way to easily, here
we instead just open the database file and look for ourselves.
Diffstat (limited to 'mu4web/xapian.py')
-rw-r--r-- | mu4web/xapian.py | 16 |
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() + |