mirror of https://github.com/CGAL/cgal
remove problems detected by the linter
This commit is contained in:
parent
e7ab525ead
commit
8e6670d8ea
|
|
@ -1,14 +1,14 @@
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
import collections
|
||||||
|
|
||||||
input_report_file_name=sys.argv[1]
|
CONFIG_REGEX = re.compile(
|
||||||
report_file_name=sys.argv[2]
|
r"(.*Configuring (examples|demo|test)*( in )*(test/|examples/|demo/)*)((?!done)\w+)"
|
||||||
global_report_file_name=sys.argv[3]
|
)
|
||||||
config_regex=re.compile(r'(.*Configuring (examples|demo|test)*( in )*(test/|examples/|demo/)*)((?!done)\w+)')
|
DEMO_REGEX = re.compile(r".*in demo/")
|
||||||
demo_regex=re.compile(r'.*in demo/')
|
EXAMPLES_REGEX = re.compile(r'.*in examples/')
|
||||||
examples_regex=re.compile(r'.*in examples/')
|
SEPARATOR = "------------------------------------------------------------------"
|
||||||
Separator = "------------------------------------------------------------------"
|
|
||||||
|
|
||||||
|
|
||||||
# open the Installation report
|
# open the Installation report
|
||||||
|
|
@ -17,6 +17,23 @@ Separator = "------------------------------------------------------------------"
|
||||||
# in it. Then, add 'NAME r' in the global report. This should allow to get all
|
# in it. Then, add 'NAME r' in the global report. This should allow to get all
|
||||||
# the NOTICE and other info explaining why the configuration is skipped.
|
# the NOTICE and other info explaining why the configuration is skipped.
|
||||||
|
|
||||||
|
def find_third_separator(contents):
|
||||||
|
separator_count = 0
|
||||||
|
for j, line in enumerate(contents):
|
||||||
|
if line.strip() == SEPARATOR:
|
||||||
|
separator_count += 1
|
||||||
|
if separator_count == 3:
|
||||||
|
return j
|
||||||
|
return len(contents) + 2
|
||||||
|
|
||||||
|
def last(iterator):
|
||||||
|
return collections.deque(iterator, maxlen=1).pop()
|
||||||
|
|
||||||
|
def find_last_separator(contents):
|
||||||
|
position, _ = last(filter(lambda x: x[1].strip() == SEPARATOR, enumerate(contents)))
|
||||||
|
return position
|
||||||
|
|
||||||
|
def process_report(input_report_file_name, report_file_name, global_report_file_name):
|
||||||
name = ""
|
name = ""
|
||||||
is_writing = False
|
is_writing = False
|
||||||
is_ignored = False
|
is_ignored = False
|
||||||
|
|
@ -24,42 +41,31 @@ position = 0
|
||||||
lines_to_write = []
|
lines_to_write = []
|
||||||
installation_cmake_logs = []
|
installation_cmake_logs = []
|
||||||
|
|
||||||
|
file_path = f"Installation/{report_file_name}"
|
||||||
|
print(f"Debug: Opening file {file_path}")
|
||||||
def find_third_separator(inner_contents):
|
with open(file_path, "r", encoding="utf-8") as file:
|
||||||
separator_count = 0
|
|
||||||
for j, inner_line in enumerate(inner_contents):
|
|
||||||
if inner_line.strip() == Separator:
|
|
||||||
separator_count += 1
|
|
||||||
if separator_count == 3:
|
|
||||||
return j
|
|
||||||
return len(inner_contents) + 2
|
|
||||||
|
|
||||||
def find_last_separator(inner_contents):
|
|
||||||
for j, inner_line in enumerate(inner_contents):
|
|
||||||
if inner_line.strip() == Separator:
|
|
||||||
inner_position = j
|
|
||||||
return inner_position
|
|
||||||
|
|
||||||
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)
|
||||||
|
print(f"Debug: Position is {position}")
|
||||||
|
print(f"Debug: Length of contents is {len(contents)}")
|
||||||
for i, line in enumerate(contents):
|
for i, line in enumerate(contents):
|
||||||
if i > position:
|
if i > position:
|
||||||
installation_cmake_logs.append(line)
|
|
||||||
if line.strip() == "== Generating build files for tests ==":
|
if line.strip() == "== Generating build files for tests ==":
|
||||||
|
print(f"Debug: Found the line {line} at position {i}")
|
||||||
break
|
break
|
||||||
|
installation_cmake_logs.append(line)
|
||||||
contents = []
|
contents = []
|
||||||
|
print(f"Debug: Length of installation CMake logs is {len(installation_cmake_logs)}")
|
||||||
|
print(f"Debug: Installation CMake logs are {"".join(installation_cmake_logs)}")
|
||||||
global_report = open(global_report_file_name, "a+", encoding="utf-8")
|
global_report = open(global_report_file_name, "a+", encoding="utf-8")
|
||||||
with open(input_report_file_name, "rt", encoding="utf-8") as input_report_file:
|
with open(input_report_file_name, "rt", encoding="utf-8") as input_report_file:
|
||||||
for myline in input_report_file:
|
for line in input_report_file:
|
||||||
match = config_regex.match(myline)
|
match = CONFIG_REGEX.match(line)
|
||||||
if is_writing:
|
if is_writing:
|
||||||
if match:
|
if match:
|
||||||
is_writing = False
|
is_writing = False
|
||||||
if is_ignored:
|
if is_ignored:
|
||||||
print("{label} {result}".format(label=name, result='r'), file=global_report)
|
print(f"{name} r", file=global_report)
|
||||||
is_ignored = False
|
is_ignored = False
|
||||||
if lines_to_write:
|
if lines_to_write:
|
||||||
file_path = f"{name}/{report_file_name}"
|
file_path = f"{name}/{report_file_name}"
|
||||||
|
|
@ -71,8 +77,14 @@ with open(input_report_file_name, "rt", encoding="utf-8") as input_report_file:
|
||||||
|
|
||||||
position = find_third_separator(contents)
|
position = find_third_separator(contents)
|
||||||
|
|
||||||
if not any(re.search("- CMake Results .*", content) for content in contents):
|
if not any(
|
||||||
lines_to_write.insert(0, f"{Separator}\n- CMake Results for {name}\n{Separator}\n\n")
|
re.search("- CMake Results .*", content)
|
||||||
|
for content in contents
|
||||||
|
):
|
||||||
|
lines_to_write.insert(
|
||||||
|
0,
|
||||||
|
f"{SEPARATOR}\n- CMake Results for {name}\n{SEPARATOR}\n\n",
|
||||||
|
)
|
||||||
lines_to_write.insert(0, "\n")
|
lines_to_write.insert(0, "\n")
|
||||||
contents[position:position] = lines_to_write
|
contents[position:position] = lines_to_write
|
||||||
|
|
||||||
|
|
@ -83,15 +95,16 @@ with open(input_report_file_name, "rt", encoding="utf-8") as input_report_file:
|
||||||
if is_ignored:
|
if is_ignored:
|
||||||
is_ignored = False
|
is_ignored = False
|
||||||
else:
|
else:
|
||||||
if myline.strip() != "":
|
if line.strip() != "":
|
||||||
lines_to_write.append(myline)
|
lines_to_write.append(line)
|
||||||
if not is_writing:
|
if not is_writing:
|
||||||
if match:
|
if match:
|
||||||
name = match.group(0).replace(match.group(1), "")
|
name = match.group(0).replace(match.group(1), "")
|
||||||
if demo_regex.match(myline):
|
print(f"Debug: Found name {name}")
|
||||||
name="{str}_Demo".format(str=name)
|
if DEMO_REGEX.match(line):
|
||||||
elif examples_regex.match(myline):
|
name = f"{name}_Demo"
|
||||||
name="{str}_Examples".format(str=name)
|
elif EXAMPLES_REGEX.match(line):
|
||||||
|
name = f"{name}_Examples"
|
||||||
elif name == "libCGAL":
|
elif name == "libCGAL":
|
||||||
name = "libCGAL_shared"
|
name = "libCGAL_shared"
|
||||||
elif name == "libCGAL_Core":
|
elif name == "libCGAL_Core":
|
||||||
|
|
@ -108,14 +121,20 @@ with open(input_report_file_name, "rt", encoding="utf-8") as input_report_file:
|
||||||
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("{}/../../../../../.scm-branch".format(os.getcwd()), 'r', encoding="utf-8") as scm_branch_file:
|
with open(
|
||||||
|
f"{os.getcwd()}/../../../../../.scm-branch",
|
||||||
|
"r",
|
||||||
|
encoding="utf-8",
|
||||||
|
) as scm_branch_file:
|
||||||
scm_branch_content = scm_branch_file.read()
|
scm_branch_content = scm_branch_file.read()
|
||||||
|
|
||||||
with open("{dir}/{file}".format(dir=name, file=report_file_name), "w+", encoding="utf-8") as report_file_handle:
|
with open(
|
||||||
|
f"{name}/{report_file_name}", "w+", encoding="utf-8"
|
||||||
|
) as report_file_handle:
|
||||||
report_file_handle.write(scm_branch_content)
|
report_file_handle.write(scm_branch_content)
|
||||||
else:
|
else:
|
||||||
is_ignored = False
|
is_ignored = False
|
||||||
file_path = "{dir}/{file}".format(dir=name, file=report_file_name)
|
file_path = f"{name}/{report_file_name}"
|
||||||
if os.path.exists(file_path):
|
if os.path.exists(file_path):
|
||||||
with open(file_path, "r", encoding="utf-8") as file:
|
with open(file_path, "r", encoding="utf-8") as file:
|
||||||
contents = file.readlines()
|
contents = file.readlines()
|
||||||
|
|
@ -124,8 +143,17 @@ with open(input_report_file_name, "rt", encoding="utf-8") as input_report_file:
|
||||||
|
|
||||||
position = find_third_separator(contents)
|
position = find_third_separator(contents)
|
||||||
|
|
||||||
if not any(re.search("- CMake Logs .*", content) for content in contents):
|
if not any(
|
||||||
contents.insert(position - 1, Separator + "\n- CMake Logs from Installation \n" + Separator + "\n\n")
|
re.search("- CMake Logs .*", content)
|
||||||
|
for content in contents
|
||||||
|
):
|
||||||
|
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
|
||||||
|
|
@ -138,6 +166,15 @@ with open(input_report_file_name, "rt", encoding="utf-8") as input_report_file:
|
||||||
if is_writing:
|
if is_writing:
|
||||||
is_writing = False
|
is_writing = False
|
||||||
if is_ignored:
|
if is_ignored:
|
||||||
print("{label} {result}".format(label=name, result='r'), file=global_report)
|
print(f"{name} r", file=global_report)
|
||||||
is_ignored = False
|
is_ignored = False
|
||||||
global_report.close()
|
global_report.close()
|
||||||
|
|
||||||
|
def main():
|
||||||
|
input_report_file_name = sys.argv[1]
|
||||||
|
report_file_name = sys.argv[2]
|
||||||
|
global_report_file_name = sys.argv[3]
|
||||||
|
process_report(input_report_file_name, report_file_name, global_report_file_name)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue