Created
March 23, 2022 15:05
-
-
Save akaszynski/e82c1e1c9977b32242e947f3c5bf08c0 to your computer and use it in GitHub Desktop.
Print errors redirected from sphinx.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Read errors output from a sphinx build and remove duplicate groups""" | |
import os | |
import pathlib | |
import sys | |
sys.tracebacklimit = 0 | |
my_path = pathlib.Path(__file__).parent.resolve() | |
errors = set() | |
error_file = os.path.join(my_path, "build_errors.txt") | |
if os.path.isfile(error_file): | |
with open(error_file) as fid: | |
group = [] | |
for line in fid.readlines(): | |
line = line.strip() | |
if line: | |
group.append(line) | |
else: | |
errors.add("\n".join(group)) | |
group = [] | |
errors.add("\n".join(group)) | |
for error in list(errors): | |
print(error) | |
print() | |
# There should be no errors here since sphinx will have exited | |
print() | |
if errors: | |
raise Exception(f"Sphinx reported unique {len(errors)} warnings\n\n") | |
print(f"Sphinx Reported no warnings\n\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment