|
2 | 2 |
|
3 | 3 | # %% ../nbs/api/13_cli.ipynb 2
|
4 | 4 | from __future__ import annotations
|
5 |
| -from multiprocessing import Value |
6 | 5 | import warnings
|
7 | 6 |
|
8 | 7 | from .config import *
|
@@ -86,13 +85,28 @@ def nbdev_new(**kwargs):
|
86 | 85 | _update_repo_meta(cfg)
|
87 | 86 |
|
88 | 87 | 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}' |
95 | 88 |
|
| 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 | + |
96 | 110 | cfg.nbs_path.mkdir(exist_ok=True)
|
97 | 111 | nbexists = bool(first(cfg.nbs_path.glob('*.ipynb')))
|
98 | 112 | _nbs_path_sufs = ('.ipynb','.css')
|
|
0 commit comments