ghnova 0.3.0__py3-none-any.whl
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.
- ghnova/__init__.py +8 -0
- ghnova/__main__.py +8 -0
- ghnova/cli/__init__.py +1 -0
- ghnova/cli/config/__init__.py +1 -0
- ghnova/cli/config/add.py +48 -0
- ghnova/cli/config/delete.py +50 -0
- ghnova/cli/config/list.py +40 -0
- ghnova/cli/config/main.py +27 -0
- ghnova/cli/config/update.py +59 -0
- ghnova/cli/issue/__init__.py +7 -0
- ghnova/cli/issue/create.py +155 -0
- ghnova/cli/issue/get.py +119 -0
- ghnova/cli/issue/list.py +267 -0
- ghnova/cli/issue/lock.py +110 -0
- ghnova/cli/issue/main.py +31 -0
- ghnova/cli/issue/unlock.py +101 -0
- ghnova/cli/issue/update.py +164 -0
- ghnova/cli/main.py +117 -0
- ghnova/cli/repository/__init__.py +1 -0
- ghnova/cli/repository/list.py +201 -0
- ghnova/cli/repository/main.py +21 -0
- ghnova/cli/user/__init__.py +1 -0
- ghnova/cli/user/ctx_info.py +105 -0
- ghnova/cli/user/get.py +98 -0
- ghnova/cli/user/list.py +78 -0
- ghnova/cli/user/main.py +27 -0
- ghnova/cli/user/update.py +164 -0
- ghnova/cli/utils/__init__.py +7 -0
- ghnova/cli/utils/auth.py +67 -0
- ghnova/client/__init__.py +8 -0
- ghnova/client/async_github.py +121 -0
- ghnova/client/base.py +78 -0
- ghnova/client/github.py +107 -0
- ghnova/config/__init__.py +8 -0
- ghnova/config/manager.py +209 -0
- ghnova/config/model.py +58 -0
- ghnova/issue/__init__.py +8 -0
- ghnova/issue/async_issue.py +554 -0
- ghnova/issue/base.py +469 -0
- ghnova/issue/issue.py +584 -0
- ghnova/repository/__init__.py +8 -0
- ghnova/repository/async_repository.py +134 -0
- ghnova/repository/base.py +124 -0
- ghnova/repository/repository.py +134 -0
- ghnova/resource/__init__.py +8 -0
- ghnova/resource/async_resource.py +88 -0
- ghnova/resource/resource.py +88 -0
- ghnova/user/__init__.py +8 -0
- ghnova/user/async_user.py +285 -0
- ghnova/user/base.py +214 -0
- ghnova/user/user.py +285 -0
- ghnova/utils/__init__.py +16 -0
- ghnova/utils/log.py +70 -0
- ghnova/utils/response.py +67 -0
- ghnova/version.py +11 -0
- ghnova-0.3.0.dist-info/METADATA +194 -0
- ghnova-0.3.0.dist-info/RECORD +60 -0
- ghnova-0.3.0.dist-info/WHEEL +4 -0
- ghnova-0.3.0.dist-info/entry_points.txt +2 -0
- ghnova-0.3.0.dist-info/licenses/LICENSE +21 -0
ghnova/user/user.py
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"""GitHub User resource."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, cast
|
|
6
|
+
|
|
7
|
+
from requests import Response
|
|
8
|
+
|
|
9
|
+
from ghnova.resource.resource import Resource
|
|
10
|
+
from ghnova.user.base import BaseUser
|
|
11
|
+
from ghnova.utils.response import process_response_with_last_modified
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class User(BaseUser, Resource):
|
|
15
|
+
"""GitHub User resource."""
|
|
16
|
+
|
|
17
|
+
def _get_user(
|
|
18
|
+
self,
|
|
19
|
+
username: str | None = None,
|
|
20
|
+
account_id: int | None = None,
|
|
21
|
+
etag: str | None = None,
|
|
22
|
+
last_modified: str | None = None,
|
|
23
|
+
**kwargs: Any,
|
|
24
|
+
) -> Response:
|
|
25
|
+
"""Get user information.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
username: The username of the user to retrieve. If None, retrieves the authenticated user.
|
|
29
|
+
account_id: The account ID of the user to retrieve. If None, retrieves by username.
|
|
30
|
+
etag: The ETag value for conditional requests.
|
|
31
|
+
last_modified: The Last-Modified timestamp for conditional requests.
|
|
32
|
+
**kwargs: Additional arguments for the request.
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
The response object.
|
|
36
|
+
|
|
37
|
+
"""
|
|
38
|
+
endpoint, kwargs = self._get_user_helper(username=username, account_id=account_id, **kwargs)
|
|
39
|
+
return self._get(endpoint=endpoint, etag=etag, last_modified=last_modified, **kwargs)
|
|
40
|
+
|
|
41
|
+
def get_user(
|
|
42
|
+
self,
|
|
43
|
+
username: str | None = None,
|
|
44
|
+
account_id: int | None = None,
|
|
45
|
+
etag: str | None = None,
|
|
46
|
+
last_modified: str | None = None,
|
|
47
|
+
**kwargs: Any,
|
|
48
|
+
) -> tuple[dict[str, Any], int, str | None, str | None]:
|
|
49
|
+
"""Get user information.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
username: The username of the user to retrieve. If None, retrieves the authenticated user.
|
|
53
|
+
account_id: The account ID of the user to retrieve. If None, retrieves by username.
|
|
54
|
+
etag: The ETag value for conditional requests.
|
|
55
|
+
last_modified: The Last-Modified timestamp for conditional requests.
|
|
56
|
+
**kwargs: Additional arguments for the request.
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
A tuple containing:
|
|
60
|
+
|
|
61
|
+
- A dictionary with user information (empty if 304 Not Modified).
|
|
62
|
+
- The HTTP status code.
|
|
63
|
+
- The ETag value from the response headers (if present).
|
|
64
|
+
- The Last-Modified timestamp from the response headers (if present).
|
|
65
|
+
|
|
66
|
+
"""
|
|
67
|
+
response = self._get_user(
|
|
68
|
+
username=username, account_id=account_id, etag=etag, last_modified=last_modified, **kwargs
|
|
69
|
+
)
|
|
70
|
+
data, status_code, etag_value, last_modified_value = process_response_with_last_modified(response)
|
|
71
|
+
data = cast(dict[str, Any], data)
|
|
72
|
+
return data, status_code, etag_value, last_modified_value
|
|
73
|
+
|
|
74
|
+
def _update_user( # noqa: PLR0913
|
|
75
|
+
self,
|
|
76
|
+
name: str | None = None,
|
|
77
|
+
email: str | None = None,
|
|
78
|
+
blog: str | None = None,
|
|
79
|
+
twitter_username: str | None = None,
|
|
80
|
+
company: str | None = None,
|
|
81
|
+
location: str | None = None,
|
|
82
|
+
hireable: bool | None = None,
|
|
83
|
+
bio: str | None = None,
|
|
84
|
+
etag: str | None = None,
|
|
85
|
+
last_modified: str | None = None,
|
|
86
|
+
**kwargs: Any,
|
|
87
|
+
) -> Response:
|
|
88
|
+
"""Update the authenticated user's information.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
name: The name of the user.
|
|
92
|
+
email: The email of the user.
|
|
93
|
+
blog: The blog URL of the user.
|
|
94
|
+
twitter_username: The Twitter username of the user.
|
|
95
|
+
company: The company of the user.
|
|
96
|
+
location: The location of the user.
|
|
97
|
+
hireable: The hireable status of the user.
|
|
98
|
+
bio: The bio of the user.
|
|
99
|
+
etag: The ETag value for conditional requests.
|
|
100
|
+
last_modified: The Last-Modified timestamp for conditional requests.
|
|
101
|
+
**kwargs: Additional arguments for the request.
|
|
102
|
+
|
|
103
|
+
Returns:
|
|
104
|
+
The response object.
|
|
105
|
+
|
|
106
|
+
"""
|
|
107
|
+
endpoint, payload, kwargs = self._update_user_helper(
|
|
108
|
+
name=name,
|
|
109
|
+
email=email,
|
|
110
|
+
blog=blog,
|
|
111
|
+
twitter_username=twitter_username,
|
|
112
|
+
company=company,
|
|
113
|
+
location=location,
|
|
114
|
+
hireable=hireable,
|
|
115
|
+
bio=bio,
|
|
116
|
+
**kwargs,
|
|
117
|
+
)
|
|
118
|
+
return self._patch(endpoint=endpoint, json=payload, etag=etag, last_modified=last_modified, **kwargs)
|
|
119
|
+
|
|
120
|
+
def update_user( # noqa: PLR0913
|
|
121
|
+
self,
|
|
122
|
+
name: str | None = None,
|
|
123
|
+
email: str | None = None,
|
|
124
|
+
blog: str | None = None,
|
|
125
|
+
twitter_username: str | None = None,
|
|
126
|
+
company: str | None = None,
|
|
127
|
+
location: str | None = None,
|
|
128
|
+
hireable: bool | None = None,
|
|
129
|
+
bio: str | None = None,
|
|
130
|
+
etag: str | None = None,
|
|
131
|
+
last_modified: str | None = None,
|
|
132
|
+
**kwargs: Any,
|
|
133
|
+
) -> tuple[dict[str, Any], int, str | None, str | None]:
|
|
134
|
+
"""Update the authenticated user's information.
|
|
135
|
+
|
|
136
|
+
Args:
|
|
137
|
+
name: The name of the user.
|
|
138
|
+
email: The email of the user.
|
|
139
|
+
blog: The blog URL of the user.
|
|
140
|
+
twitter_username: The Twitter username of the user.
|
|
141
|
+
company: The company of the user.
|
|
142
|
+
location: The location of the user.
|
|
143
|
+
hireable: The hireable status of the user.
|
|
144
|
+
bio: The bio of the user.
|
|
145
|
+
etag: The ETag value for conditional requests.
|
|
146
|
+
last_modified: The Last-Modified timestamp for conditional requests.
|
|
147
|
+
**kwargs: Additional arguments for the request.
|
|
148
|
+
|
|
149
|
+
Returns:
|
|
150
|
+
A tuple containing:
|
|
151
|
+
|
|
152
|
+
- A dictionary with updated user information (empty if 304 Not Modified).
|
|
153
|
+
- The HTTP status code.
|
|
154
|
+
- The ETag value from the response headers (if present).
|
|
155
|
+
- The Last-Modified timestamp from the response headers (if present).
|
|
156
|
+
|
|
157
|
+
"""
|
|
158
|
+
response = self._update_user(
|
|
159
|
+
name=name,
|
|
160
|
+
email=email,
|
|
161
|
+
blog=blog,
|
|
162
|
+
twitter_username=twitter_username,
|
|
163
|
+
company=company,
|
|
164
|
+
location=location,
|
|
165
|
+
hireable=hireable,
|
|
166
|
+
bio=bio,
|
|
167
|
+
etag=etag,
|
|
168
|
+
last_modified=last_modified,
|
|
169
|
+
**kwargs,
|
|
170
|
+
)
|
|
171
|
+
data, status_code, etag_value, last_modified_value = process_response_with_last_modified(response)
|
|
172
|
+
data = cast(dict[str, Any], data)
|
|
173
|
+
|
|
174
|
+
return data, status_code, etag_value, last_modified_value
|
|
175
|
+
|
|
176
|
+
def _list_users(
|
|
177
|
+
self,
|
|
178
|
+
since: int | None = None,
|
|
179
|
+
per_page: int | None = None,
|
|
180
|
+
etag: str | None = None,
|
|
181
|
+
last_modified: str | None = None,
|
|
182
|
+
**kwargs: Any,
|
|
183
|
+
) -> Response:
|
|
184
|
+
"""List all users.
|
|
185
|
+
|
|
186
|
+
Args:
|
|
187
|
+
since: The integer ID of the last User that you've seen.
|
|
188
|
+
per_page: The number of results per page (max 100).
|
|
189
|
+
etag: The ETag value for conditional requests.
|
|
190
|
+
last_modified: The Last-Modified timestamp for conditional requests.
|
|
191
|
+
**kwargs: Additional arguments for the request.
|
|
192
|
+
|
|
193
|
+
Returns:
|
|
194
|
+
A response object.
|
|
195
|
+
|
|
196
|
+
"""
|
|
197
|
+
endpoint, params, kwargs = self._list_users_helper(since=since, per_page=per_page, **kwargs)
|
|
198
|
+
return self._get(endpoint=endpoint, params=params, etag=etag, last_modified=last_modified, **kwargs)
|
|
199
|
+
|
|
200
|
+
def list_users(
|
|
201
|
+
self,
|
|
202
|
+
since: int | None = None,
|
|
203
|
+
per_page: int | None = None,
|
|
204
|
+
etag: str | None = None,
|
|
205
|
+
last_modified: str | None = None,
|
|
206
|
+
**kwargs: Any,
|
|
207
|
+
) -> tuple[list[dict[str, Any]], int, str | None, str | None]:
|
|
208
|
+
"""List all users.
|
|
209
|
+
|
|
210
|
+
Args:
|
|
211
|
+
since: The integer ID of the last User that you've seen.
|
|
212
|
+
per_page: The number of results per page (max 100).
|
|
213
|
+
etag: The ETag value for conditional requests.
|
|
214
|
+
last_modified: The Last-Modified timestamp for conditional requests.
|
|
215
|
+
**kwargs: Additional arguments for the request.
|
|
216
|
+
|
|
217
|
+
Returns:
|
|
218
|
+
A tuple containing:
|
|
219
|
+
|
|
220
|
+
- A list of user dictionaries (empty if 304 Not Modified).
|
|
221
|
+
- The HTTP status code.
|
|
222
|
+
- The ETag value from the response headers (if present).
|
|
223
|
+
- The Last-Modified timestamp from the response headers (if present).
|
|
224
|
+
|
|
225
|
+
"""
|
|
226
|
+
response = self._list_users(since=since, per_page=per_page, etag=etag, last_modified=last_modified, **kwargs)
|
|
227
|
+
data, status_code, etag_value, last_modified_value = process_response_with_last_modified(response)
|
|
228
|
+
if status_code == 304: # noqa: PLR2004
|
|
229
|
+
data = []
|
|
230
|
+
return cast(list[dict[str, Any]], data), status_code, etag_value, last_modified_value
|
|
231
|
+
|
|
232
|
+
def _get_contextual_information(
|
|
233
|
+
self,
|
|
234
|
+
username: str,
|
|
235
|
+
subject_type: str | None = None,
|
|
236
|
+
subject_id: str | None = None,
|
|
237
|
+
**kwargs: Any,
|
|
238
|
+
) -> Response:
|
|
239
|
+
"""Get contextual information about a user.
|
|
240
|
+
|
|
241
|
+
Args:
|
|
242
|
+
username: The username of the user.
|
|
243
|
+
subject_type: The type of subject for the hovercard.
|
|
244
|
+
subject_id: The ID of the subject for the hovercard.
|
|
245
|
+
**kwargs: Additional arguments for the request.
|
|
246
|
+
|
|
247
|
+
Returns:
|
|
248
|
+
The response object.
|
|
249
|
+
|
|
250
|
+
"""
|
|
251
|
+
endpoint, params, kwargs = self._get_contextual_information_helper(
|
|
252
|
+
username=username, subject_type=subject_type, subject_id=subject_id, **kwargs
|
|
253
|
+
)
|
|
254
|
+
return self._get(endpoint=endpoint, params=params, **kwargs)
|
|
255
|
+
|
|
256
|
+
def get_contextual_information(
|
|
257
|
+
self,
|
|
258
|
+
username: str,
|
|
259
|
+
subject_type: str | None = None,
|
|
260
|
+
subject_id: str | None = None,
|
|
261
|
+
**kwargs: Any,
|
|
262
|
+
) -> tuple[dict[str, Any], int, str | None, str | None]:
|
|
263
|
+
"""Get contextual information about a user.
|
|
264
|
+
|
|
265
|
+
Args:
|
|
266
|
+
username: The username of the user.
|
|
267
|
+
subject_type: The type of subject for the hovercard.
|
|
268
|
+
subject_id: The ID of the subject for the hovercard.
|
|
269
|
+
**kwargs: Additional arguments for the request.
|
|
270
|
+
|
|
271
|
+
Returns:
|
|
272
|
+
A tuple containing:
|
|
273
|
+
|
|
274
|
+
- A dictionary with contextual information about the user.
|
|
275
|
+
- The HTTP status code.
|
|
276
|
+
- The ETag value from the response headers (if present).
|
|
277
|
+
- The Last-Modified timestamp from the response headers (if present).
|
|
278
|
+
|
|
279
|
+
"""
|
|
280
|
+
response = self._get_contextual_information(
|
|
281
|
+
username=username, subject_type=subject_type, subject_id=subject_id, **kwargs
|
|
282
|
+
)
|
|
283
|
+
data, status_code, etag_value, last_modified_value = process_response_with_last_modified(response)
|
|
284
|
+
data = cast(dict[str, Any], data)
|
|
285
|
+
return data, status_code, etag_value, last_modified_value
|
ghnova/utils/__init__.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""Utility functions for the ghnova package."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from ghnova.utils.log import get_version_information, setup_logger
|
|
6
|
+
from ghnova.utils.response import (
|
|
7
|
+
process_async_response_with_last_modified,
|
|
8
|
+
process_response_with_last_modified,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
"get_version_information",
|
|
13
|
+
"process_async_response_with_last_modified",
|
|
14
|
+
"process_response_with_last_modified",
|
|
15
|
+
"setup_logger",
|
|
16
|
+
]
|
ghnova/utils/log.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""Utility functions for logging."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from ghnova.version import __version__
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def get_version_information() -> str:
|
|
12
|
+
"""Get the version information.
|
|
13
|
+
|
|
14
|
+
Returns:
|
|
15
|
+
str: Version information.
|
|
16
|
+
|
|
17
|
+
"""
|
|
18
|
+
return __version__
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def setup_logger(
|
|
22
|
+
outdir: str = ".", label: str | None = None, log_level: str | int = "INFO", print_version: bool = False
|
|
23
|
+
) -> None:
|
|
24
|
+
"""Set up logging output: call at the start of the script to use.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
outdir: Output directory for log file.
|
|
28
|
+
label: Label for log file name. If None, no log file is created.
|
|
29
|
+
log_level: Logging level as string or integer.
|
|
30
|
+
print_version: Whether to print version information to the log.
|
|
31
|
+
|
|
32
|
+
"""
|
|
33
|
+
if isinstance(log_level, str):
|
|
34
|
+
try:
|
|
35
|
+
level = getattr(logging, log_level.upper())
|
|
36
|
+
except AttributeError as e:
|
|
37
|
+
raise ValueError(f"log_level {log_level} not understood") from e
|
|
38
|
+
else:
|
|
39
|
+
level = int(log_level)
|
|
40
|
+
|
|
41
|
+
logger = logging.getLogger("ghnova")
|
|
42
|
+
logger.propagate = False
|
|
43
|
+
logger.setLevel(level)
|
|
44
|
+
|
|
45
|
+
if not any(
|
|
46
|
+
isinstance(h, logging.StreamHandler) and not isinstance(h, logging.FileHandler) for h in logger.handlers
|
|
47
|
+
):
|
|
48
|
+
stream_handler = logging.StreamHandler()
|
|
49
|
+
stream_handler.setFormatter(
|
|
50
|
+
logging.Formatter("%(asctime)s %(name)s %(levelname)-8s: %(message)s", datefmt="%H:%M")
|
|
51
|
+
)
|
|
52
|
+
stream_handler.setLevel(level)
|
|
53
|
+
logger.addHandler(stream_handler)
|
|
54
|
+
|
|
55
|
+
if not any(isinstance(h, logging.FileHandler) for h in logger.handlers) and label:
|
|
56
|
+
outdir_path = Path(outdir)
|
|
57
|
+
outdir_path.mkdir(parents=True, exist_ok=True)
|
|
58
|
+
log_file = outdir_path / f"{label}.log"
|
|
59
|
+
file_handler = logging.FileHandler(log_file)
|
|
60
|
+
file_handler.setFormatter(logging.Formatter("%(asctime)s %(levelname)-8s: %(message)s", datefmt="%H:%M"))
|
|
61
|
+
|
|
62
|
+
file_handler.setLevel(level)
|
|
63
|
+
logger.addHandler(file_handler)
|
|
64
|
+
|
|
65
|
+
for handler in logger.handlers:
|
|
66
|
+
handler.setLevel(level)
|
|
67
|
+
|
|
68
|
+
if print_version:
|
|
69
|
+
version = get_version_information()
|
|
70
|
+
logger.info("Running ghnova version: %s", version)
|
ghnova/utils/response.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""Response processing utilities with Last-Modified handling."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from aiohttp import ClientResponse, ContentTypeError
|
|
9
|
+
from requests import Response
|
|
10
|
+
|
|
11
|
+
logger = logging.getLogger("ghnova")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def process_response_with_last_modified(
|
|
15
|
+
response: Response,
|
|
16
|
+
) -> tuple[dict[str, Any] | list[dict[str, Any]], int, str | None, str | None]:
|
|
17
|
+
"""Process an HTTP response and extract data, status, ETag, and Last-Modified.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
response: The HTTP response object.
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
A tuple containing the response data, status code, ETag, and Last-Modified.
|
|
24
|
+
|
|
25
|
+
"""
|
|
26
|
+
status_code = response.status_code
|
|
27
|
+
etag = response.headers.get("ETag", None)
|
|
28
|
+
last_modified = response.headers.get("Last-Modified", None)
|
|
29
|
+
if status_code == 204: # noqa: PLR2004
|
|
30
|
+
data = {}
|
|
31
|
+
elif 200 <= status_code < 300: # noqa: PLR2004
|
|
32
|
+
try:
|
|
33
|
+
data = response.json()
|
|
34
|
+
except ValueError as e:
|
|
35
|
+
logger.error("Failed to parse JSON response: %s", e)
|
|
36
|
+
data = {}
|
|
37
|
+
else:
|
|
38
|
+
data = {}
|
|
39
|
+
return data, status_code, etag, last_modified
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
async def process_async_response_with_last_modified(
|
|
43
|
+
response: ClientResponse,
|
|
44
|
+
) -> tuple[dict[str, Any] | list[dict[str, Any]], int, str | None, str | None]:
|
|
45
|
+
"""Process an asynchronous HTTP response and extract data, status, ETag, and Last-Modified.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
response: The asynchronous HTTP response object.
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
A tuple containing the response data, status code, ETag, and Last-Modified.
|
|
52
|
+
|
|
53
|
+
"""
|
|
54
|
+
status_code = response.status
|
|
55
|
+
etag = response.headers.get("ETag", None)
|
|
56
|
+
last_modified = response.headers.get("Last-Modified", None)
|
|
57
|
+
if status_code == 204: # noqa: PLR2004
|
|
58
|
+
data = {}
|
|
59
|
+
elif 200 <= status_code < 300: # noqa: PLR2004
|
|
60
|
+
try:
|
|
61
|
+
data = await response.json()
|
|
62
|
+
except (ValueError, ContentTypeError) as e:
|
|
63
|
+
logger.error("Failed to parse JSON response: %s", e)
|
|
64
|
+
data = {}
|
|
65
|
+
else:
|
|
66
|
+
data = {}
|
|
67
|
+
return data, status_code, etag, last_modified
|
ghnova/version.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""A script to infer the version number from the metadata."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
6
|
+
|
|
7
|
+
try:
|
|
8
|
+
__version__ = version("ghnova")
|
|
9
|
+
except PackageNotFoundError:
|
|
10
|
+
# Fallback for source checkouts or environments without installed metadata.
|
|
11
|
+
__version__ = "0+unknown"
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ghnova
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: A Python package for interacting with the GitHub API, offering a simple interface to access repositories, users, organizations, issues, and more for automation and data management.
|
|
5
|
+
Project-URL: Documentation, https://isaac-cf-wong.github.io/ghnova
|
|
6
|
+
Project-URL: Source, https://github.com/isaac-cf-wong/ghnova
|
|
7
|
+
Project-URL: Tracker, https://github.com/isaac-cf-wong/ghnova/issues
|
|
8
|
+
Project-URL: Home, https://github.com/isaac-cf-wong/ghnova
|
|
9
|
+
Project-URL: Release Notes, https://github.com/isaac-cf-wong/ghnova/releases
|
|
10
|
+
Author-email: "Isaac C. F. Wong" <isaac.cf.wong@gmail.com>
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Requires-Dist: aiohttp==3.13.3
|
|
21
|
+
Requires-Dist: pydantic==2.12.5
|
|
22
|
+
Requires-Dist: typer==0.21.1
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: black; extra == 'dev'
|
|
25
|
+
Requires-Dist: flake8; extra == 'dev'
|
|
26
|
+
Requires-Dist: pre-commit; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
28
|
+
Provides-Extra: docs
|
|
29
|
+
Requires-Dist: mike; extra == 'docs'
|
|
30
|
+
Requires-Dist: mkdocs; extra == 'docs'
|
|
31
|
+
Requires-Dist: mkdocs-gen-files; extra == 'docs'
|
|
32
|
+
Requires-Dist: mkdocs-literate-nav; extra == 'docs'
|
|
33
|
+
Requires-Dist: mkdocs-material; extra == 'docs'
|
|
34
|
+
Requires-Dist: mkdocs-section-index; extra == 'docs'
|
|
35
|
+
Requires-Dist: mkdocstrings[python]; extra == 'docs'
|
|
36
|
+
Provides-Extra: test
|
|
37
|
+
Requires-Dist: bandit[toml]==1.9.3; extra == 'test'
|
|
38
|
+
Requires-Dist: black==26.1.0; extra == 'test'
|
|
39
|
+
Requires-Dist: check-manifest==0.51; extra == 'test'
|
|
40
|
+
Requires-Dist: flake8; extra == 'test'
|
|
41
|
+
Requires-Dist: flake8-bugbear==25.11.29; extra == 'test'
|
|
42
|
+
Requires-Dist: flake8-docstrings; extra == 'test'
|
|
43
|
+
Requires-Dist: flake8-formatter-junit-xml; extra == 'test'
|
|
44
|
+
Requires-Dist: flake8-pyproject; extra == 'test'
|
|
45
|
+
Requires-Dist: pre-commit==4.5.1; extra == 'test'
|
|
46
|
+
Requires-Dist: pytest-asyncio==1.3.0; extra == 'test'
|
|
47
|
+
Requires-Dist: pytest-cov==7.0.0; extra == 'test'
|
|
48
|
+
Requires-Dist: pytest-github-actions-annotate-failures; extra == 'test'
|
|
49
|
+
Requires-Dist: pytest-mock<3.15.2; extra == 'test'
|
|
50
|
+
Requires-Dist: pytest-runner; extra == 'test'
|
|
51
|
+
Requires-Dist: pytest==9.0.2; extra == 'test'
|
|
52
|
+
Requires-Dist: shellcheck-py==0.11.0.1; extra == 'test'
|
|
53
|
+
Description-Content-Type: text/markdown
|
|
54
|
+
|
|
55
|
+
# ghnova
|
|
56
|
+
|
|
57
|
+
[](https://github.com/isaac-cf-wong/ghnova/actions/workflows/CI.yml)
|
|
58
|
+
[](https://results.pre-commit.ci/latest/github/isaac-cf-wong/ghnova/main)
|
|
59
|
+
[](https://isaac-cf-wong.github.io/ghnova/)
|
|
60
|
+
[](https://codecov.io/gh/isaac-cf-wong/ghnova)
|
|
61
|
+
[](https://pypi.org/project/ghnova/)
|
|
62
|
+
[](https://pypi.org/project/ghnova/)
|
|
63
|
+
[](LICENSE)
|
|
64
|
+
[](https://github.com/PyCQA/bandit)
|
|
65
|
+
[](https://doi.org/10.5281/zenodo.18290200)
|
|
66
|
+
|
|
67
|
+
**Note:** This project is still in progress. The promised features are not fully ready yet, and APIs are subject to change.
|
|
68
|
+
|
|
69
|
+
A Python package for interacting with the GitHub API.
|
|
70
|
+
This package provides a simple and intuitive interface to access
|
|
71
|
+
GitHub repositories, users, organizations, issues, and more,
|
|
72
|
+
enabling seamless integration with GitHub instances for automation, data retrieval, and management tasks.
|
|
73
|
+
|
|
74
|
+
## Features
|
|
75
|
+
|
|
76
|
+
Full API Coverage: Access to repositories, users, organizations, issues, pull requests, and more.
|
|
77
|
+
|
|
78
|
+
- Easy Authentication: Support for token-based authentication.
|
|
79
|
+
- Asynchronous Support: Built with async/await for non-blocking operations.
|
|
80
|
+
- Type Hints: Full type annotations for better IDE support and code reliability.
|
|
81
|
+
- Comprehensive Documentation: Detailed guides and API reference.
|
|
82
|
+
- Command-Line Interface: Interact with the GitHub API directly from the terminal for
|
|
83
|
+
quick, scriptable operations without writing code.
|
|
84
|
+
|
|
85
|
+
## Installation
|
|
86
|
+
|
|
87
|
+
We recommend using `uv` to manage virtual environments for installing `ghnova`.
|
|
88
|
+
|
|
89
|
+
If you don't have `uv` installed, you can install it with pip. See the project pages for more details:
|
|
90
|
+
|
|
91
|
+
- Install via pip: `pip install --upgrade pip && pip install uv`
|
|
92
|
+
- Project pages: [uv on PyPI](https://pypi.org/project/uv/) | [uv on GitHub](https://github.com/astral-sh/uv)
|
|
93
|
+
- Full documentation and usage guide: [uv docs](https://docs.astral.sh/uv/)
|
|
94
|
+
|
|
95
|
+
### Requirements
|
|
96
|
+
|
|
97
|
+
- Python 3.10 or higher
|
|
98
|
+
- Operating System: Linux, macOS, or Windows
|
|
99
|
+
|
|
100
|
+
### Install from PyPI
|
|
101
|
+
|
|
102
|
+
The recommended way to install `ghnova` is from PyPI:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# Create a virtual environment (recommended with uv)
|
|
106
|
+
uv venv --python 3.10
|
|
107
|
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
108
|
+
uv pip install ghnova
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### Optional Dependencies
|
|
112
|
+
|
|
113
|
+
For development or specific features:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# Development dependencies (testing, linting, etc.)
|
|
117
|
+
uv pip install ghnova[dev]
|
|
118
|
+
|
|
119
|
+
# Documentation dependencies
|
|
120
|
+
uv pip install ghnova[docs]
|
|
121
|
+
|
|
122
|
+
# All dependencies
|
|
123
|
+
uv pip install ghnova[dev,docs]
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Install from Source
|
|
127
|
+
|
|
128
|
+
For the latest development version:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
git clone git@github.com:isaac-cf-wong/ghnova.git
|
|
132
|
+
cd ghnova
|
|
133
|
+
# Create a virtual environment (recommended with uv)
|
|
134
|
+
uv venv --python 3.10
|
|
135
|
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
136
|
+
uv pip install .
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
#### Development Installation
|
|
140
|
+
|
|
141
|
+
To set up for development:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
git clone git@github.com:isaac-cf-wong/ghnova.git
|
|
145
|
+
cd ghnova
|
|
146
|
+
|
|
147
|
+
# Create a virtual environment (recommended with uv)
|
|
148
|
+
uv venv --python 3.10
|
|
149
|
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
150
|
+
uv pip install ".[dev]"
|
|
151
|
+
|
|
152
|
+
# Install the commitlint dependencies
|
|
153
|
+
npm install
|
|
154
|
+
|
|
155
|
+
# Install pre-commit hooks
|
|
156
|
+
pre-commit install
|
|
157
|
+
pre-commit install --hook-type commit-msg
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Verify Installation
|
|
161
|
+
|
|
162
|
+
Check that `ghnova` is installed correctly:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
ghnova --help
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
python -c "import ghnova; print(ghnova.__version__)"
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Release Schedule
|
|
173
|
+
|
|
174
|
+
Releases follow a fixed schedule: every Tuesday at 00:00 UTC,
|
|
175
|
+
unless an emergent bugfix is required.
|
|
176
|
+
This ensures predictable updates while allowing flexibility for critical issues.
|
|
177
|
+
Users can view upcoming changes in the draft release on the
|
|
178
|
+
[GitHub Releases page](https://github.com/isaac-cf-wong/ghnova/releases).
|
|
179
|
+
|
|
180
|
+
## License
|
|
181
|
+
|
|
182
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
183
|
+
|
|
184
|
+
## Support
|
|
185
|
+
|
|
186
|
+
For questions, issues, or contributions, please:
|
|
187
|
+
|
|
188
|
+
- Check the [documentation](https://isaac-cf-wong.github.io/ghnova/)
|
|
189
|
+
- Open an issue on [GitHub](https://github.com/isaac-cf-wong/ghnova/issues)
|
|
190
|
+
- Join our [discussions](https://github.com/isaac-cf-wong/ghnova/discussions)
|
|
191
|
+
|
|
192
|
+
## Changelog
|
|
193
|
+
|
|
194
|
+
See [Release Notes](https://github.com/isaac-cf-wong/ghnova/releases) for version history.
|