# HG changeset patch # User Henry S. Thompson # Date 1695895224 -3600 # Node ID 43b0509e70c03db68026848f3207825bbfa604d7 # Parent 961aab0802396933c3932b8f4c390cfc52e5a89e refactor to sort a module in an lmh package diff -r 961aab080239 -r 43b0509e70c0 lib/python/cc/lmh/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/python/cc/lmh/__init__.py Thu Sep 28 11:00:24 2023 +0100 @@ -0,0 +1,5 @@ +'''Nothing to see here''' + +INITED = True + +from .sort_date import cdx_key diff -r 961aab080239 -r 43b0509e70c0 lib/python/cc/lmh/sort_date.py --- a/lib/python/cc/lmh/sort_date.py Thu Sep 28 10:54:12 2023 +0100 +++ b/lib/python/cc/lmh/sort_date.py Thu Sep 28 11:00:24 2023 +0100 @@ -128,15 +128,18 @@ print(dateTime.rstrip(),e,sep='\t',file=sys.stderr) return -fstr = sys.argv[1] +def main(fstr): -with open(fstr,"r") as ff: - # crucial that the following is done _after_ the file is opened - # with the default (utf-8) locale! - locale.setlocale(locale.LC_ALL, "C") - ctk=cmp_to_key(locale.strcoll) - for key, ts in sorted((kk for l in ff if (kk:=keyed(l)) is not None), - key=lambda x:x[0]): - print(key[0],key[1], - key[2].encode('ascii',errors='java_unicode').decode('ascii'), - ts,sep='\t') + with open(fstr,"r") as ff: + # crucial that the following is done _after_ the file is opened + # with the default (utf-8) locale! + locale.setlocale(locale.LC_ALL, "C") + ctk=cmp_to_key(locale.strcoll) + for key, ts in sorted((kk for l in ff if (kk:=keyed(l)) is not None), + key=lambda x:x[0]): + print(key[0],key[1], + key[2].encode('ascii',errors='java_unicode').decode('ascii'), + ts,sep='\t') + +if __name__ == '__main__': + sys.exit(main(fstr = sys.argv[1]))