-
Notifications
You must be signed in to change notification settings - Fork 0
/
issue_manager.py
51 lines (44 loc) · 1.48 KB
/
issue_manager.py
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
40
41
42
43
44
45
46
47
48
49
50
51
import shutil
import cleaner
import os
import re
def run(github_access):
fic = github_access.get_organization("FAIRiCUBE")
files = 0
for repo in fic.get_repos():
if repo.name == 'data-requests':
continue
path = 'repos/' + repo.name + '/issues/'
if not os.path.exists(path):
os.makedirs(path)
issues = repo.get_issues(state="all")
# print('\n')
# print('--------------------------------------')
# print(repo.name)
# print('--------------------------------------')
for issue in issues:
if not isinstance(issue.body, str):
continue
s = issue.title + '\n'
s = s + issue.body + '\n'
comments = issue.get_comments()
for comment in comments:
s = s + comment.body
s = s + '\n'
if s == '':
continue
special_chars = r'[^A-Za-z0-9]'
title = issue.title
title = re.sub(special_chars, '', title)
title = title.strip().replace(' ', '')
s = cleaner.preprocess_text(s)
f = open(path+title+'.md', 'w', encoding="utf-8")
f.write(s)
f.close()
files += 1
# print('\n')
if len(os.listdir(path)) == 0:
shutil.rmtree(path)
# To close connections after use
# github_access.close()
return files