Mercurial > hg > cc > cirrus_work
diff bin/sort_date.py @ 86:3a2ae6057242
handle double .www, more keep-me chars
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Mon, 28 Aug 2023 21:07:43 +0100 |
parents | 1daa8e444cfe |
children | 49faf679d7df |
line wrap: on
line diff
--- a/bin/sort_date.py Thu Aug 24 18:21:41 2023 +0100 +++ b/bin/sort_date.py Mon Aug 28 21:07:43 2023 +0100 @@ -20,10 +20,24 @@ codecs.register_error('percent',percent_encode) +# From RFC-3986: +# gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@" +# sub-delims = "!" / "$" / "&" / "'" / "(" / ")" +# / "*" / "+" / "," / ";" / "=" +# But # _is_ escaped in Java surt results +# and additionally " \ : < = > ? \ ^ _ ` { | } are not + +# Also, Java surt strips _all_ leading 'www.', +# where python3 surt only strips the first one. + def cdx_key(uristring): - return quote(unquote(surt(uristring), - errors='percent'), - safe='/,:)?=').lower() + _surt = quote(unquote(surt(uristring), + errors='percent'), + safe='!"$&\'()*+,/:;<=>?@[\\]^_`{|}').lower() + while _surt.endswith(",www"): + _surt = _surt[:-4] + + return _surt def keyed(l): uri, cc_stamp, dateTime = l.split('\t',2)