Show More
@@ -187,7 +187,7 b' class FileNotebookManager(NotebookManager):' | |||
|
187 | 187 | for name in dir_names: |
|
188 | 188 | os_path = self._get_os_path(name, path) |
|
189 | 189 | if os.path.isdir(os_path) and not is_hidden(os_path, self.notebook_dir)\ |
|
190 |
and |
|
|
190 | and self.should_list(name): | |
|
191 | 191 | try: |
|
192 | 192 | model = self.get_dir_model(name, path) |
|
193 | 193 | except IOError: |
@@ -233,7 +233,8 b' class FileNotebookManager(NotebookManager):' | |||
|
233 | 233 | """ |
|
234 | 234 | path = path.strip('/') |
|
235 | 235 | notebook_names = self.get_notebook_names(path) |
|
236 |
notebooks = [self.get_notebook(name, path, content=False) |
|
|
236 | notebooks = [self.get_notebook(name, path, content=False) | |
|
237 | for name in notebook_names if self.should_list(name)] | |
|
237 | 238 | notebooks = sorted(notebooks, key=sort_key) |
|
238 | 239 | return notebooks |
|
239 | 240 |
@@ -17,12 +17,13 b' Authors:' | |||
|
17 | 17 | # Imports |
|
18 | 18 | #----------------------------------------------------------------------------- |
|
19 | 19 | |
|
20 | from fnmatch import fnmatch | |
|
20 | 21 | import itertools |
|
21 | 22 | import os |
|
22 | 23 | |
|
23 | 24 | from IPython.config.configurable import LoggingConfigurable |
|
24 | 25 | from IPython.nbformat import current, sign |
|
25 | from IPython.utils.traitlets import Instance, Unicode | |
|
26 | from IPython.utils.traitlets import Instance, Unicode, List | |
|
26 | 27 | |
|
27 | 28 | #----------------------------------------------------------------------------- |
|
28 | 29 | # Classes |
@@ -36,6 +37,10 b' class NotebookManager(LoggingConfigurable):' | |||
|
36 | 37 | def _notary_default(self): |
|
37 | 38 | return sign.NotebookNotary(parent=self) |
|
38 | 39 | |
|
40 | hide_globs = List(Unicode, [u'__pycache__'], config=True, help=""" | |
|
41 | Glob patterns to hide in file and directory listings. | |
|
42 | """) | |
|
43 | ||
|
39 | 44 | # NotebookManager API part 1: methods that must be |
|
40 | 45 | # implemented in subclasses. |
|
41 | 46 | |
@@ -241,3 +246,6 b' class NotebookManager(LoggingConfigurable):' | |||
|
241 | 246 | self.log.warn("Notebook %s/%s is not trusted", path, name) |
|
242 | 247 | self.notary.mark_cells(nb, trusted) |
|
243 | 248 | |
|
249 | def should_list(self, name): | |
|
250 | """Should this file/directory name be displayed in a listing?""" | |
|
251 | return not any(fnmatch(name, glob) for glob in self.hide_globs) |
General Comments 0
You need to be logged in to leave comments.
Login now