|
57 | 57 | # We import this using __import__ so that "tox -e relint" does not complain about this source file.
|
58 | 58 | __import__("sage.all", globals(), locals(), ["*"])
|
59 | 59 |
|
| 60 | + |
60 | 61 | # Keep in sync with SAGE_ROOT/src/.relint.yml (namespace_pkg_all_import)
|
61 | 62 |
|
62 | 63 | default_package_regex = (r"sage("
|
@@ -402,25 +403,6 @@ def walkdir_replace_dot_all(dir, file_regex=r'.*[.](py|pyx|pxi)$', package_regex
|
402 | 403 | make_replacements_in_file(location, package_regex, verbose)
|
403 | 404 |
|
404 | 405 |
|
405 |
| -def print_log_messages(): |
406 |
| - r""" |
407 |
| - Print out the messages collected in the global variable ``log_messages``. |
408 |
| -
|
409 |
| - This function sorts the lines of ``log_messages`` by the first character of each line (lines are separated by \n). |
410 |
| - """ |
411 |
| - global log_messages |
412 |
| - # split the log messages into a list of strings (each string is a line separated by a newline character) |
413 |
| - log_messages = log_messages.split('\n') |
414 |
| - # sort the list of strings |
415 |
| - log_messages.sort() |
416 |
| - # add index to each line |
417 |
| - for i, message in enumerate(log_messages): |
418 |
| - log_messages[i] = f'{i}. {message}' |
419 |
| - # join the list of strings into a single string separated by newline characters |
420 |
| - log_messages = '\n'.join(log_messages)[2:] |
421 |
| - print(log_messages) |
422 |
| - |
423 |
| - |
424 | 406 | # ******************************************************** EXECUTES MAIN FUNCTION **********************************************************************
|
425 | 407 | # this executes the main function in this file which writes over all import statements matching regex in files in specified location matching fileRegex:
|
426 | 408 | if __name__ == "__main__":
|
@@ -457,7 +439,10 @@ def print_log_messages():
|
457 | 439 | finally:
|
458 | 440 | # Print report also when interrupted
|
459 | 441 | if verbosity:
|
460 |
| - print_log_messages() |
| 442 | + log_messages = sorted(log_messages.rstrip().split('\n')) |
| 443 | + for i, message in enumerate(log_messages, start=1): |
| 444 | + # add index to each line |
| 445 | + print(f'{i}. {message.rstrip()}') |
461 | 446 | report = 'REPORT:\n'
|
462 | 447 | report += f'Number of files checked: {numberFiles}\n'
|
463 | 448 | report += f'Number of files matching regex: {numberFilesMatchingRegex}\n'
|
|
0 commit comments