Skip to content

Commit b47ab55

Browse files
committed
export
1 parent 05c512c commit b47ab55

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

nbdev/cli.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
# %% ../nbs/api/13_cli.ipynb 2
44
from __future__ import annotations
5-
from multiprocessing import Value
65
import warnings
76

87
from .config import *
@@ -86,13 +85,28 @@ def nbdev_new(**kwargs):
8685
_update_repo_meta(cfg)
8786

8887
path = Path()
89-
with warnings.catch_warnings():
90-
warnings.simplefilter('ignore', UserWarning)
91-
tag = GhApi(gh_host='https://api.github.com', authenticate=False).repos.get_latest_release('fastai', 'nbdev-template').tag_name
92-
url = f"https://github.com/fastai/nbdev-template/archive/{tag}.tar.gz"
93-
extract_tgz(url)
94-
tmpl_path = path/f'nbdev-template-{tag}'
9588

89+
_ORG_OR_USR = 'fastai'
90+
_REPOSITORY = 'nbdev-template'
91+
_TEMPLATE = f'{_ORG_OR_USR}/{_TEMPLATE}'
92+
template = kwargs.get('template', _TEMPLATE)
93+
try:
94+
org_or_usr, repo = template.split('/')
95+
except ValueError:
96+
org_or_usr, repo = _ORG_OR_USR, _REPOSITORY
97+
98+
99+
tag = kwargs.get('tag', None)
100+
if tag is None:
101+
with warnings.catch_warnings():
102+
warnings.simplefilter('ignore', UserWarning)
103+
104+
tag = GhApi(gh_host='https://api.github.com', authenticate=False).repos.get_latest_release(org_or_usr, repo).tag_name
105+
106+
url = f"https://github.com/{org_or_usr}/{repo}/archive/{tag}.tar.gz"
107+
extract_tgz(url)
108+
tmpl_path = path/f'{repo}-{tag}'
109+
96110
cfg.nbs_path.mkdir(exist_ok=True)
97111
nbexists = bool(first(cfg.nbs_path.glob('*.ipynb')))
98112
_nbs_path_sufs = ('.ipynb','.css')

0 commit comments

Comments
 (0)