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

cluster.py 909 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import re
# import argparse
import logging
import csv
from dataclasses import dataclass

DEFAULT_RESULTS_CSV_FILE="moss-report.csv"

@dataclass
class MossMatch:
  legi1: str
  percentage1: int
  legi2: str
  percentage2: int
  avg_percentage: int,
  lines: int

def main(results_csv_file=DEFAULT_RESULTS_CSV_FILE):
  candidate_percentage_pattern = r"([\d-]+) \((\d+)%\)"

  with open(results_csv_file, newline="") as csv_fh:
    csv_reader = csv.DictReader(csv_fh, delimiter=",", quotechar='"')
    for row in csv_reader:
      match1 = re.search(candidate_percentage_pattern, row["File 1"])
      match2 = re.search(candidate_percentage_pattern, row["File 2"])

      moss_match = MossMatch(
        match1.group(1),
        match1.group(2),
        match2.group(1),
        match2.group(2),
        row["Avg. %"],
        row["Lines Matched"])

      print(moss_match)


if __name__ == "__main__":
  main()