|
618 | 618 | { |
619 | 619 | "data": { |
620 | 620 | "text/plain": [ |
621 | | - "['d', 'e', 'h', 'g', 'b', 'a', 'c', 'f']" |
| 621 | + "['c', 'b', 'e', 'f', 'g', 'a', 'd', 'h']" |
622 | 622 | ] |
623 | 623 | }, |
624 | 624 | "execution_count": null, |
|
1010 | 1010 | "def untar_dir(fname, dest):\n", |
1011 | 1011 | " \"untar `file` into `dest`\"\n", |
1012 | 1012 | " with tempfile.TemporaryDirectory(dir='.') as d:\n", |
1013 | | - " shutil.unpack_archive(fname, d)\n", |
1014 | | - " ls = Path(d).ls()\n", |
| 1013 | + " out = Path(d)/'out'\n", |
| 1014 | + " out.mkdir()\n", |
| 1015 | + " shutil.unpack_archive(fname, out)\n", |
| 1016 | + " ls = out.ls()\n", |
1015 | 1017 | " if len(ls) == 1: shutil.move(str(ls[0]), dest)\n", |
1016 | | - " else: shutil.move(str(d), dest/remove_suffix(Path(fname).stem, '.tar'))" |
| 1018 | + " else: shutil.move(str(out), dest/remove_suffix(Path(fname).stem, '.tar'))" |
1017 | 1019 | ] |
1018 | 1020 | }, |
1019 | 1021 | { |
|
1295 | 1297 | "outputs": [], |
1296 | 1298 | "source": [ |
1297 | 1299 | "for suf in '.pkl','.bz2','.gz':\n", |
1298 | | - " # delete=False is added for Windows. https://stackoverflow.com/questions/23212435/permission-denied-to-write-to-my-temporary-file\n", |
| 1300 | + " # delete=False is added for Windows\n", |
| 1301 | + " # https://stackoverflow.com/questions/23212435/permission-denied-to-write-to-my-temporary-file\n", |
1299 | 1302 | " with tempfile.NamedTemporaryFile(suffix=suf, delete=False) as f:\n", |
1300 | 1303 | " fn = Path(f.name)\n", |
1301 | 1304 | " save_pickle(fn, 't')\n", |
|
0 commit comments