Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mossutils
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dinfk-lecturers
mossutils
Commits
e75780eb
Commit
e75780eb
authored
May 07, 2020
by
scmalte
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cluster.py: generate individual cluster files in a subdirectory
parent
eae96d93
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
4 deletions
+15
-4
mossutils/cluster.py
mossutils/cluster.py
+15
-4
No files found.
mossutils/cluster.py
View file @
e75780eb
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_CLUSTER
S_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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment