Skip to content

Commit 53b9c89

Browse files
authored
Merge pull request #15959 from Pronoss/fix/update
chore: improve code readability and style in regressions.py and splitSources.py
2 parents 2c5a4d5 + 37d4a72 commit 53b9c89

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

scripts/regressions.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ def __init__(self, interval=300):
2222
thread.start()
2323

2424
def run(self):
25-
""" Runs until the main Python thread exits. """
26-
## Print a newline at the very beginning.
25+
""" Run indefinitely until the main Python thread exits. """
26+
## Print an initial newline at the very beginning.
2727
print("")
2828
while True:
2929
# Print dot
3030
print(".")
3131
time.sleep(self.interval)
3232

33-
class regressor:
33+
class Regressor:
3434
_re_sanitizer_log = re.compile(r"""ERROR: (libFuzzer|UndefinedBehaviorSanitizer)""")
3535

3636
def __init__(self, description, args):
@@ -87,7 +87,7 @@ def process_log(self, logfile):
8787
False -> Failure
8888
"""
8989

90-
## Log may contain non ASCII characters, so we simply stringify them
90+
## Log may contain non-ASCII characters, so we simply stringify them
9191
## since they don't matter for regular expression matching
9292
with open(logfile, 'rb', encoding=None) as f:
9393
rawtext = str(f.read())
@@ -122,5 +122,5 @@ def run(self):
122122

123123
if __name__ == '__main__':
124124
dotprinter = PrintDotsThread()
125-
tool = regressor(DESCRIPTION, sys.argv[1:])
125+
tool = Regressor(DESCRIPTION, sys.argv[1:])
126126
sys.exit(not tool.run())

scripts/splitSources.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
#
33
# This script reads a syntaxTest file and writes all
4-
# sources into their own files. If one source-name specifies subdirectories
4+
# sources into separate files. If a source name specifies subdirectories,
55
# those will be created too.
66

77
# Usage: scripts/splitSources.py pathToTestfile
@@ -18,7 +18,7 @@ def uncaught_exception_hook(exc_type, exc_value, exc_traceback):
1818
# The script `scripts/ASTImportTest.sh` will interpret return code 3
1919
# as a critical error (because of the uncaught exception) and will
2020
# terminate further execution.
21-
print("Unhandled exception: %s", "".join(traceback.format_exception(exc_type, exc_value, exc_traceback)))
21+
print("Unhandled exception: " + "".join(traceback.format_exception(exc_type, exc_value, exc_traceback)))
2222
sys.exit(3)
2323

2424

@@ -42,7 +42,7 @@ def writeSourceToFile(lines):
4242
with open(srcName, mode='a+', encoding='utf8', newline='') as f:
4343
for idx, line in enumerate(lines[1:]):
4444
# write to file
45-
if line[:12] != "==== Source:":
45+
if not line.startswith("==== Source:"):
4646
f.write(line + '\n')
4747

4848
# recursive call if there is another source

0 commit comments

Comments
 (0)