15
15
16
16
from build_docs import format_seconds
17
17
18
+
18
19
def get_lines () -> list [str ]:
19
20
lines = []
20
21
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 )
22
23
for logfile in zipped_logs :
23
24
with gzip .open (logfile , "rt" , encoding = "utf-8" ) as f :
24
25
lines += f .readlines ()
25
26
with open ("docsbuild.log" , encoding = "utf-8" ) as f :
26
- lines += f .readlines ()
27
+ lines += f .readlines ()
27
28
return lines
28
29
29
30
30
31
def calc_time (lines : list [str ]) -> None :
31
32
start = end = language = version = start_timestamp = None
32
- reason = lang_ver = ''
33
+ reason = lang_ver = ""
33
34
34
35
print ("Start | Version | Language | Build | Trigger" )
35
36
print (":-- | :--: | :--: | --: | :--:" )
36
37
37
38
for line in lines :
38
39
line = line .strip ()
39
40
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"
47
48
else :
48
- reason = ''
49
+ reason = ""
49
50
lang_ver = line .split (" " )[3 ].removesuffix (":" )
50
51
51
52
if line .endswith ("Build start." ):
@@ -62,19 +63,24 @@ def calc_time(lines: list[str]) -> None:
62
63
if start and end :
63
64
duration = (end - start ).total_seconds ()
64
65
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
+ )
68
71
start = end = start_timestamp = None
69
72
70
- if ' : Full build done' in line :
73
+ if " : Full build done" in line :
71
74
timestamp = f"{ line [:16 ]} UTC"
72
75
_ , 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
+ )
74
79
75
80
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
+ )
78
84
79
85
80
86
if __name__ == "__main__" :
0 commit comments