Mercurial > hg > cc > cirrus_home
changeset 156:ace590c2fdfc
allow use of global stash
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Mon, 04 Jul 2022 18:12:26 +0100 |
parents | 58b90cd52c15 |
children | cac9586291ad |
files | bin/cdx2tsv.py |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/bin/cdx2tsv.py Fri Jul 01 17:50:06 2022 +0200 +++ b/bin/cdx2tsv.py Mon Jul 04 18:12:26 2022 +0100 @@ -27,7 +27,10 @@ fields=sys.argv[1:] -fields=[((lambda x,y:(x,eval("lambda f:%s"%y)))(*(f[1:-1].split(',',maxsplit=1))) if f[0]=='(' else f) for f in fields] +stash={} # This can be used to save an expensive field computation for re-use: + # E.g. '(filename,(lambda g:(stash.__setitem__("T1",g) or g)[3].split(".")[1])(f.split("/",maxsplit=5)))' '(filename,(stash["T1"])[4][0]) + +fields=[((lambda x,y:(x,eval("lambda f:%s"%y,globals())))(*(f[1:-1].split(',',maxsplit=1))) if f[0]=='(' else f) for f in fields] for l in sys.stdin: (key,stamp,jj)=l.rstrip().split(' ',maxsplit=2) ja=json.loads(jj)