-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_issues.py
84 lines (69 loc) · 2.29 KB
/
get_issues.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import os
import json
from time import sleep
# get issues json from gitlab
project_id = "6550869"
out_file = "issues"
token = "ryP5_rYncef4ZL93hiWF"
page = "1"
def getApi(page,issue_iid=""):
issue_path = ""
if issue_iid != "":
issue_path = "/" + issue_iid + "/notes"
params = "?per_page=100\&page="+page
cmd = 'curl --header "PRIVATE-TOKEN: '+token+'" https://gitlab.com/api/v4/projects/'+project_id+'/issues'+issue_path+params+' >> '+out_file+page+issue_iid+".json"
print("COMANDO: "+cmd)
os.system("rm "+out_file+page+issue_iid+".json")
os.system(cmd)
def readJson(page):
f = open(out_file+page+".json")
data = json.load(f)
cant = 0
for d in data:
print("--------------------------------------------------------")
id = str(d['id'])
title = str(d['title'])
description = str(d['description'])
links = str(d['_links']['notes'])
iid = str(d['iid'])
text = "<div style='background: #9AB9D9'>" + iid + " - " + title + "</div>" + "\n\n<br><br>"
md_text = "issue> " + iid + " - " + title + " \n"
getApi(page,iid)
n = open(out_file+page+iid+".json")
n_data = json.load(n)
for nd in n_data:
ndata = str(nd['body'])
if "changed" in ndata or "assigned" in ndata or "closed" in ndata:
continue
text += ndata
text += "\n<br>---------------------------------------------------------\n<br>"
md_text += (ndata + " \n")
md_text += "--------------------------------------------------------- \n \n"
cant += 1
fi = open("issue_"+iid+".html","w")
text = "<html><head></head><body>" + text + "</body></html>"
fi.write(text)
fi.close()
mdf = open("issue_"+iid+".md","w")
mdf.write(md_text)
mdf.close()
cmd = "pandoc issue_"+iid+".md -o iss/issue_"+iid+".html"
os.system(cmd)
print("Cant Issues: ",cant)
getApi("1")
getApi("2")
sleep(3)
# get info issues
readJson("1")
readJson("2")
def move_files(type):
cmd = "rm -r " + type
os.system(cmd)
cmd = "mkdir " + type
os.system(cmd)
cmd = "mv *." + type + " " + type
os.system(cmd)
move_files("pdf")
move_files("md")
move_files("html")
move_files("json")