-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcntWch.py
More file actions
51 lines (47 loc) · 1.48 KB
/
Copy pathcntWch.py
File metadata and controls
51 lines (47 loc) · 1.48 KB
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 pymongo,operator
client = pymongo.MongoClient (host="da0.eecs.utk.edu")
db = client ['bitbucket']
wchs = {}
all = {}
frks = {}
prs = {}
coll = db ['pullrequests']
for r in coll .find ({}, { "url" : 1, "values":1,"_id":0 } ):
u, v = (r ["url"], r ["values"])
l = u .replace ("https://api.bitbucket.org/2.0/repositories/","").replace("/pullrequests","")
all [l] = 1
if l not in prs: prs[l] = set ()
for i in v:
a = i ["author"]
if a is not None:
u = a ["username"]
prs [l] .add (u)
coll = db ['watchers']
for r in coll .find ({}, { "url" : 1, "values":1,"_id":0 } ):
u, v = (r ["url"], r ["values"])
l = u .replace ("https://api.bitbucket.org/2.0/repositories/","").replace("/watchers","")
if l not in wchs: wchs [l] = set ()
all [l] = 1
for i in v:
wchs [l] .add (i["username"])
coll = db ['forks']
for r in coll .find ({}, { "url" : 1, "values":1,"_id":0 } ):
u, v = (r ["url"], r ["values"])
l = u .replace ("https://api.bitbucket.org/2.0/repositories/","").replace("/forks","")
all [l] = 1
if l not in frks: frks[l] = set ()
for i in v:
frks[l] .add (i["full_name"])
for l in all .keys ():
nw, nf, np = 0, 0, 0
w, f, p = '', '', ''
if l in wchs:
nw = len (wchs[l])
w = ':' .join (list(wchs[l]))
if l in frks:
nf = len (frks[l])
f = ':' .join (list(frks[l]))
if l in prs:
np = len (prs[l])
p = ':' .join (list(prs[l]))
print l + ';' + str(nw) + ';' + str (nf) + ";" + str (np) + ';' + w + ';' + f + ';' + p