Commit 70d60e32 authored by sparonuz's avatar sparonuz
Browse files

[Issue#142]: Small refactoring, and changed a name

parent 39e1d0ed
......@@ -41,7 +41,7 @@ class ReadSourceFile:
def rebuild_text(self):
self.text = "".join([l + "\n" for l in self.lines[:] if l.strip()])
def save_modified_file(self, file_path=None):
def save_file(self, file_path=None):
if file_path:
path = file_path + "/" + self.filename
else:
......
......@@ -20,14 +20,14 @@ def Implement_RPE(path_to_input_sources, path_to_output_sources, blacklist=[]):
# Fix the problem the changes implied
implementer.fix_sources()
# "use rpe_emulator" statement is inserted
Inserter.insert_use_rpe_statement(implementer.vault)
# Insert precision specification into sources
Inserter.add_sbits_to_rpe_variables(implementer.vault)
# Add the read_precisions module into a file (should be accessible for all the other modules)
Inserter.insert_read_precisions_module_to_file_and_save(path_to_output_sources, implementer.vault)
# Add the read_precisions and rpe_emulator use statement into all files (should be accessible for all modules)
Inserter.insert_use_statement(implementer.vault)
# Save module txt files to folder
implementer.save_files()
# Create the read_precisions.f90 module
Inserter.create_read_precisions_module(path_to_output_sources, implementer.vault)
......@@ -45,6 +45,10 @@ class ImplementRPE:
# Parse the sources and obtain all info
self.vault = Vault(path_to_output_sources)
def save_files(self):
for module in self.vault.modules:
module.save_file(self.output_path)
def replace_real_with_RPE_declaration(self):
n_of_file = len(self.file_list)
for index, source_file in enumerate(self.file_list):
......@@ -72,7 +76,7 @@ class ImplementRPE:
source_file.lines[_index] = line
source_file.rebuild_text()
source_file.save_modified_file(self.output_path)
source_file.save_file(self.output_path)
def fix_sources(self):
n_of_modules = len(self.vault.modules)
......
......@@ -11,7 +11,7 @@ def pre_process_sources(path_to_input_sources, path_to_output_sources):
for index, file in enumerate(all_sources):
print("\rFormatting file %i/%i %20s" % (index + 1, n_of_file, file.filename), end="")
pre_process(file)
file.save_modified_file(path_to_output_sources)
file.save_file(path_to_output_sources)
def pre_process(file):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment