1212import re
1313import sys
1414from urllib .parse import quote_plus
15- import natsort
15+
1616import humanize
17+ import natsort
1718from packaging .utils import parse_wheel_filename
1819
19- PREFIX = 'https://s3.amazonaws.com/ifcopenshell-builds/'
20+ PREFIX = "https://s3.amazonaws.com/ifcopenshell-builds/"
21+
2022
2123def _ ():
2224 import json
25+
2326 d = json .load (open (sys .argv [1 ]))
24- for c in d [' Contents' ]:
25- k = c [' Key' ]
26- if k .endswith (' .zip' ):
27- parts = k [:- 4 ].rsplit ('-' , 3 )
27+ for c in d [" Contents" ]:
28+ k = c [" Key" ]
29+ if k .endswith (" .zip" ):
30+ parts = k [:- 4 ].rsplit ("-" , 3 )
2831 if len (parts ) == 4 :
2932 product , version , hash , os = parts
30-
31- if product in {' IfcConvert' , ' IfcGeomServer' , ' svgfill' }:
33+
34+ if product in {" IfcConvert" , " IfcGeomServer" , " svgfill" }:
3235 pass
33- elif re .match (r' ^ifcopenshell-python-\d{2,3}u?$' , product ):
36+ elif re .match (r" ^ifcopenshell-python-\d{2,3}u?$" , product ):
3437 pass
3538 else :
3639 continue
@@ -40,21 +43,20 @@ def _():
4043 else :
4144 continue
4245
43- if re .match (r' ^v\d\.\d\.\d+$' , version ):
46+ if re .match (r" ^v\d\.\d\.\d+$" , version ):
4447 pass
4548 else :
4649 continue
4750
48- if os in {' macosm164' , ' macos64' , ' linux64' , ' linuxarm64' , ' win32' , ' win64' , ' linux32' }:
51+ if os in {" macosm164" , " macos64" , " linux64" , " linuxarm64" , " win32" , " win64" , " linux32" }:
4952 pass
5053 else :
5154 continue
5255
53-
54- yield version , hash , c ['LastModified' ], product , os , c ['Size' ], k
55- elif k .endswith ('.whl' ):
56- fixed = k .replace ('ifcopenshell-python' , 'ifcopenshell_python' )
57- fixed = re .sub (r'(v\d\.\d\.\d)(\-|\+)(\w{7})' , 'v0.8.1+\\ 3' , fixed )
56+ yield version , hash , c ["LastModified" ], product , os , c ["Size" ], k
57+ elif k .endswith (".whl" ):
58+ fixed = k .replace ("ifcopenshell-python" , "ifcopenshell_python" )
59+ fixed = re .sub (r"(v\d\.\d\.\d)(\-|\+)(\w{7})" , "v0.8.1+\\ 3" , fixed )
5860 try :
5961 module_name , version , _ , tags = parse_wheel_filename (fixed )
6062 except :
@@ -68,12 +70,12 @@ def _():
6870
6971 tag = next (iter (tags ))
7072
71- if ' wasm' not in tag .platform :
73+ if " wasm" not in tag .platform :
7274 continue
7375
74- abi = re .sub (' c|p|y' , '' , tag .abi )
76+ abi = re .sub (" c|p|y" , "" , tag .abi )
7577
76- yield f' v{ version .public } ' , version .local , c [' LastModified' ], f' { module_name } -{ abi } ' , ' WASM' , c [' Size' ], k
78+ yield f" v{ version .public } " , version .local , c [" LastModified" ], f" { module_name } -{ abi } " , " WASM" , c [" Size" ], k
7779
7880
7981if len (sys .argv ) != 2 :
@@ -84,20 +86,35 @@ def _():
8486print ("Source code - [IfcOpenShell/build-listing](https://github.com/IfcOpenShell/build-listing)" )
8587print ()
8688
87- hashtodate = dict ((hash , functools .reduce (min , (t [1 ] for t in hash_dates ))) for hash , hash_dates in itertools .groupby (sorted ((a [1 ],a [2 ]) for a in _ ()), key = operator .itemgetter (0 )))
89+ hashtodate = dict (
90+ (hash , functools .reduce (min , (t [1 ] for t in hash_dates )))
91+ for hash , hash_dates in itertools .groupby (sorted ((a [1 ], a [2 ]) for a in _ ()), key = operator .itemgetter (0 ))
92+ )
8893data = natsort .natsorted (_ (), reverse = True )
8994for section , subsections in itertools .groupby (data , key = operator .itemgetter (0 )):
90- print ('##' , section )
95+ print ("##" , section )
9196
92- for hash , rows in itertools .groupby (sorted (subsections , key = lambda t : hashtodate [t [1 ]], reverse = True ), key = operator .itemgetter (1 )):
93- print ('###' , hash , '(%s)' % hashtodate [hash ])
97+ for hash , rows in itertools .groupby (
98+ sorted (subsections , key = lambda t : hashtodate [t [1 ]], reverse = True ), key = operator .itemgetter (1 )
99+ ):
100+ print ("###" , hash , "(%s)" % hashtodate [hash ])
94101 rows = list (rows )
95102 product , os , size = map (lambda vs : natsort .natsorted (set (vs )), zip (* (r [3 :6 ] for r in rows )))
96- osh = list (map (lambda s : s [0 ].upper () + s [1 :], map (lambda s : re .sub (r'(32|64)' , ' \\ 1bit' , s .replace ('m1' , ' M1' ).replace ('arm' , ' ARM' )).replace ('os' , 'OS' ), os )))
103+ osh = list (
104+ map (
105+ lambda s : s [0 ].upper () + s [1 :],
106+ map (
107+ lambda s : re .sub (r"(32|64)" , " \\ 1bit" , s .replace ("m1" , " M1" ).replace ("arm" , " ARM" )).replace (
108+ "os" , "OS"
109+ ),
110+ os ,
111+ ),
112+ )
113+ )
97114 d = dict ((r [3 :5 ], (humanize .naturalsize (r [5 ]), quote_plus (r [6 ]))) for r in rows )
98115 print ()
99- print (' item|' , '|' .join (osh ))
100- print ('|' .join ([' ---' ] * (len (osh ) + 1 )))
116+ print (" item|" , "|" .join (osh ))
117+ print ("|" .join ([" ---" ] * (len (osh ) + 1 )))
101118 for p in product :
102- print (p , '|' , '|' .join (map (lambda t : ' [%%s](%s%%s)' % PREFIX % t , (d .get ((p , o ), ('-' , '' )) for o in os ))))
119+ print (p , "|" , "|" .join (map (lambda t : " [%%s](%s%%s)" % PREFIX % t , (d .get ((p , o ), ("-" , "" )) for o in os ))))
103120 print ()
0 commit comments