Commit e75780eb authored by scmalte's avatar scmalte

cluster.py: generate individual cluster files in a subdirectory

parent eae96d93
import re import re
import os
# import argparse # import argparse
import logging import logging
import csv import csv
...@@ -21,7 +22,7 @@ from .utils import logging as logutils ...@@ -21,7 +22,7 @@ from .utils import logging as logutils
DEFAULT_RESULTS_CSV_FILE="moss-report.csv" DEFAULT_RESULTS_CSV_FILE="moss-report.csv"
DEFAULT_TOTAL_GRAPH_DOT_FILE="moss-report.dot" DEFAULT_TOTAL_GRAPH_DOT_FILE="moss-report.dot"
DEFAULT_CLUSTERS_DOT_FILE="clusters.dot" DEFAULT_CLUSTER_FILES_DIR="_clusters"
DEFAULT_CLUSTER_FILE_PATTERN="cluster-{}.{}" DEFAULT_CLUSTER_FILE_PATTERN="cluster-{}.{}"
DEFAULT_THRESHOLD_PERCENTAGE=90 DEFAULT_THRESHOLD_PERCENTAGE=90
DEFAULT_THRESHOLD_LINES=50 DEFAULT_THRESHOLD_LINES=50
...@@ -109,13 +110,16 @@ def get_results_graph(results, percentage_threshold, lines_threshold): ...@@ -109,13 +110,16 @@ def get_results_graph(results, percentage_threshold, lines_threshold):
edge = (result.id1, result.id2, weight) edge = (result.id1, result.id2, weight)
color = get_color(weight) color = get_color(weight)
# TODO: Don't hardcode ../ path prefix
match_url = "../{}".format(result.match_file)
attributes = { attributes = {
# Attributes for GraphViz # Attributes for GraphViz
"color": color, "color": color,
"penwidth": 2, "penwidth": 2,
"label": "{0}% ({1})".format(weight, result.lines), "label": "{0}% ({1})".format(weight, result.lines),
"labelURL": result.match_file, "labelURL": match_url,
"URL": result.match_file, "URL": match_url,
"target": "match", "target": "match",
"fontcolor": color, "fontcolor": color,
# Attributes for internal bookkeeping # Attributes for internal bookkeeping
...@@ -195,6 +199,7 @@ def create_summary_csv_file(cluster_entries, summary_csv_file): ...@@ -195,6 +199,7 @@ def create_summary_csv_file(cluster_entries, summary_csv_file):
def main( def main(
results_csv_file=DEFAULT_RESULTS_CSV_FILE, results_csv_file=DEFAULT_RESULTS_CSV_FILE,
total_graph_dot_file=DEFAULT_TOTAL_GRAPH_DOT_FILE, total_graph_dot_file=DEFAULT_TOTAL_GRAPH_DOT_FILE,
cluster_files_dir=DEFAULT_CLUSTER_FILES_DIR,
cluster_file_pattern=DEFAULT_CLUSTER_FILE_PATTERN, cluster_file_pattern=DEFAULT_CLUSTER_FILE_PATTERN,
percentage_threshold=DEFAULT_THRESHOLD_PERCENTAGE, percentage_threshold=DEFAULT_THRESHOLD_PERCENTAGE,
lines_threshold=DEFAULT_THRESHOLD_LINES, lines_threshold=DEFAULT_THRESHOLD_LINES,
...@@ -209,7 +214,13 @@ def main( ...@@ -209,7 +214,13 @@ def main(
logging.info("Writing total graph to {}".format(total_graph_dot_file)) logging.info("Writing total graph to {}".format(total_graph_dot_file))
nx.drawing.nx_pydot.write_dot(graph, total_graph_dot_file) nx.drawing.nx_pydot.write_dot(graph, total_graph_dot_file)
cluster_entries = create_clusters(graph, cluster_file_pattern, create_svg_files) logging.info("Creating directory {}".format(cluster_files_dir))
os.makedirs(cluster_files_dir, exist_ok=True)
cluster_entries = create_clusters(
graph,
os.path.join(cluster_files_dir, cluster_file_pattern),
create_svg_files)
create_summary_csv_file(cluster_entries, summary_csv_file) create_summary_csv_file(cluster_entries, summary_csv_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