dynamic
This commit is contained in:
parent
e7ccdf212f
commit
b9f263cefc
@ -1,9 +1,15 @@
|
|||||||
import requests
|
import requests
|
||||||
|
import sys
|
||||||
|
|
||||||
apiLocation = "https://git.tijl.dev/api/v1"
|
apiLocation = "https://git.tijl.dev/api/v1"
|
||||||
secret = "token_here"
|
secret = sys.argv[1]
|
||||||
|
|
||||||
userrepos = requests.get(apiLocation+'/user/repos', headers={'Authorization': 'token '+secret})
|
userrepos = requests.get(
|
||||||
|
apiLocation+'/user/repos',
|
||||||
|
headers={
|
||||||
|
'Authorization': 'token '+secret
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
if userrepos.status_code == 200:
|
if userrepos.status_code == 200:
|
||||||
userrepos = userrepos.json()
|
userrepos = userrepos.json()
|
||||||
@ -13,13 +19,18 @@ else:
|
|||||||
result = []
|
result = []
|
||||||
|
|
||||||
for item in userrepos:
|
for item in userrepos:
|
||||||
|
|
||||||
languages_url = item.get('languages_url')
|
languages_url = item.get('languages_url')
|
||||||
if languages_url:
|
if languages_url:
|
||||||
language_response = requests.get(languages_url, headers={'Authorization': 'token '+secret})
|
language_response = requests.get(
|
||||||
|
languages_url,
|
||||||
|
headers={'Authorization': 'token '+secret}
|
||||||
|
)
|
||||||
if language_response.status_code == 200:
|
if language_response.status_code == 200:
|
||||||
language_data = language_response.json()
|
language_data = language_response.json()
|
||||||
newdata = {'full_name': item.get('full_name'), 'language_data': language_data}
|
newdata = {
|
||||||
|
'full_name': item.get('full_name'),
|
||||||
|
'language_data': language_data
|
||||||
|
}
|
||||||
result.append(newdata)
|
result.append(newdata)
|
||||||
else:
|
else:
|
||||||
print(f'Request failed with status code {userrepos.status_code}')
|
print(f'Request failed with status code {userrepos.status_code}')
|
||||||
@ -35,8 +46,11 @@ for item in result:
|
|||||||
else:
|
else:
|
||||||
language_counts[language] = {'score': count}
|
language_counts[language] = {'score': count}
|
||||||
|
|
||||||
sorted_data = dict(sorted(language_counts.items(), key=lambda x: x[1]['score'], reverse=True))
|
sorted_data = dict(
|
||||||
|
sorted(
|
||||||
|
language_counts.items(),
|
||||||
|
key=lambda x: x[1]['score'],
|
||||||
|
reverse=True)
|
||||||
|
)
|
||||||
|
|
||||||
print(sorted_data)
|
print(sorted_data)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user