1515
1616from build_docs import format_seconds
1717
18+
1819def get_lines () -> list [str ]:
1920 lines = []
2021 zipped_logs = list (Path .cwd ().glob ("docsbuild.log.*.gz" ))
21- zipped_logs .sort (key = lambda p : int (p .name .split ('.' )[- 2 ]), reverse = True )
22+ zipped_logs .sort (key = lambda p : int (p .name .split ("." )[- 2 ]), reverse = True )
2223 for logfile in zipped_logs :
2324 with gzip .open (logfile , "rt" , encoding = "utf-8" ) as f :
2425 lines += f .readlines ()
2526 with open ("docsbuild.log" , encoding = "utf-8" ) as f :
26- lines += f .readlines ()
27+ lines += f .readlines ()
2728 return lines
2829
2930
3031def calc_time (lines : list [str ]) -> None :
3132 start = end = language = version = start_timestamp = None
32- reason = lang_ver = ''
33+ reason = lang_ver = ""
3334
3435 print ("Start | Version | Language | Build | Trigger" )
3536 print (":-- | :--: | :--: | --: | :--:" )
3637
3738 for line in lines :
3839 line = line .strip ()
3940
40- if ' : Should rebuild: ' in line :
41- if ' no previous state found' in line :
42- reason = ' brand new'
43- elif ' new translations' in line :
44- reason = ' translation'
45- elif ' Doc/ has changed' in line :
46- reason = ' docs'
41+ if " : Should rebuild: " in line :
42+ if " no previous state found" in line :
43+ reason = " brand new"
44+ elif " new translations" in line :
45+ reason = " translation"
46+ elif " Doc/ has changed" in line :
47+ reason = " docs"
4748 else :
48- reason = ''
49+ reason = ""
4950 lang_ver = line .split (" " )[3 ].removesuffix (":" )
5051
5152 if line .endswith ("Build start." ):
@@ -62,19 +63,24 @@ def calc_time(lines: list[str]) -> None:
6263 if start and end :
6364 duration = (end - start ).total_seconds ()
6465 fmt_duration = format_seconds (duration )
65- if lang_ver != f'{ language } /{ version } ' :
66- reason = ''
67- print (f"{ start_timestamp : <20} | { version : <7} | { language : <8} | { fmt_duration :<14} | { reason } " )
66+ if lang_ver != f"{ language } /{ version } " :
67+ reason = ""
68+ print (
69+ f"{ start_timestamp : <20} | { version : <7} | { language : <8} | { fmt_duration :<14} | { reason } "
70+ )
6871 start = end = start_timestamp = None
6972
70- if ' : Full build done' in line :
73+ if " : Full build done" in line :
7174 timestamp = f"{ line [:16 ]} UTC"
7275 _ , fmt_duration = line .removesuffix (")." ).split ("(" )
73- print (f"{ timestamp : <20} | --FULL- | -BUILD-- | { fmt_duration :<14} | -----------" )
76+ print (
77+ f"{ timestamp : <20} | --FULL- | -BUILD-- | { fmt_duration :<14} | -----------"
78+ )
7479
7580 if start and end is None :
76- print (f"{ start_timestamp : <20} | { version : <7} | { language : <8} | In progress... | { reason } " )
77-
81+ print (
82+ f"{ start_timestamp : <20} | { version : <7} | { language : <8} | In progress... | { reason } "
83+ )
7884
7985
8086if __name__ == "__main__" :
0 commit comments