dynamic
This commit is contained in:
parent
e7ccdf212f
commit
b9f263cefc
@ -1,9 +1,15 @@
|
||||
import requests
|
||||
import sys
|
||||
|
||||
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:
|
||||
userrepos = userrepos.json()
|
||||
@ -13,13 +19,18 @@ else:
|
||||
result = []
|
||||
|
||||
for item in userrepos:
|
||||
|
||||
languages_url = item.get('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:
|
||||
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)
|
||||
else:
|
||||
print(f'Request failed with status code {userrepos.status_code}')
|
||||
@ -35,8 +46,11 @@ for item in result:
|
||||
else:
|
||||
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)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user