Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Sep 23, 2024
1 parent 245637d commit 3de813e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.7
hooks:
- id: ruff-format

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.2
hooks:
Expand Down
2 changes: 1 addition & 1 deletion build_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ def build(self):
# Disable CPython switchers, we handle them now:

def is_mac():
return platform.system() == 'Darwin'
return platform.system() == "Darwin"

run(
["sed", "-i"]
Expand Down
42 changes: 24 additions & 18 deletions check_times.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,38 @@

from build_docs import format_seconds


def get_lines() -> list[str]:
lines = []
zipped_logs = list(Path.cwd().glob("docsbuild.log.*.gz"))
zipped_logs.sort(key=lambda p: int(p.name.split('.')[-2]), reverse=True)
zipped_logs.sort(key=lambda p: int(p.name.split(".")[-2]), reverse=True)
for logfile in zipped_logs:
with gzip.open(logfile, "rt", encoding="utf-8") as f:
lines += f.readlines()
with open("docsbuild.log", encoding="utf-8") as f:
lines += f.readlines()
lines += f.readlines()
return lines


def calc_time(lines: list[str]) -> None:
start = end = language = version = start_timestamp = None
reason = lang_ver = ''
reason = lang_ver = ""

print("Start | Version | Language | Build | Trigger")
print(":-- | :--: | :--: | --: | :--:")

for line in lines:
line = line.strip()

if ': Should rebuild: ' in line:
if 'no previous state found' in line:
reason = 'brand new'
elif 'new translations' in line:
reason = 'translation'
elif 'Doc/ has changed' in line:
reason = 'docs'
if ": Should rebuild: " in line:
if "no previous state found" in line:
reason = "brand new"
elif "new translations" in line:
reason = "translation"
elif "Doc/ has changed" in line:
reason = "docs"
else:
reason = ''
reason = ""
lang_ver = line.split(" ")[3].removesuffix(":")

if line.endswith("Build start."):
Expand All @@ -62,19 +63,24 @@ def calc_time(lines: list[str]) -> None:
if start and end:
duration = (end - start).total_seconds()
fmt_duration = format_seconds(duration)
if lang_ver != f'{language}/{version}':
reason = ''
print(f"{start_timestamp: <20} | {version: <7} | {language: <8} | {fmt_duration :<14} | {reason}")
if lang_ver != f"{language}/{version}":
reason = ""
print(
f"{start_timestamp: <20} | {version: <7} | {language: <8} | {fmt_duration :<14} | {reason}"
)
start = end = start_timestamp = None

if ': Full build done' in line:
if ": Full build done" in line:
timestamp = f"{line[:16]} UTC"
_, fmt_duration = line.removesuffix(").").split("(")
print(f"{timestamp: <20} | --FULL- | -BUILD-- | {fmt_duration :<14} | -----------")
print(
f"{timestamp: <20} | --FULL- | -BUILD-- | {fmt_duration :<14} | -----------"
)

if start and end is None:
print(f"{start_timestamp: <20} | {version: <7} | {language: <8} | In progress... | {reason}")

print(
f"{start_timestamp: <20} | {version: <7} | {language: <8} | In progress... | {reason}"
)


if __name__ == "__main__":
Expand Down

0 comments on commit 3de813e

Please sign in to comment.