Last active
August 29, 2015 14:08
-
-
Save Fale/7b6dd95f36a12cd3397d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.request | |
import json | |
import operator | |
from pprint import pprint | |
def urlToJSON (url): | |
response = urllib.request.urlopen(url) | |
string = response.readall().decode('utf-8') | |
return json.loads(string) | |
class Pkgdb: | |
def __init__(self): | |
self.data = [] | |
def getPackageList(self, pattern): | |
packages = urlToJSON('https://admin.fedoraproject.org/pkgdb/api/packages/' + pattern + '/')['packages'] | |
pkgs = [] | |
for package in packages: | |
pkgs.append(package['name']) | |
return pkgs | |
class PkgdbPkg: | |
def __init__(self, name): | |
self.data = urlToJSON('https://admin.fedoraproject.org/pkgdb/api/package/' + name)['packages'] | |
def getApprovedUsers(self): | |
users = [] | |
for package in self.data: | |
for acl in package['acls']: | |
if acl['status'] == 'Approved': | |
users.append(acl['fas_name']) | |
return users | |
pkgdb = Pkgdb() | |
packages = pkgdb.getPackageList('golang-*') | |
goUsers = {} | |
for p in packages: | |
package = PkgdbPkg(p) | |
print(p) | |
users = package.getApprovedUsers() | |
for user in users: | |
try: | |
t = goUsers[user] | |
goUsers[user] = t + 1; | |
except: | |
goUsers[user] = 1 | |
pprint(sorted(goUsers.items(), key=operator.itemgetter(1))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment