To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit e75780eb authored by scmalte's avatar scmalte
Browse files

cluster.py: generate individual cluster files in a subdirectory

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