Skip to content

Commit 2af1e56

Browse files
committed
fixes export
1 parent f237a63 commit 2af1e56

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

fastcore/_modidx.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@
448448
'fastcore.xtras.local2utc': 'https://fastcore.fast.ai/xtras.html#local2utc',
449449
'fastcore.xtras.mapped': 'https://fastcore.fast.ai/xtras.html#mapped',
450450
'fastcore.xtras.maybe_open': 'https://fastcore.fast.ai/xtras.html#maybe_open',
451+
'fastcore.xtras.mkdir': 'https://fastcore.fast.ai/xtras.html#mkdir',
451452
'fastcore.xtras.modified_env': 'https://fastcore.fast.ai/xtras.html#modified_env',
452453
'fastcore.xtras.modify_exception': 'https://fastcore.fast.ai/xtras.html#modify_exception',
453454
'fastcore.xtras.obj2dict': 'https://fastcore.fast.ai/xtras.html#obj2dict',

fastcore/xtras.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from __future__ import annotations
55

66
# %% auto 0
7-
__all__ = ['spark_chars', 'walk', 'globtastic', 'maybe_open', 'image_size', 'bunzip', 'loads', 'loads_multi', 'dumps',
7+
__all__ = ['spark_chars', 'walk', 'globtastic', 'maybe_open', 'mkdir', 'image_size', 'bunzip', 'loads', 'loads_multi', 'dumps',
88
'untar_dir', 'repo_details', 'run', 'open_file', 'save_pickle', 'load_pickle', 'dict2obj', 'obj2dict',
99
'repr_dict', 'is_listy', 'mapped', 'IterLen', 'ReindexCollection', 'get_source_link', 'truncstr',
1010
'sparkline', 'modify_exception', 'round_multiple', 'set_num_threads', 'join_path_file', 'autostart',
@@ -74,6 +74,14 @@ def maybe_open(f, mode='r', **kwargs):
7474
with open(f, mode, **kwargs) as f: yield f
7575
else: yield f
7676

77+
# %% ../nbs/03_xtras.ipynb 26
78+
def mkdir(path, exist_ok=False, parents=False, overwrite=False, **kwargs):
79+
"Creates and returns a directory defined by `path`, optionally removing previous existing directory if `overwrite` is `True`"
80+
path = Path(path)
81+
if path.exists() and overwrite: shutil.rmtree(path)
82+
path.mkdir(exist_ok=exist_ok, parents=parents, **kwargs)
83+
return path
84+
7785
# %% ../nbs/03_xtras.ipynb 28
7886
def image_size(fn):
7987
"Tuple of (w,h) for png, gif, or jpg; `None` otherwise"

nbs/.gitattributes

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
*.ipynb merge=nbdev-merge
1+
**/*.ipynb filter=clean-nbs
2+
**/*.ipynb diff=ipynb

nbs/03_xtras.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@
324324
"metadata": {},
325325
"outputs": [],
326326
"source": [
327-
"#export\n",
327+
"#|export\n",
328328
"def mkdir(path, exist_ok=False, parents=False, overwrite=False, **kwargs):\n",
329329
" \"Creates and returns a directory defined by `path`, optionally removing previous existing directory if `overwrite` is `True`\"\n",
330330
" path = Path(path)\n",

0 commit comments

Comments
 (0)