Skip to content

Commit

Permalink
Updated to print out the changes in the terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
ym1906 committed Nov 14, 2024
1 parent 7675db1 commit feaf3ac
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions process/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ def validate_input(self, replace_obsolete=False):
filename = self.input_file
variables_in_in_dat = []
modified_lines = []
changes_made = [] # To store details of the changes

with open(filename, "r") as file:
for line in file:
Expand All @@ -570,12 +571,18 @@ def validate_input(self, replace_obsolete=False):
if replacement is None:
# If no replacement is defined, comment out the line
modified_lines.append(f"* Obsolete: {line}")
changes_made.append(
f"Commented out obsolete variable: {variable_name}"
)
else:
# Replace obsolete variable with updated variable
modified_line = line.replace(variable_name, replacement, 1)
modified_lines.append(
f"* Replaced '{variable_name}' with '{replacement}'\n{modified_line}"
)
changes_made.append(
f"Replaced '{variable_name}' with '{replacement}'"
)
else:
# If replacement is False, add the line as-is
modified_lines.append(line)
Expand All @@ -593,6 +600,9 @@ def validate_input(self, replace_obsolete=False):
print(
"The IN.DAT file has been updated to replace or comment out obsolete variables."
)
print("Summary of changes made:")
for change in changes_made:
print(f" - {change}")
else:
# Only print the report if replace_obsolete is False
message = (
Expand Down

0 comments on commit feaf3ac

Please sign in to comment.