Mercurial > hg > cc > cirrus_shared
changeset 8:c7c72311b731
fix big comment,
get callback working
| author | Henry S. Thompson <ht@inf.ed.ac.uk> |
|---|---|
| date | Thu, 11 Jun 2026 21:16:41 +0100 |
| parents | 10dfd4feeaa0 |
| children | f6f1deba62af |
| files | bin/cdx2tsv.py |
| diffstat | 1 files changed, 6 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/bin/cdx2tsv.py Thu Jun 11 21:15:35 2026 +0100 +++ b/bin/cdx2tsv.py Thu Jun 11 21:16:41 2026 +0100 @@ -11,8 +11,10 @@ Note that 'key' and 'timestamp' are also available as global variables, so e.g. '(key,key.split(",")[0])' will yield the TLD. - For a callback instead of printing, include -c cb-mod for a module to import + For a callback instead of printing, include -c cb-mod.cb-file for + a file from a module to import and within which to call init() once and the cbf function for each index line + and finally finish() ''' import json,sys @@ -23,9 +25,9 @@ index=str(int(sys.argv.pop(1))) elif sys.argv[1] == '-c': sys.argv.pop(1) - cbmodname = sys.argv.pop(1) - from importlib import import_module - cbm = import_module(cbmodname) + (cbmodname,cbfilename) = sys.argv.pop(1).split('.') + import importlib + cbm = importlib.import_module(cbfilename,cbmodname) cbf=cbm.cbf cbm.init() else:
