Skip to content

Commit f5bc441

Browse files
committed
build
1 parent a100707 commit f5bc441

File tree

2 files changed

+66
-45
lines changed

2 files changed

+66
-45
lines changed

00_core.ipynb

Lines changed: 63 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -293,22 +293,22 @@
293293
{
294294
"data": {
295295
"text/markdown": [
296-
"- ref: refs/heads/master\n",
297-
"- node_id: MDM6UmVmMzE1NzEyNTg4OnJlZnMvaGVhZHMvbWFzdGVy\n",
298-
"- url: https://api.github.com/repos/fastai/ghapi-test/git/refs/heads/master\n",
299-
"- object: \n",
300-
" - sha: d0605f3abc070f4790501db038c24223379007a5\n",
301-
" - type: commit\n",
302-
" - url: https://api.github.com/repos/fastai/ghapi-test/git/commits/d0605f3abc070f4790501db038c24223379007a5"
296+
"```json\n",
297+
"{ 'node_id': 'MDM6UmVmMzE1NzEyNTg4OnJlZnMvaGVhZHMvbWFzdGVy',\n",
298+
" 'object': { 'sha': 'a863d693772d5e76c05d4065c3f21a0e26e96e6b',\n",
299+
" 'type': 'commit',\n",
300+
" 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/commits/a863d693772d5e76c05d4065c3f21a0e26e96e6b'},\n",
301+
" 'ref': 'refs/heads/master',\n",
302+
" 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/refs/heads/master'}\n",
303+
"```"
303304
],
304305
"text/plain": [
305-
"- ref: refs/heads/master\n",
306-
"- node_id: MDM6UmVmMzE1NzEyNTg4OnJlZnMvaGVhZHMvbWFzdGVy\n",
307-
"- url: https://api.github.com/repos/fastai/ghapi-test/git/refs/heads/master\n",
308-
"- object: \n",
309-
" - sha: d0605f3abc070f4790501db038c24223379007a5\n",
310-
" - type: commit\n",
311-
" - url: https://api.github.com/repos/fastai/ghapi-test/git/commits/d0605f3abc070f4790501db038c24223379007a5"
306+
"{'ref': 'refs/heads/master',\n",
307+
" 'node_id': 'MDM6UmVmMzE1NzEyNTg4OnJlZnMvaGVhZHMvbWFzdGVy',\n",
308+
" 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/refs/heads/master',\n",
309+
" 'object': {'sha': 'a863d693772d5e76c05d4065c3f21a0e26e96e6b',\n",
310+
" 'type': 'commit',\n",
311+
" 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/commits/a863d693772d5e76c05d4065c3f21a0e26e96e6b'}}"
312312
]
313313
},
314314
"execution_count": null,
@@ -329,7 +329,7 @@
329329
{
330330
"data": {
331331
"text/markdown": [
332-
"<h4 id=\"GhApi.__getitem__\" class=\"doc_header\"><code>GhApi.__getitem__</code><a href=\"__main__.py#L39\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
332+
"<h4 id=\"GhApi.__getitem__\" class=\"doc_header\"><code>GhApi.__getitem__</code><a href=\"__main__.py#L40\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
333333
"\n",
334334
"> <code>GhApi.__getitem__</code>(**`k`**)\n",
335335
"\n",
@@ -362,22 +362,22 @@
362362
{
363363
"data": {
364364
"text/markdown": [
365-
"- ref: refs/heads/master\n",
366-
"- node_id: MDM6UmVmMzE1NzEyNTg4OnJlZnMvaGVhZHMvbWFzdGVy\n",
367-
"- url: https://api.github.com/repos/fastai/ghapi-test/git/refs/heads/master\n",
368-
"- object: \n",
369-
" - sha: d0605f3abc070f4790501db038c24223379007a5\n",
370-
" - type: commit\n",
371-
" - url: https://api.github.com/repos/fastai/ghapi-test/git/commits/d0605f3abc070f4790501db038c24223379007a5"
365+
"```json\n",
366+
"{ 'node_id': 'MDM6UmVmMzE1NzEyNTg4OnJlZnMvaGVhZHMvbWFzdGVy',\n",
367+
" 'object': { 'sha': 'a863d693772d5e76c05d4065c3f21a0e26e96e6b',\n",
368+
" 'type': 'commit',\n",
369+
" 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/commits/a863d693772d5e76c05d4065c3f21a0e26e96e6b'},\n",
370+
" 'ref': 'refs/heads/master',\n",
371+
" 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/refs/heads/master'}\n",
372+
"```"
372373
],
373374
"text/plain": [
374-
"- ref: refs/heads/master\n",
375-
"- node_id: MDM6UmVmMzE1NzEyNTg4OnJlZnMvaGVhZHMvbWFzdGVy\n",
376-
"- url: https://api.github.com/repos/fastai/ghapi-test/git/refs/heads/master\n",
377-
"- object: \n",
378-
" - sha: d0605f3abc070f4790501db038c24223379007a5\n",
379-
" - type: commit\n",
380-
" - url: https://api.github.com/repos/fastai/ghapi-test/git/commits/d0605f3abc070f4790501db038c24223379007a5"
375+
"{'ref': 'refs/heads/master',\n",
376+
" 'node_id': 'MDM6UmVmMzE1NzEyNTg4OnJlZnMvaGVhZHMvbWFzdGVy',\n",
377+
" 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/refs/heads/master',\n",
378+
" 'object': {'sha': 'a863d693772d5e76c05d4065c3f21a0e26e96e6b',\n",
379+
" 'type': 'commit',\n",
380+
" 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/commits/a863d693772d5e76c05d4065c3f21a0e26e96e6b'}}"
381381
]
382382
},
383383
"execution_count": null,
@@ -411,7 +411,7 @@
411411
{
412412
"data": {
413413
"text/plain": [
414-
"'d0605f3abc070f4790501db038c24223379007a5'"
414+
"'a863d693772d5e76c05d4065c3f21a0e26e96e6b'"
415415
]
416416
},
417417
"execution_count": null,
@@ -448,7 +448,7 @@
448448
"name": "stdout",
449449
"output_type": "stream",
450450
"text": [
451-
"Quota remaining: 4991 of 5000\n"
451+
"Quota remaining: 4874 of 5000\n"
452452
]
453453
},
454454
{
@@ -484,7 +484,7 @@
484484
{
485485
"data": {
486486
"text/plain": [
487-
"'4991'"
487+
"'4874'"
488488
]
489489
},
490490
"execution_count": null,
@@ -552,6 +552,9 @@
552552
"- [checks](https://docs.github.com/rest/reference/checks)\n",
553553
"- [code_scanning](https://docs.github.com/rest/reference/code-scanning)\n",
554554
"- [codes_of_conduct](https://docs.github.com/rest/reference/codes-of-conduct)\n",
555+
"- [codespaces](https://docs.github.com/rest/reference/codespaces)\n",
556+
"- [dependabot](https://docs.github.com/rest/reference/dependabot)\n",
557+
"- [dependency_graph](https://docs.github.com/rest/reference/dependency-graph)\n",
555558
"- [emojis](https://docs.github.com/rest/reference/emojis)\n",
556559
"- [enterprise_admin](https://docs.github.com/rest/reference/enterprise-admin)\n",
557560
"- [gists](https://docs.github.com/rest/reference/gists)\n",
@@ -564,6 +567,7 @@
564567
"- [meta](https://docs.github.com/rest/reference/meta)\n",
565568
"- [migrations](https://docs.github.com/rest/reference/migrations)\n",
566569
"- [oauth_authorizations](https://docs.github.com/rest/reference/oauth-authorizations)\n",
570+
"- [oidc](https://docs.github.com/rest/reference/oidc)\n",
567571
"- [orgs](https://docs.github.com/rest/reference/orgs)\n",
568572
"- [packages](https://docs.github.com/rest/reference/packages)\n",
569573
"- [projects](https://docs.github.com/rest/reference/projects)\n",
@@ -578,7 +582,7 @@
578582
"- [users](https://docs.github.com/rest/reference/users)"
579583
],
580584
"text/plain": [
581-
"<__main__.GhApi at 0x11e204eb0>"
585+
"<__main__.GhApi at 0x14af1cd60>"
582586
]
583587
},
584588
"execution_count": null,
@@ -602,7 +606,7 @@
602606
"- [codes-of-conduct.get_conduct_code](https://docs.github.com/rest/reference/codes-of-conduct#get-a-code-of-conduct)(key): *Get a code of conduct*"
603607
],
604608
"text/plain": [
605-
"<__main__._GhVerbGroup at 0x11e204940>"
609+
"<__main__._GhVerbGroup at 0x14af1abe0>"
606610
]
607611
},
608612
"execution_count": null,
@@ -752,7 +756,7 @@
752756
"- [git.get_tree](https://docs.github.com/rest/reference/git#get-a-tree)(tree_sha, recursive): *Get a tree*"
753757
],
754758
"text/plain": [
755-
"<__main__._GhVerbGroup at 0x11e211d30>"
759+
"<__main__._GhVerbGroup at 0x14af1b550>"
756760
]
757761
},
758762
"execution_count": null,
@@ -1028,7 +1032,7 @@
10281032
{
10291033
"data": {
10301034
"text/plain": [
1031-
"('https://gist.github.com/77c65673fbf13079a63c4d525e03e043', 'some content')"
1035+
"('https://gist.github.com/7090f1687eea491992b30ec0333daf4e', 'some content')"
10321036
]
10331037
},
10341038
"execution_count": null,
@@ -1443,19 +1447,19 @@
14431447
"```json\n",
14441448
"{ 'mode': '100644',\n",
14451449
" 'path': 'README.md',\n",
1446-
" 'sha': '9b33a4362dda251455f7e4d99554467d1e6ba024',\n",
1447-
" 'size': 66,\n",
1450+
" 'sha': 'eaea0f2698e76c75602058bf4e2e9fd7940ac4e3',\n",
1451+
" 'size': 72,\n",
14481452
" 'type': 'blob',\n",
1449-
" 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/blobs/9b33a4362dda251455f7e4d99554467d1e6ba024'}\n",
1453+
" 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/blobs/eaea0f2698e76c75602058bf4e2e9fd7940ac4e3'}\n",
14501454
"```"
14511455
],
14521456
"text/plain": [
14531457
"{'path': 'README.md',\n",
14541458
" 'mode': '100644',\n",
14551459
" 'type': 'blob',\n",
1456-
" 'sha': '9b33a4362dda251455f7e4d99554467d1e6ba024',\n",
1457-
" 'size': 66,\n",
1458-
" 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/blobs/9b33a4362dda251455f7e4d99554467d1e6ba024'}"
1460+
" 'sha': 'eaea0f2698e76c75602058bf4e2e9fd7940ac4e3',\n",
1461+
" 'size': 72,\n",
1462+
" 'url': 'https://api.github.com/repos/fastai/ghapi-test/git/blobs/eaea0f2698e76c75602058bf4e2e9fd7940ac4e3'}"
14591463
]
14601464
},
14611465
"execution_count": null,
@@ -1645,7 +1649,23 @@
16451649
"cell_type": "code",
16461650
"execution_count": null,
16471651
"metadata": {},
1648-
"outputs": [],
1652+
"outputs": [
1653+
{
1654+
"data": {
1655+
"text/markdown": [
1656+
"```json\n",
1657+
"{}\n",
1658+
"```"
1659+
],
1660+
"text/plain": [
1661+
"{}"
1662+
]
1663+
},
1664+
"execution_count": null,
1665+
"metadata": {},
1666+
"output_type": "execute_result"
1667+
}
1668+
],
16491669
"source": [
16501670
"res = api.enable_pages(branch='new-branch', path='/')\n",
16511671
"test_eq(res.source.branch, 'new-branch')\n",

ghapi/core.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,16 @@ def __call__(self, path:str, verb:str=None, headers:dict=None, route:dict=None,
107107
path = self.gh_host + path
108108
if route:
109109
for k,v in route.items(): route[k] = quote(str(route[k]))
110+
return_json = ('json' in headers['Accept'])
110111
res,self.recv_hdrs = urlsend(path, verb, headers=headers or None, debug=self.debug, return_headers=True,
111-
route=route or None, query=query or None, data=data or None)
112+
route=route or None, query=query or None, data=data or None, return_json=return_json)
112113
if 'X-RateLimit-Remaining' in self.recv_hdrs:
113114
newlim = self.recv_hdrs['X-RateLimit-Remaining']
114115
if self.limit_cb is not None and newlim != self.limit_rem:
115116
self.limit_cb(int(newlim),int(self.recv_hdrs['X-RateLimit-Limit']))
116117
self.limit_rem = newlim
117118

118-
return dict2obj(res)
119+
return dict2obj(res) if return_json else res
119120

120121
def __dir__(self): return super().__dir__() + list(self.groups)
121122
def _repr_markdown_(self): return "\n".join(f"- [{o}]({_docroot + o.replace('_', '-')})" for o in sorted(self.groups))

0 commit comments

Comments
 (0)