This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
62 lines (54 loc) · 1.82 KB
/
run.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
52
53
54
55
56
57
58
59
60
61
62
import sys
from PyInquirer import prompt
from github_connection import GithubConnection
from message import ERROR_LOGIN
from message import ERROR_CONNECTION
from message import INFO_COMPLETE
from message import INFO_EXIT
from message import INFO_ALREADY_REPO
from store import REPOSITORIES, EXPORT_PATH
from utils import export_csv
from question import repository
from question import export_path
from question import continue_work
from question import build_milestone
def get_repo(repo_name):
"""
When the program starts, the list of repository issues that have been called once is saved and used.
:param repo_name:
:return:
"""
repo = REPOSITORIES.get(repo_name)
if repo:
print(INFO_ALREADY_REPO)
return repo
try:
repo = GithubConnection(name=repo_name)
except GithubConnection.LoginError:
print(ERROR_LOGIN)
sys.exit()
REPOSITORIES[repo_name] = repo
return repo
def run_crawler():
answer_repo = prompt([repository]).get('repo')
repo = get_repo(answer_repo)
question_milestone = build_milestone(repo.get_milestone_title_list())
answer_milestone = prompt(question_milestone).get('milestone')
export_list = repo.issue_list
if answer_milestone != 'all':
export_list = repo.filter_milestone(answer_milestone)
try:
export_csv(issue_list=export_list, dest_path=EXPORT_PATH, repo_name=answer_repo,
extra_name=answer_milestone)
except GithubConnection.ConnectionError:
print(ERROR_CONNECTION)
sys.exit()
if __name__ == '__main__':
EXPORT_PATH = prompt([export_path]).get('export_path')
while True:
run_crawler()
print(INFO_COMPLETE)
answer_continue = prompt([continue_work]).get('continue_work')
if not answer_continue:
break
print(INFO_EXIT)