generated from caltechlibrary/template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_queue.py
35 lines (27 loc) · 1014 Bytes
/
get_queue.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
import os,re,csv
from ames.harvesters import get_pending_requests
from ames.harvesters import get_request_comments
from ames.harvesters import get_request_id_title
from ames.harvesters import get_publisher
token = os.environ["CTATOK"]
community = "aedd135f-227e-4fdf-9476-5b3fd011bac6"
completed = []
pending = get_pending_requests(token, community)
for p in pending:
rdm_id,title,updated = get_request_id_title(token, p)
publisher = get_publisher(token, rdm_id)
comments = get_request_comments(token, p)
tags = []
for c in comments:
if '@' in c:
tags = re.findall(r'(?<!\w)@(\w+)', c)
if tags == []:
tags.append('new')
for tag in tags:
completed.append([tag,updated,title,publisher,rdm_id, p])
with open("queue.csv", "w") as f:
writer = csv.writer(f)
writer.writerow(['tag','updated','title','publisher','rdm_id','request'])
print(f'Writing {len(completed)} rows to queue.csv')
for c in completed:
writer.writerow(c)