(csv_path: str)
| 124 | |
| 125 | |
| 126 | def categorize_csv_file(csv_path: str): |
| 127 | headings = defaultdict(lambda: defaultdict(list)) |
| 128 | sprint("Opening CSV") |
| 129 | with open(csv_path) as f: |
| 130 | input_file = csv.DictReader(f) |
| 131 | |
| 132 | i = 0 |
| 133 | blank_cate_set = {"Misc"} |
| 134 | for row in input_file: |
| 135 | # print(row) |
| 136 | tags = row["pr_title_tags"].split("/") |
| 137 | tags = ["misc"] if len(tags) == 0 else tags |
| 138 | |
| 139 | categories = map(lambda t: TAG_DICT.get(t.lower(), "Misc"), tags) |
| 140 | categories = list(categories) |
| 141 | categories = list(set(categories) - blank_cate_set) |
| 142 | category = "Misc" if len(categories) == 0 else categories[0] |
| 143 | |
| 144 | subject = row["subject"].strip() |
| 145 | pr_number = row["url"].split("/")[-1] |
| 146 | |
| 147 | if category == "" or subject == "": |
| 148 | sprint(f"Skipping {i}th pr with number: {pr_number}, row: {row}") |
| 149 | continue |
| 150 | |
| 151 | headings[category][subject].append(pr_number) |
| 152 | i += 1 |
| 153 | # if i > 30: |
| 154 | # break |
| 155 | return headings |
| 156 | |
| 157 | |
| 158 | if __name__ == "__main__": |
no test coverage detected
searching dependent graphs…