Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
src/sage/misc/replace_dot_all.py: Replace sort_log_messages by print_…
Browse files Browse the repository at this point in the history
…log_messages
  • Loading branch information
Matthias Koeppe committed Jan 29, 2023
1 parent 2cbbf2d commit 29e5ddb
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/sage/misc/replace_dot_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,8 @@ def walkdir_replace_dot_all(dir, fileRegex, package_regex, verbose=False):
location = os.path.join(root, name)[1:]
if location.find('replace_dot_all') == -1: # to avoid changing anything in this file itself
make_replacements_in_file(dir + location, package_regex, verbose)
# sort lines of log_messages by first character of each line(lines are separated by \n)
sort_log_messages()
if verbosity:
print(log_messages)
print_log_messages()
report = (f'REPORT:\n'
f'Number of files checked: {numberFiles}\n'
f'Number of files matching regex: {numberFilesMatchingRegex}\n'
Expand All @@ -435,7 +433,7 @@ def walkdir_replace_dot_all(dir, fileRegex, package_regex, verbose=False):
print('*'*100 + '\n' + report + '\n' + '*'*100)


def sort_log_messages():
def print_log_messages():
r"""
If the user executes the function walkdir_replace_dot_all with the verbose parameter set to True, then the global variable log_messages will be a string containing all the log messages.
This function sorts the lines of log_messages by the first character of each line(lines are separated by \n). This function is called at the end of walkdir_replace_dot_all.
Expand All @@ -446,10 +444,11 @@ def sort_log_messages():
# sort the list of strings
log_messages.sort()
# add index to each line
for i in range(len(log_messages)):
log_messages[i] = f'{i}. {log_messages[i]}'
for i, message in enumerate(log_messages):
log_messages[i] = f'{i}. {message}'
# join the list of strings into a single string separated by newline characters
log_messages = '\n'.join(log_messages)[2:]
print(log_messages)


# ******************************************************** EXECUTES MAIN FUNCTION ****************************************************************************************
Expand Down

0 comments on commit 29e5ddb

Please sign in to comment.