-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch_languages.py
30 lines (23 loc) · 1.03 KB
/
fetch_languages.py
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
import requests
def fetch_languages(repo_url):
# Replace {owner} and {repo} with the repository's owner and name
api_url = f"https://api.github.com/repos/{repo_url}/languages"
# Fetching the language data using GitHub API
response = requests.get(api_url)
if response.status_code != 200:
print(f"Failed to get data: {response.status_code}")
return None
language_data = response.json()
# Converting bytes to megabytes
for lang, bytes_count in language_data.items():
language_data[lang] = bytes_count / (1024 * 1024)
return language_data
# Replace 'lsst-it/lsst-control' with the target repository
language_data = fetch_languages("lsst-it/lsst-control")
if language_data:
total_megabytes = sum(language_data.values())
total_gigabytes = total_megabytes / 1024
print("Decoded Conversations:")
for lang, megabytes in language_data.items():
print(f"{lang} with {megabytes:.2f} megabytes of code.")
print(f"Total gigabytes of code: {total_gigabytes:.2f}")