Commit ab6a6bd9 authored by scmalte's avatar scmalte
Browse files, raise helpful exceptions in certain situations, log further output

parent a0885d1f
......@@ -123,7 +123,7 @@ def get_results_graph(results, percentage_threshold, lines_threshold):
return graph
def create_cluster_dot_and_svg_files(subgraph, index, cluster_dot_file, cluster_svg_file=None):
"Writing cluster {} with {}/{} nodes/edge to file {}".format(
......@@ -133,8 +133,12 @@ def create_cluster_dot_and_svg_files(subgraph, index, cluster_dot_file, cluster_
nx.drawing.nx_pydot.write_dot(subgraph, cluster_dot_file)
if cluster_svg_file:
dot_command = ["dot", "-Tsvg", "-o{}".format(cluster_svg_file), cluster_dot_file]
logging.debug("Calling dot to create SVG {} file from {}".format(cluster_svg_file, cluster_dot_file))["dot", "-Tsvg", "-o{}".format(cluster_svg_file), cluster_dot_file])
logging.debug("Command: {}".format(" ".join(dot_command)))
def create_clusters(graph, cluster_file_pattern, create_svg_files):"Computing connected component (CC) clusters")
......@@ -81,7 +81,8 @@ def localize_match_links(doc, input_report_subdir):
url_pattern = r"http://moss\.stanford\.edu/results/\d+/\d+/(match.*\.html)"
# E.g. ./12-345-678/main.cpp (77%)
text_pattern = r"\./([\d-]+)/.* (\(\d+%\))"
# ./some/dir/12-345-678/main.cpp (77%)
text_pattern = r".*?/([\d-]+)/.* (\(\d+%\))""Localising links to match files")
......@@ -92,14 +93,22 @@ def localize_match_links(doc, input_report_subdir):
for a in row.find_all("a"):
# Change remote URLs to local ones
url_match =, a["href"])
if not url_match:
raise RuntimeError("Failure while localising match links in the Moss report. Failed to match link '{}' against regex '{}'".format(a["href"], url_pattern))
a["href"] = "./{}/{}".format(input_report_subdir,
# Open links in a new tab/window
a["target"] = "_blank"
# Strip away unnecessary link text
# print(a.get_text().strip())
text_match =, a.get_text().strip())
link_text = a.get_text().strip()
text_match =, link_text)
if not text_match:
raise RuntimeError("Failure while localising match links in the Moss report. Failed to match link text '{}' against regex '{}'".format(link_text, text_pattern))
a.string = "{} {}".format(,
def get_match_percentage(match_text):
Supports Markdown
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