Spaces:
Running
Running
Create src/github_analysis.py
Browse files- src/github_analysis.py +21 -0
src/github_analysis.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
|
3 |
+
def analyze_github_repo(owner, repo):
|
4 |
+
try:
|
5 |
+
response = requests.get(f"https://api.github.com/repos/{owner}/{repo}")
|
6 |
+
if response.status_code == 200:
|
7 |
+
data = response.json()
|
8 |
+
repo_data = {
|
9 |
+
"Name": data['name'],
|
10 |
+
"Owner": data['owner']['login'],
|
11 |
+
"Stars": data['stargazers_count'],
|
12 |
+
"Forks": data['forks_count'],
|
13 |
+
"Language": data['language'],
|
14 |
+
"Description": data['description'],
|
15 |
+
}
|
16 |
+
return repo_data
|
17 |
+
else:
|
18 |
+
return None
|
19 |
+
except Exception as e:
|
20 |
+
print(f"Error: {e}")
|
21 |
+
return None
|