mirror of https://github.com/CGAL/cgal
Refactor variable names and fix some warnings
This commit is contained in:
parent
bfe1f2234d
commit
0dfaf8a8ac
|
|
@ -1,9 +1,8 @@
|
||||||
import sys
|
import sys
|
||||||
import io
|
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
|
||||||
input_report_file=sys.argv[1]
|
input_report_file_name=sys.argv[1]
|
||||||
report_file_name=sys.argv[2]
|
report_file_name=sys.argv[2]
|
||||||
global_report_file_name=sys.argv[3]
|
global_report_file_name=sys.argv[3]
|
||||||
config_regex=re.compile('(.*Configuring (examples|demo|test)*( in )*(test\/|examples\/|demo\/)*)((?!done)\w+)')
|
config_regex=re.compile('(.*Configuring (examples|demo|test)*( in )*(test\/|examples\/|demo\/)*)((?!done)\w+)')
|
||||||
|
|
@ -27,22 +26,22 @@ installation_cmake_logs = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def find_third_separator(contents):
|
def find_third_separator(inner_contents):
|
||||||
separator_count = 0
|
separator_count = 0
|
||||||
for i, line in enumerate(contents):
|
for j, inner_line in enumerate(inner_contents):
|
||||||
if line.strip() == Separator:
|
if inner_line.strip() == Separator:
|
||||||
separator_count += 1
|
separator_count += 1
|
||||||
if separator_count == 3:
|
if separator_count == 3:
|
||||||
return i
|
return j
|
||||||
return len(contents) + 2
|
return len(inner_contents) + 2
|
||||||
|
|
||||||
def find_last_separator(contents):
|
def find_last_separator(inner_contents):
|
||||||
for i, line in enumerate(contents):
|
for j, inner_line in enumerate(inner_contents):
|
||||||
if line.strip() == Separator:
|
if inner_line.strip() == Separator:
|
||||||
position = i
|
inner_position = j
|
||||||
return position
|
return inner_position
|
||||||
|
|
||||||
with open ("{dir}/{file}".format(dir="Installation",file=report_file_name), "r") as file:
|
with open ("{dir}/{file}".format(dir="Installation",file=report_file_name), "r", encoding="utf-8") as file:
|
||||||
contents = file.readlines()
|
contents = file.readlines()
|
||||||
position = find_last_separator(contents)
|
position = find_last_separator(contents)
|
||||||
for i, line in enumerate(contents):
|
for i, line in enumerate(contents):
|
||||||
|
|
@ -52,9 +51,9 @@ for i, line in enumerate(contents):
|
||||||
break
|
break
|
||||||
contents = []
|
contents = []
|
||||||
|
|
||||||
global_report = open(global_report_file_name, "a+")
|
global_report = open(global_report_file_name, "a+", encoding="utf-8")
|
||||||
with open(input_report_file, "rt") as test_report:
|
with open(input_report_file_name, "rt", encoding="utf-8") as input_report_file:
|
||||||
for myline in test_report:
|
for myline in input_report_file:
|
||||||
match = config_regex.match(myline)
|
match = config_regex.match(myline)
|
||||||
if is_writing:
|
if is_writing:
|
||||||
if match:
|
if match:
|
||||||
|
|
@ -62,24 +61,24 @@ with open(input_report_file, "rt") as test_report:
|
||||||
if lines_to_write:
|
if lines_to_write:
|
||||||
file_path = "{dir}/{file}".format(dir=name, file=report_file_name)
|
file_path = "{dir}/{file}".format(dir=name, file=report_file_name)
|
||||||
if os.path.exists(file_path):
|
if os.path.exists(file_path):
|
||||||
with open(file_path, "r") as file:
|
with open(file_path, "r", encoding="utf-8") as file:
|
||||||
contents = file.readlines()
|
contents = file.readlines()
|
||||||
else:
|
else:
|
||||||
contents = []
|
contents = []
|
||||||
|
|
||||||
position = find_third_separator(contents)
|
position = find_third_separator(contents)
|
||||||
|
|
||||||
if Separator + "\n- CMake Results \n" + Separator not in lines_to_write:
|
if not any(re.search("- CMake Results .*", content) for content in contents):
|
||||||
lines_to_write.insert(0,Separator + "\n- CMake Results \n" + Separator + "\n")
|
lines_to_write.insert(0, f"{Separator}\n- CMake Results for {name}\n{Separator}\n\n")
|
||||||
if Separator + "\n- CMake Logs \n" + Separator not in contents:
|
if not any(re.search("- CMake Logs .*", content) for content in contents):
|
||||||
contents.insert(position - 1, Separator + "\n- CMake Logs \n" + Separator + "\n\n")
|
contents.insert(position - 1, Separator + "\n- CMake Logs from Installation \n" + Separator + "\n\n")
|
||||||
for log in installation_cmake_logs:
|
for log in installation_cmake_logs:
|
||||||
contents.insert(position, log)
|
contents.insert(position, log)
|
||||||
position += 1
|
position += 1
|
||||||
lines_to_write.insert(0, "\n")
|
lines_to_write.insert(0, "\n")
|
||||||
contents[position:position] = lines_to_write
|
contents[position:position] = lines_to_write
|
||||||
|
|
||||||
with open(file_path, "w") as file:
|
with open(file_path, "w", encoding="utf-8") as file:
|
||||||
file.write("".join(contents))
|
file.write("".join(contents))
|
||||||
|
|
||||||
lines_to_write = []
|
lines_to_write = []
|
||||||
|
|
@ -112,15 +111,15 @@ with open(input_report_file, "rt") as test_report:
|
||||||
if not os.path.isdir(name):
|
if not os.path.isdir(name):
|
||||||
is_ignored = True
|
is_ignored = True
|
||||||
os.mkdir(name)
|
os.mkdir(name)
|
||||||
with open("{dir}/{file}".format(dir=name, file=report_file_name), "w") as test_report:
|
with open("{dir}/{file}".format(dir=name, file=report_file_name), "w", encoding="utf-8") as input_report_file:
|
||||||
test_report.write(open("{}/../../../../../.scm-branch".format(os.getcwd()), 'r').read())
|
input_report_file.write(open("{}/../../../../../.scm-branch".format(os.getcwd()), 'r', encoding="utf-8").read())
|
||||||
else:
|
else:
|
||||||
is_ignored = False
|
is_ignored = False
|
||||||
is_writing = True
|
is_writing = True
|
||||||
|
|
||||||
if is_writing:
|
if is_writing:
|
||||||
is_writing=False
|
is_writing=False
|
||||||
test_report.close()
|
input_report_file.close()
|
||||||
if is_ignored:
|
if is_ignored:
|
||||||
print("{label} {result}".format(label=name, result='r'), file=global_report)
|
print("{label} {result}".format(label=name, result='r'), file=global_report)
|
||||||
is_ignored=False
|
is_ignored=False
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue