kitab-index

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 74e243bcd1eeedd582331d2d9d416ba59699e685
parent fd683b556f59143e6407c85c7cabee1ea1b2806e
Author: Louis Holbrook <dev@holbrook.no>
Date:   Wed, 16 Sep 2026 16:11:15 -0600

Add tool

Diffstat:
Mkitab.py | 2+-
Mkitab/index.py | 15+++++++++++++--
2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/kitab.py b/kitab.py @@ -18,7 +18,7 @@ def main(): logg.setLevel(logging.DEBUG) o = Index(args.path) o.load() - o.export_lines(sys.stdout) + o.export_lines(sys.stdout, jsonl=True) if __name__ == '__main__': diff --git a/kitab/index.py b/kitab/index.py @@ -250,10 +250,18 @@ class Index(): def _lines_split_content(self): lxm - def export_lines(self, w): + def export_lines(self, w, jsonl=False): + if not jsonl: + w.write("[") + i = 0 for v in self.ln: + if jsonl: + w.write("\n") + elif i > 0: + w.write(",") o = { 'uuid': str(self.uu), + 'globalseq': i, 'order': v[0], 'level': v[1], 'seq': v[2], @@ -261,7 +269,10 @@ class Index(): 'type': v[4], 'contents': v[5], } - w.write(json.dumps(o) + '\n') + w.write(json.dumps(o)) + i += 1 + if not jsonl: + w.write("]") #def __str__(self):