Skip to content

Commit 4c2d4d5

Browse files
committed
imports shutil inside mkdir
1 parent 349caba commit 4c2d4d5

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

fastcore/xtras.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def maybe_open(f, mode='r', **kwargs):
7777
# %% ../nbs/03_xtras.ipynb 26
7878
def mkdir(path, exist_ok=False, parents=False, overwrite=False, **kwargs):
7979
"Creates and returns a directory defined by `path`, optionally removing previous existing directory if `overwrite` is `True`"
80+
import shutil
8081
path = Path(path)
8182
if path.exists() and overwrite: shutil.rmtree(path)
8283
path.mkdir(exist_ok=exist_ok, parents=parents, **kwargs)

nbs/03_xtras.ipynb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@
327327
"#|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",
330+
" import shutil\n",
330331
" path = Path(path)\n",
331332
" if path.exists() and overwrite: shutil.rmtree(path)\n",
332333
" path.mkdir(exist_ok=exist_ok, parents=parents, **kwargs)\n",
@@ -1556,7 +1557,7 @@
15561557
{
15571558
"data": {
15581559
"text/plain": [
1559-
"['g', 'h', 'a', 'e', 'c', 'b', 'f', 'd']"
1560+
"['d', 'f', 'g', 'a', 'h', 'e', 'b', 'c']"
15601561
]
15611562
},
15621563
"execution_count": null,
@@ -2006,8 +2007,8 @@
20062007
"name": "stdout",
20072008
"output_type": "stream",
20082009
"text": [
2009-
"Num Events: 6, Freq/sec: 299.2\n",
2010-
"Most recent: ▇▃▁▃▅ 401.8 332.9 266.1 331.7 364.3\n"
2010+
"Num Events: 3, Freq/sec: 242.1\n",
2011+
"Most recent: ▇▁▂▃▁ 358.8 267.5 296.5 315.5 266.4\n"
20112012
]
20122013
}
20132014
],

0 commit comments

Comments
 (0)