Skip to content

Commit 2a4d643

Browse files
committed
fixes #145
1 parent e23d64b commit 2a4d643

File tree

8 files changed

+330
-312
lines changed

8 files changed

+330
-312
lines changed

00_core.ipynb

Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,8 @@
8585
" params = [_mk_param(k) for k in req_args]\n",
8686
" params += [_mk_param(k, default=v) for k,v in opt_args.items()]\n",
8787
" params += [_mk_param(k, **_mk_sig_detls(v)) for k,v in anno_args.items()]\n",
88-
" return Signature(params)"
89-
]
90-
},
91-
{
92-
"cell_type": "code",
93-
"execution_count": null,
94-
"metadata": {},
95-
"outputs": [],
96-
"source": [
97-
"#|export\n",
88+
" return Signature(params)\n",
89+
"\n",
9890
"class _GhObj: pass"
9991
]
10092
},
@@ -165,6 +157,18 @@
165157
"_docroot = 'https://docs.github.com/rest/reference/'"
166158
]
167159
},
160+
{
161+
"cell_type": "code",
162+
"execution_count": null,
163+
"metadata": {},
164+
"outputs": [],
165+
"source": [
166+
"#|export\n",
167+
"def print_summary(req:Request):\n",
168+
" \"Print `Request.summary` with the token (if any) removed\"\n",
169+
" pprint(req.summary('Authorization'))"
170+
]
171+
},
168172
{
169173
"cell_type": "markdown",
170174
"metadata": {},
@@ -185,7 +189,8 @@
185189
" token = token or os.getenv('GITHUB_TOKEN', None)\n",
186190
" jwt_token = jwt_token or os.getenv('GITHUB_JWT_TOKEN', None)\n",
187191
" if jwt_token: self.headers['Authorization'] = 'Bearer ' + jwt_token\n",
188-
" if token: self.headers['Authorization'] = 'token ' + token\n",
192+
" elif token: self.headers['Authorization'] = 'token ' + token\n",
193+
" else: warn('Neither GITHUB_TOKEN nor GITHUB_JWT_TOKEN found: running as unauthenticated')\n",
189194
" if owner: kwargs['owner'] = owner\n",
190195
" if repo: kwargs['repo' ] = repo\n",
191196
" funcs_ = L(funcs).starmap(_GhVerb, client=self, kwargs=kwargs)\n",
@@ -203,7 +208,8 @@
203208
" if route:\n",
204209
" for k,v in route.items(): route[k] = quote(str(route[k]))\n",
205210
" return_json = ('json' in headers['Accept'])\n",
206-
" res,self.recv_hdrs = urlsend(path, verb, headers=headers or None, debug=self.debug, return_headers=True,\n",
211+
" debug = self.debug if self.debug else print_summary if os.getenv('GHAPI_DEBUG') else None\n",
212+
" res,self.recv_hdrs = urlsend(path, verb, headers=headers or None, debug=debug, return_headers=True,\n",
207213
" route=route or None, query=query or None, data=data or None, return_json=return_json)\n",
208214
" if 'X-RateLimit-Remaining' in self.recv_hdrs:\n",
209215
" newlim = self.recv_hdrs['X-RateLimit-Remaining']\n",
@@ -253,15 +259,22 @@
253259
"text/markdown": [
254260
"---\n",
255261
"\n",
256-
"#### GhApi.__call__\n",
262+
"### GhApi.__call__\n",
257263
"\n",
258264
"> GhApi.__call__ (path:str, verb:str=None, headers:dict=None,\n",
259265
"> route:dict=None, query:dict=None, data=None)\n",
260266
"\n",
261267
"Call a fully specified `path` using HTTP `verb`, passing arguments to `fastcore.core.urlsend`"
262268
],
263269
"text/plain": [
264-
"<nbdev.showdoc.BasicMarkdownRenderer>"
270+
"---\n",
271+
"\n",
272+
"### GhApi.__call__\n",
273+
"\n",
274+
"> GhApi.__call__ (path:str, verb:str=None, headers:dict=None,\n",
275+
"> route:dict=None, query:dict=None, data=None)\n",
276+
"\n",
277+
"Call a fully specified `path` using HTTP `verb`, passing arguments to `fastcore.core.urlsend`"
265278
]
266279
},
267280
"execution_count": null,
@@ -299,9 +312,9 @@
299312
"text/markdown": [
300313
"```json\n",
301314
"{ 'node_id': 'MDM6UmVmMzE1NzEyNTg4OnJlZnMvaGVhZHMvbWFzdGVy',\n",
302-
" 'object': { 'sha': 'af24f2afd42cdaf2e368fed47e52a9f7c6065bed',\n",
315+
" 'object': { 'sha': '037bf40e4e5eb32a165db42a35dd89e1c1546493',\n",
303316
" 'type': 'commit',\n",
304-
" 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/commits/af24f2afd42cdaf2e368fed47e52a9f7c6065bed'},\n",
317+
" 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/commits/037bf40e4e5eb32a165db42a35dd89e1c1546493'},\n",
305318
" 'ref': 'refs/heads/master',\n",
306319
" 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/refs/heads/master'}\n",
307320
"```"
@@ -310,9 +323,9 @@
310323
"{'ref': 'refs/heads/master',\n",
311324
" 'node_id': 'MDM6UmVmMzE1NzEyNTg4OnJlZnMvaGVhZHMvbWFzdGVy',\n",
312325
" 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/refs/heads/master',\n",
313-
" 'object': {'sha': 'af24f2afd42cdaf2e368fed47e52a9f7c6065bed',\n",
326+
" 'object': {'sha': '037bf40e4e5eb32a165db42a35dd89e1c1546493',\n",
314327
" 'type': 'commit',\n",
315-
" 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/commits/af24f2afd42cdaf2e368fed47e52a9f7c6065bed'}}"
328+
" 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/commits/037bf40e4e5eb32a165db42a35dd89e1c1546493'}}"
316329
]
317330
},
318331
"execution_count": null,
@@ -335,14 +348,20 @@
335348
"text/markdown": [
336349
"---\n",
337350
"\n",
338-
"#### GhApi.__getitem__\n",
351+
"### GhApi.__getitem__\n",
339352
"\n",
340353
"> GhApi.__getitem__ (k)\n",
341354
"\n",
342355
"Lookup and call an endpoint by path and verb (which defaults to 'GET')"
343356
],
344357
"text/plain": [
345-
"<nbdev.showdoc.BasicMarkdownRenderer>"
358+
"---\n",
359+
"\n",
360+
"### GhApi.__getitem__\n",
361+
"\n",
362+
"> GhApi.__getitem__ (k)\n",
363+
"\n",
364+
"Lookup and call an endpoint by path and verb (which defaults to 'GET')"
346365
]
347366
},
348367
"execution_count": null,
@@ -371,9 +390,9 @@
371390
"text/markdown": [
372391
"```json\n",
373392
"{ 'node_id': 'MDM6UmVmMzE1NzEyNTg4OnJlZnMvaGVhZHMvbWFzdGVy',\n",
374-
" 'object': { 'sha': 'af24f2afd42cdaf2e368fed47e52a9f7c6065bed',\n",
393+
" 'object': { 'sha': '037bf40e4e5eb32a165db42a35dd89e1c1546493',\n",
375394
" 'type': 'commit',\n",
376-
" 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/commits/af24f2afd42cdaf2e368fed47e52a9f7c6065bed'},\n",
395+
" 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/commits/037bf40e4e5eb32a165db42a35dd89e1c1546493'},\n",
377396
" 'ref': 'refs/heads/master',\n",
378397
" 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/refs/heads/master'}\n",
379398
"```"
@@ -382,9 +401,9 @@
382401
"{'ref': 'refs/heads/master',\n",
383402
" 'node_id': 'MDM6UmVmMzE1NzEyNTg4OnJlZnMvaGVhZHMvbWFzdGVy',\n",
384403
" 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/refs/heads/master',\n",
385-
" 'object': {'sha': 'af24f2afd42cdaf2e368fed47e52a9f7c6065bed',\n",
404+
" 'object': {'sha': '037bf40e4e5eb32a165db42a35dd89e1c1546493',\n",
386405
" 'type': 'commit',\n",
387-
" 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/commits/af24f2afd42cdaf2e368fed47e52a9f7c6065bed'}}"
406+
" 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/commits/037bf40e4e5eb32a165db42a35dd89e1c1546493'}}"
388407
]
389408
},
390409
"execution_count": null,
@@ -418,7 +437,7 @@
418437
{
419438
"data": {
420439
"text/plain": [
421-
"'af24f2afd42cdaf2e368fed47e52a9f7c6065bed'"
440+
"'037bf40e4e5eb32a165db42a35dd89e1c1546493'"
422441
]
423442
},
424443
"execution_count": null,
@@ -455,7 +474,7 @@
455474
"name": "stdout",
456475
"output_type": "stream",
457476
"text": [
458-
"Quota remaining: 4727 of 5000\n"
477+
"Quota remaining: 4995 of 5000\n"
459478
]
460479
},
461480
{
@@ -491,7 +510,7 @@
491510
{
492511
"data": {
493512
"text/plain": [
494-
"'4727'"
513+
"'4995'"
495514
]
496515
},
497516
"execution_count": null,
@@ -788,7 +807,8 @@
788807
"outputs": [],
789808
"source": [
790809
"#|hide\n",
791-
"for hook in api.repos.list_webhooks(): api.repos.delete_webhook(hook.id)"
810+
"for hook in api.repos.list_webhooks():\n",
811+
" api.repos.delete_webhook(hook.id)"
792812
]
793813
},
794814
{
@@ -948,18 +968,6 @@
948968
"print(created, '->', gh2date(created))"
949969
]
950970
},
951-
{
952-
"cell_type": "code",
953-
"execution_count": null,
954-
"metadata": {},
955-
"outputs": [],
956-
"source": [
957-
"#|export\n",
958-
"def print_summary(req:Request):\n",
959-
" \"Print `Request.summary` with the token (if any) removed\"\n",
960-
" pprint(req.summary('Authorization'))"
961-
]
962-
},
963971
{
964972
"cell_type": "markdown",
965973
"metadata": {},

Makefile

Lines changed: 0 additions & 42 deletions
This file was deleted.

dothis

Lines changed: 0 additions & 16 deletions
This file was deleted.

ghapi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.1.23"
1+
__version__ = "1.0.0"

0 commit comments

Comments
 (0)