Skip to content

Commit 8ea858f

Browse files
committed
remove obsolete Config.path usages
1 parent ce91508 commit 8ea858f

18 files changed

+40
-40
lines changed

nbdev/clean.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def nbdev_trust(
3131
warnings.warn("Please install jupyter and try again")
3232
return
3333

34-
fname = Path(fname if fname else get_config().path('nbs_path'))
34+
fname = Path(fname if fname else get_config().nbs_path)
3535
path = fname if fname.is_dir() else fname.parent
3636
check_fname = path/".last_checked"
3737
last_checked = os.path.getmtime(check_fname) if check_fname.exists() else None
@@ -133,7 +133,7 @@ def nbdev_clean(
133133
_write = partial(process_write, warn_msg='Failed to clean notebook', proc_nb=_clean)
134134
if stdin: return _write(f_in=sys.stdin, f_out=sys.stdout)
135135

136-
if fname is None: fname = get_config().path('nbs_path')
136+
if fname is None: fname = get_config().nbs_path
137137
for f in globtastic(fname, file_glob='*.ipynb', skip_folder_re='^[_.]'): _write(f_in=f, disp=disp)
138138

139139
# %% ../nbs/09_API/10_clean.ipynb 30

nbdev/doclinks.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ def _stor(nm, tree, pre=''): d[f'{mod_name}{pre}.{nm}'] = f'{loc}#{nm.lower()}',
7171
# %% ../nbs/09_API/04b_doclinks.ipynb 10
7272
def _build_modidx(dest=None, nbs_path=None, skip_exists=False):
7373
"Create _modidx.py"
74-
if dest is None: dest = get_config().path('lib_path')
75-
nbs_path = Path(nbs_path or get_config().path('nbs_path')).resolve()
74+
if dest is None: dest = get_config().lib_path
75+
nbs_path = Path(nbs_path or get_config().nbs_path).resolve()
7676
if os.environ.get('IN_TEST',0): return
7777
idxfile = dest/'_modidx.py'
7878
if skip_exists and idxfile.exists(): return
@@ -90,7 +90,7 @@ def _build_modidx(dest=None, nbs_path=None, skip_exists=False):
9090
@delegates(globtastic, but=('file_glob', 'skip_folder_re', 'skip_file_re'))
9191
def nbglob(path=None, skip_folder_re = '^[_.]', file_glob='*.ipynb', skip_file_re='^[_.]', key='nbs_path', as_path=False, **kwargs):
9292
"Find all files in a directory matching an extension given a config key."
93-
path = Path(path or get_config().path(key))
93+
path = Path(path or get_config()[key])
9494
recursive=str2bool(get_config().recursive)
9595
res = globtastic(path, file_glob=file_glob, skip_folder_re=skip_folder_re,
9696
skip_file_re=skip_file_re, recursive=recursive, **kwargs)
@@ -120,7 +120,7 @@ def nbdev_export(
120120
if os.environ.get('IN_TEST',0): return
121121
files = nbglob(path=path, **kwargs)
122122
for f in files: nb_export(f)
123-
add_init(get_config().path('lib_path'))
123+
add_init(get_config().lib_path)
124124
_build_modidx()
125125

126126
# %% ../nbs/09_API/04b_doclinks.ipynb 19

nbdev/export.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def black_format(cell, # Cell to format
4343
# %% ../nbs/09_API/04a_export.ipynb 9
4444
def nb_export(nbname, lib_path=None, procs=black_format, debug=False, mod_maker=ModuleMaker):
4545
"Create module(s) from notebook"
46-
if lib_path is None: lib_path = get_config().path('lib_path')
46+
if lib_path is None: lib_path = get_config().lib_path
4747
exp = ExportModuleProc()
4848
nb = NBProcessor(nbname, [exp]+L(procs), debug=debug)
4949
nb.process()

nbdev/maker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def make(self:ModuleMaker, cells, all_cells=None, lib_path=None):
182182
if all_cells is None: all_cells = cells
183183
cells,all_cells = L(cells),L(all_cells)
184184
if self.parse:
185-
if not lib_path: lib_path = get_config().path('lib_path')
185+
if not lib_path: lib_path = get_config().lib_path
186186
mod_dir = os.path.relpath(self.fname.parent, Path(lib_path).parent)
187187
_import2relative(all_cells, mod_dir)
188188
if not self.is_new: return self._make_exists(cells, all_cells)
@@ -215,6 +215,6 @@ def _make_exists(self:ModuleMaker, cells, all_cells=None):
215215
# %% ../nbs/09_API/02_maker.ipynb 43
216216
def _basic_export_nb2(fname, name, dest=None):
217217
"A basic exporter to bootstrap nbdev using `ModuleMaker`"
218-
if dest is None: dest = get_config().path('lib_path')
218+
if dest is None: dest = get_config().lib_path
219219
cells = L(c for c in read_nb(fname).cells if re.match(r'#\|\s*export', c.source))
220220
ModuleMaker(dest=dest, name=name, nb_path=fname).make(cells)

nbdev/migrate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,5 @@ def nbdev_migrate(
123123
_write = partial(process_write, warn_msg='Failed to replace directives', proc_nb=_migrate)
124124
if stdin: _write(f_in=sys.stdin, f_out=sys.stdout)
125125
_skip_re = None if no_skip else '^[_.]'
126-
if fname is None: fname = get_config().path('nbs_path')
126+
if fname is None: fname = get_config().nbs_path
127127
for f in globtastic(fname, file_glob='*.ipynb', skip_folder_re=_skip_re): _write(f_in=f, disp=disp)

nbdev/quarto.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ def install_quarto():
5454
def install():
5555
"Install Quarto and the current library"
5656
install_quarto.__wrapped__()
57-
d = get_config().path('lib_path')
57+
d = get_config().lib_path
5858
if (d/'__init__.py').exists(): system(f'pip install -e "{d.parent}[dev]"')
5959

6060
# %% ../nbs/09_API/13_quarto.ipynb 9
6161
def _doc_paths(path:str=None, doc_path:str=None):
6262
cfg = get_config()
6363
cfg_path = cfg.config_path
64-
path = cfg.path('nbs_path') if not path else Path(path)
65-
doc_path = cfg.path('doc_path') if not doc_path else Path(doc_path)
64+
path = cfg.nbs_path if not path else Path(path)
65+
doc_path = cfg.doc_path if not doc_path else Path(doc_path)
6666
tmp_doc_path = path/f"{cfg['doc_path']}"
6767
return cfg,cfg_path,path,doc_path,tmp_doc_path
6868

@@ -97,7 +97,7 @@ def nbdev_sidebar(
9797
**kwargs):
9898
"Create sidebar.yml"
9999
if not force and str2bool(get_config().custom_sidebar): return
100-
path = get_config().path('nbs_path') if not path else Path(path)
100+
path = get_config().nbs_path if not path else Path(path)
101101
files = nbglob(path, func=_f, skip_folder_re=skip_folder_re, **kwargs).sorted(key=_sort)
102102
lastd,res = Path(),[]
103103
for dabs,name in files:
@@ -212,7 +212,7 @@ def _ensure_quarto():
212212
def refresh_quarto_yml():
213213
"Generate `_quarto.yml` from `settings.ini`."
214214
cfg = get_config()
215-
p = cfg.path('nbs_path')/'_quarto.yml'
215+
p = cfg.nbs_path/'_quarto.yml'
216216
vals = {k:cfg.get(k) for k in ['doc_path', 'title', 'description', 'branch', 'git_url', 'doc_host', 'doc_baseurl']}
217217
# Do not build _quarto_yml if custom_quarto_yml is set to True
218218
if str2bool(cfg.get('custom_quarto_yml', False)): return
@@ -287,4 +287,4 @@ def deploy(
287287
if not skip_build: nbdev_quarto.__wrapped__(path, **kwargs)
288288
try: from ghp_import import ghp_import
289289
except: return warnings.warn('Please install ghp-import with `pip install ghp-import`')
290-
ghp_import(get_config().path('doc_path'), push=True, stderr=True, no_history=True)
290+
ghp_import(get_config().doc_path, push=True, stderr=True, no_history=True)

nbdev/release.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def _get_conda_meta():
213213
'source': {'url':rel['url'], 'sha256':rel['digests']['sha256']}
214214
}
215215

216-
_dir = cfg.path('lib_path').parent
216+
_dir = cfg.lib_path.parent
217217
readme = _dir/'README.md'
218218
descr = readme.read_text() if readme.exists() else ''
219219
d2 = {
@@ -295,7 +295,7 @@ def release_pypi(
295295
repository:str="pypi" # Respository to upload to (defined in ~/.pypirc)
296296
):
297297
"Create and upload Python package to PyPI"
298-
_dir = get_config().path('lib_path').parent
298+
_dir = get_config().lib_path.parent
299299
system(f'cd {_dir} && rm -rf dist && python setup.py sdist bdist_wheel')
300300
system(f'twine upload --repository {repository} {_dir}/dist/*')
301301

nbdev/showdoc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,5 +224,5 @@ def colab_link(path):
224224
from IPython.display import Markdown
225225
cfg = get_config()
226226
pre = 'https://colab.research.google.com/github/'
227-
res = f'{pre}{cfg.user}/{cfg.lib_name}/blob/{cfg.branch}/{cfg.path("nbs_path").name}/{path}.ipynb'
227+
res = f'{pre}{cfg.user}/{cfg.lib_name}/blob/{cfg.branch}/{cfg.nbs_path.name}/{path}.ipynb'
228228
display(Markdown(f'[Open `{path}` in Colab]({res})'))

nbdev/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def nbdev_test(
8484
if len(files)==0: return print('No files were eligible for testing')
8585

8686
if n_workers is None: n_workers = 0 if len(files)==1 else min(num_cpus(), 8)
87-
os.chdir(get_config().path('nbs_path'))
87+
os.chdir(get_config().nbs_path)
8888
if IN_NOTEBOOK: kw = {'method':'spawn'} if os.name=='nt' else {'method':'forkserver'}
8989
else: kw = {}
9090
results = parallel(test_nb, files, skip_flags=skip_flags, force_flags=force_flags, n_workers=n_workers,

nbs/09_API/02_maker.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@
479479
" if all_cells is None: all_cells = cells\n",
480480
" cells,all_cells = L(cells),L(all_cells)\n",
481481
" if self.parse: \n",
482-
" if not lib_path: lib_path = get_config().path('lib_path')\n",
482+
" if not lib_path: lib_path = get_config().lib_path\n",
483483
" mod_dir = os.path.relpath(self.fname.parent, Path(lib_path).parent)\n",
484484
" _import2relative(all_cells, mod_dir)\n",
485485
" if not self.is_new: return self._make_exists(cells, all_cells)\n",
@@ -722,7 +722,7 @@
722722
"#|export\n",
723723
"def _basic_export_nb2(fname, name, dest=None):\n",
724724
" \"A basic exporter to bootstrap nbdev using `ModuleMaker`\"\n",
725-
" if dest is None: dest = get_config().path('lib_path')\n",
725+
" if dest is None: dest = get_config().lib_path\n",
726726
" cells = L(c for c in read_nb(fname).cells if re.match(r'#\\|\\s*export', c.source))\n",
727727
" ModuleMaker(dest=dest, name=name, nb_path=fname).make(cells)"
728728
]

0 commit comments

Comments
 (0)