|
85 | 85 | " symlinks:bool=True, # follow symlinks?\n", |
86 | 86 | " keep_file:callable=noop, # function that returns True for wanted files\n", |
87 | 87 | " keep_folder:callable=noop, # function that returns True for folders to enter\n", |
| 88 | + " skip_folder:callable=noop, # function that returns True for folders to skip\n", |
88 | 89 | " func:callable=os.path.join # function to apply to each matched file\n", |
89 | 90 | "): # Generator of `func` applied to matched files\n", |
90 | 91 | " \"Generator version of `os.walk`, using functions to filter files and folders\"\n", |
91 | 92 | " from copy import copy\n", |
92 | 93 | " for root,dirs,files in os.walk(path, followlinks=symlinks):\n", |
93 | | - " yield from (func(root, name) for name in files if keep_file(root,name))\n", |
| 94 | + " if keep_folder(root,''): yield from (func(root, name) for name in files if keep_file(root,name))\n", |
94 | 95 | " for name in copy(dirs):\n", |
95 | | - " if not keep_folder(root,name): dirs.remove(name)" |
| 96 | + " if skip_folder(root,name): dirs.remove(name)" |
96 | 97 | ] |
97 | 98 | }, |
98 | 99 | { |
|
126 | 127 | " not file_re or file_re.search(name)) and (\n", |
127 | 128 | " not skip_file_glob or not fnmatch(name, skip_file_glob)) and (\n", |
128 | 129 | " not skip_file_re or not skip_file_re.search(name))\n", |
129 | | - " def _keep_folder(root, name):\n", |
130 | | - " return (not folder_re or folder_re.search(name)) and (\n", |
131 | | - " not skip_folder_re or not skip_folder_re.search(name))\n", |
132 | | - " return L(walk(path, symlinks=symlinks, keep_file=_keep_file, keep_folder=_keep_folder, func=func))" |
| 130 | + " def _keep_folder(root, name): return not folder_re or folder_re.search(os.path.join(root,name))\n", |
| 131 | + " def _skip_folder(root, name): return skip_folder_re and skip_folder_re.search(name)\n", |
| 132 | + " return L(walk(path, symlinks=symlinks, keep_file=_keep_file, keep_folder=_keep_folder, skip_folder=_skip_folder, func=func))" |
133 | 133 | ] |
134 | 134 | }, |
135 | 135 | { |
|
140 | 140 | { |
141 | 141 | "data": { |
142 | 142 | "text/plain": [ |
143 | | - "(#9) ['./08_script.ipynb','./04_dispatch.ipynb','./06_docments.ipynb','./01_basics.ipynb','./fastcore/docments.py','./fastcore/dispatch.py','./fastcore/basics.py','./fastcore/docscrape.py','./fastcore/script.py']" |
| 143 | + "(#5) ['./fastcore/docments.py','./fastcore/dispatch.py','./fastcore/basics.py','./fastcore/docscrape.py','./fastcore/script.py']" |
144 | 144 | ] |
145 | 145 | }, |
146 | 146 | "execution_count": null, |
|
633 | 633 | { |
634 | 634 | "data": { |
635 | 635 | "text/plain": [ |
636 | | - "'pip 22.2 from /Users/jhoward/mambaforge/lib/python3.9/site-packages/pip (python 3.9)'" |
| 636 | + "'pip 22.2.1 from /Users/jhoward/mambaforge/lib/python3.9/site-packages/pip (python 3.9)'" |
637 | 637 | ] |
638 | 638 | }, |
639 | 639 | "execution_count": null, |
|
1273 | 1273 | "### ReindexCollection\n", |
1274 | 1274 | "\n", |
1275 | 1275 | "> ReindexCollection (coll, idxs=None, cache=None,\n", |
1276 | | - "> tfm=<functionnoopat0x106121940>)\n", |
| 1276 | + "> tfm=<functionnoopat0x103c44c10>)\n", |
1277 | 1277 | "\n", |
1278 | 1278 | "Reindexes collection `coll` with indices `idxs` and optional LRU cache of size `cache`" |
1279 | 1279 | ], |
|
1523 | 1523 | { |
1524 | 1524 | "data": { |
1525 | 1525 | "text/plain": [ |
1526 | | - "['f', 'g', 'c', 'd', 'h', 'b', 'e', 'a']" |
| 1526 | + "['b', 'c', 'g', 'a', 'h', 'd', 'f', 'e']" |
1527 | 1527 | ] |
1528 | 1528 | }, |
1529 | 1529 | "execution_count": null, |
|
1973 | 1973 | "name": "stdout", |
1974 | 1974 | "output_type": "stream", |
1975 | 1975 | "text": [ |
1976 | | - "Num Events: 5, Freq/sec: 262.4\n", |
1977 | | - "Most recent: ▇▃▁▃▆ 378.3 298.9 195.8 278.2 346.5\n" |
| 1976 | + "Num Events: 4, Freq/sec: 245.3\n", |
| 1977 | + "Most recent: ▃▁▁▁▇ 302.8 255.9 224.8 261.0 372.3\n" |
1978 | 1978 | ] |
1979 | 1979 | } |
1980 | 1980 | ], |
|
2323 | 2323 | "outputs": [], |
2324 | 2324 | "source": [ |
2325 | 2325 | "#|hide\n", |
2326 | | - "from nbdev import nbdev_export\n", |
2327 | | - "nbdev_export()" |
| 2326 | + "import nbdev; nbdev.nbdev_export()" |
2328 | 2327 | ] |
2329 | 2328 | }, |
2330 | 2329 | { |
|
0 commit comments