-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCheckStats-RepoLang-Script.py
More file actions
34 lines (27 loc) · 1.1 KB
/
CheckStats-RepoLang-Script.py
File metadata and controls
34 lines (27 loc) · 1.1 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
import requests
username = "SamXop123"
# 1. Get all your public repos
repos_url = f"https://api.github.com/users/{username}/repos"
repos = requests.get(repos_url).json()
language_totals = {} # { "HTML": { "repo": "X", "bytes": 5000 }, ... }
for repo in repos:
repo_name = repo["name"]
lang_url = f"https://api.github.com/repos/{username}/{repo_name}/languages"
langs = requests.get(lang_url).json()
for lang, bytes_count in langs.items():
# if language not seen before, add it
if lang not in language_totals:
language_totals[lang] = {
"repo": repo_name,
"bytes": bytes_count
}
else:
# check if current repo has more of this language
if bytes_count > language_totals[lang]["bytes"]:
language_totals[lang] = {
"repo": repo_name,
"bytes": bytes_count
}
print("\n📌 Repository with Highest Amount for Each Language\n")
for lang, data in language_totals.items():
print(f"{lang}: {data['repo']} ({data['bytes']} bytes)")