Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jph00 committed Aug 27, 2024
1 parent 4d02c79 commit c5f06ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 28 deletions.
15 changes: 4 additions & 11 deletions nbdev/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,30 +85,24 @@ def nbdev_new(**kwargs):
nbdev_create_config.__wrapped__(**kwargs)
cfg = get_config()
_update_repo_meta(cfg)

path = Path()

_ORG_OR_USR = 'fastai'
_REPOSITORY = 'nbdev-template'
_ORG_OR_USR,_REPOSITORY = 'fastai','nbdev-template'
_TEMPLATE = f'{_ORG_OR_USR}/{_REPOSITORY}'
template = kwargs.get('template', _TEMPLATE)
try:
org_or_usr, repo = template.split('/')
except ValueError:
org_or_usr, repo = _ORG_OR_USR, _REPOSITORY

try: org_or_usr, repo = template.split('/')
except ValueError: org_or_usr, repo = _ORG_OR_USR, _REPOSITORY

tag = kwargs.get('tag', None)
if tag is None:
with warnings.catch_warnings():
warnings.simplefilter('ignore', UserWarning)

tag = GhApi(gh_host='https://api.github.com', authenticate=False).repos.get_latest_release(org_or_usr, repo).tag_name

url = f"https://github.com/{org_or_usr}/{repo}/archive/{tag}.tar.gz"
extract_tgz(url)
tmpl_path = path/f'{repo}-{tag}'

cfg.nbs_path.mkdir(exist_ok=True)
nbexists = bool(first(cfg.nbs_path.glob('*.ipynb')))
_nbs_path_sufs = ('.ipynb','.css')
Expand All @@ -121,7 +115,6 @@ def nbdev_new(**kwargs):
rmtree(tmpl_path)

refresh_quarto_yml()

nbdev_export.__wrapped__()
nbdev_readme.__wrapped__()

Expand Down
21 changes: 4 additions & 17 deletions nbs/api/13_cli.ipynb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "ff4908a6",
"metadata": {},
Expand Down Expand Up @@ -67,7 +66,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "e9fc60a8",
"metadata": {},
Expand Down Expand Up @@ -119,7 +117,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "3e7e76f7-7b19-4347-a52b-c33ad15d2178",
"metadata": {},
Expand Down Expand Up @@ -191,30 +188,24 @@
" nbdev_create_config.__wrapped__(**kwargs)\n",
" cfg = get_config()\n",
" _update_repo_meta(cfg)\n",
"\n",
" path = Path()\n",
"\n",
" _ORG_OR_USR = 'fastai'\n",
" _REPOSITORY = 'nbdev-template'\n",
" _ORG_OR_USR,_REPOSITORY = 'fastai','nbdev-template'\n",
" _TEMPLATE = f'{_ORG_OR_USR}/{_REPOSITORY}'\n",
" template = kwargs.get('template', _TEMPLATE)\n",
" try:\n",
" org_or_usr, repo = template.split('/')\n",
" except ValueError:\n",
" org_or_usr, repo = _ORG_OR_USR, _REPOSITORY\n",
"\n",
" try: org_or_usr, repo = template.split('/')\n",
" except ValueError: org_or_usr, repo = _ORG_OR_USR, _REPOSITORY\n",
"\n",
" tag = kwargs.get('tag', None)\n",
" if tag is None:\n",
" with warnings.catch_warnings():\n",
" warnings.simplefilter('ignore', UserWarning)\n",
"\n",
" tag = GhApi(gh_host='https://api.github.com', authenticate=False).repos.get_latest_release(org_or_usr, repo).tag_name\n",
"\n",
" url = f\"https://github.com/{org_or_usr}/{repo}/archive/{tag}.tar.gz\"\n",
" extract_tgz(url)\n",
" tmpl_path = path/f'{repo}-{tag}'\n",
" \n",
"\n",
" cfg.nbs_path.mkdir(exist_ok=True)\n",
" nbexists = bool(first(cfg.nbs_path.glob('*.ipynb')))\n",
" _nbs_path_sufs = ('.ipynb','.css')\n",
Expand All @@ -227,13 +218,11 @@
" rmtree(tmpl_path)\n",
"\n",
" refresh_quarto_yml()\n",
"\n",
" nbdev_export.__wrapped__()\n",
" nbdev_readme.__wrapped__()"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "2239c092",
"metadata": {},
Expand Down Expand Up @@ -311,7 +300,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "280e0d6d-6559-4fc3-9478-320ce5eff0dc",
"metadata": {},
Expand Down Expand Up @@ -381,7 +369,6 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "aa35b010",
"metadata": {},
Expand Down

0 comments on commit c5f06ac

Please sign in to comment.