Skip to content

Commit ae8148c

Browse files
committed
open file in untar_data
1 parent 3e9f4f1 commit ae8148c

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

fastcore/xtras.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,13 @@ def loads_multi(s:str):
148148
s = s[pos:]
149149

150150
# Cell
151-
def untar_dir(file, dest):
151+
def untar_dir(fname, dest):
152+
"untar `file` into `dest`"
152153
with tempfile.TemporaryDirectory(dir='.') as d:
153154
d = Path(d)
154-
with tarfile.open(mode='r:gz', fileobj=file) as t: t.extractall(d)
155+
with open(fname, 'rb') as f:
156+
with tarfile.open(mode='r:gz', fileobj=f) as t:
157+
t.extractall(d)
155158
next(d.iterdir()).rename(dest)
156159

157160
# Cell

nbs/03_xtras.ipynb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,10 +1007,13 @@
10071007
"outputs": [],
10081008
"source": [
10091009
"#export\n",
1010-
"def untar_dir(file, dest):\n",
1010+
"def untar_dir(fname, dest):\n",
1011+
" \"untar `file` into `dest`\"\n",
10111012
" with tempfile.TemporaryDirectory(dir='.') as d:\n",
10121013
" d = Path(d)\n",
1013-
" with tarfile.open(mode='r:gz', fileobj=file) as t: t.extractall(d)\n",
1014+
" with open(fname, 'rb') as f:\n",
1015+
" with tarfile.open(mode='r:gz', fileobj=f) as t:\n",
1016+
" t.extractall(d)\n",
10141017
" next(d.iterdir()).rename(dest)"
10151018
]
10161019
},
@@ -2067,7 +2070,8 @@
20672070
"Converted 05_transform.ipynb.\n",
20682071
"Converted 07_meta.ipynb.\n",
20692072
"Converted 08_script.ipynb.\n",
2070-
"Converted index.ipynb.\n"
2073+
"Converted index.ipynb.\n",
2074+
"Converted parallel_win.ipynb.\n"
20712075
]
20722076
}
20732077
],

0 commit comments

Comments
 (0)