github-conn 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: github_conn
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Un pacchetto semplice per connettersi alle API di GitHub
|
|
5
|
+
Project-URL: Homepage, https://github.com/Dal-Canto/github_conn
|
|
6
|
+
Author-email: Alessandro <gargoalexdc@gmail.com>
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Requires-Python: >=3.8
|
|
11
|
+
Requires-Dist: requests>=2.28.0
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# github_conn
|
|
15
|
+
|
|
16
|
+
Un pacchetto Python per connettersi all'API di GitHub, sviluppato da Alessandro.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "github_conn"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name="Alessandro", email="gargoalexdc@gmail.com" },
|
|
10
|
+
]
|
|
11
|
+
description = "Un pacchetto semplice per connettersi alle API di GitHub"
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.8"
|
|
14
|
+
dependencies = [
|
|
15
|
+
"requests>=2.28.0",
|
|
16
|
+
]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Operating System :: OS Independent",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
Homepage = "https://github.com/Dal-Canto/github_conn"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .client import GitHubClient
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
|
|
3
|
+
class GitHubClient:
|
|
4
|
+
def __init__(self, token=None):
|
|
5
|
+
self.base_url = "https://api.github.com"
|
|
6
|
+
self.headers = {
|
|
7
|
+
"Accept": "application/vnd.github+json",
|
|
8
|
+
"X-GitHub-Api-Version": "2022-11-28"
|
|
9
|
+
}
|
|
10
|
+
if token:
|
|
11
|
+
self.headers["Authorization"] = f"Bearer {token}"
|
|
12
|
+
|
|
13
|
+
def get_user(self, username):
|
|
14
|
+
url = f"{self.base_url}/users/{username}"
|
|
15
|
+
response = requests.get(url, headers=self.headers)
|
|
16
|
+
if response.status_code == 200:
|
|
17
|
+
return response.json()
|
|
18
|
+
response.raise_for_status()
|
|
19
|
+
|
|
20
|
+
def get_repos(self, username):
|
|
21
|
+
url = f"{self.base_url}/users/{username}/repos"
|
|
22
|
+
response = requests.get(url, headers=self.headers)
|
|
23
|
+
if response.status_code == 200:
|
|
24
|
+
return response.json()
|
|
25
|
+
response.raise_for_status()
|