forked from lanl/Draco
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse_jayenne_pr.py
49 lines (39 loc) · 1.81 KB
/
parse_jayenne_pr.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
import requests
import json
import re
import os
#Bypass LANL proxy
os.environ['no_proxy'] = '*'
#This is the gitlab private access token (different from GitHub token)
private_token = ''
#GitLab project id as a string, Can retrieve under project name on project page
project_id = '302'
#Gitlab merged url. Need to authenticate in URL due to the limited function of the Gitlab web API.
api_url = 'https://gitlab.lanl.gov/api/v4/projects/{0}/merge_requests?state=merged&private_token={1}'.format(project_id, private_token)
result = requests.get(api_url)
print(result)
result_json = result.json()
if(private_token == '' or project_id == ''):
print("Either your private token or project id is empty.")
exit()
#Collects and prints information on the first JSON page
for entry in result_json:
if(entry['merged_at']):
#Prevents empty string error
if(entry["merged_at"] != None):
year, month, day = entry["merged_at"][:10].split('-')
year, month, day = int(year), int(month), int(day)
if (year >= 2019 and ((month >= 2 and day >= 26) or month >= 3)):
print("{0} {1} {2}".format(entry["iid"], entry["title"], entry["web_url"]))
#Collects and prints information on the rest of the JSON pages
while 'next' in result.links.keys():
result=requests.get(result.links['next']['url'])
next_result_json = result.json()
if(entry['merged_at']):
for entry in next_result_json:
#Prevents empty string error
if(entry["merged_at"] != None):
year, month, day = entry["merged_at"][:10].split('-')
year, month, day = int(year), int(month), int(day)
if (year >= 2019 and ((month >= 2 and day >= 26) or month >= 3)):
print("{0} {1} {2}".format(entry["iid"], entry["title"], entry["web_url"]))