# HG changeset patch # User Henry S. Thompson # Date 1656954746 -3600 # Node ID ace590c2fdfc5c4f93cde86e0a546c5dbe1fc03f # Parent 58b90cd52c157a736daec952808187b0fc22f96c allow use of global stash diff -r 58b90cd52c15 -r ace590c2fdfc bin/cdx2tsv.py --- 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)