##// END OF EJS Templates
Make hidden directories configurable
Thomas Kluyver -
Show More
@@ -187,7 +187,7 b' class FileNotebookManager(NotebookManager):'
187 for name in dir_names:
187 for name in dir_names:
188 os_path = self._get_os_path(name, path)
188 os_path = self._get_os_path(name, path)
189 if os.path.isdir(os_path) and not is_hidden(os_path, self.notebook_dir)\
189 if os.path.isdir(os_path) and not is_hidden(os_path, self.notebook_dir)\
190 and not name.startswith('_'):
190 and self.should_list(name):
191 try:
191 try:
192 model = self.get_dir_model(name, path)
192 model = self.get_dir_model(name, path)
193 except IOError:
193 except IOError:
@@ -233,7 +233,8 b' class FileNotebookManager(NotebookManager):'
233 """
233 """
234 path = path.strip('/')
234 path = path.strip('/')
235 notebook_names = self.get_notebook_names(path)
235 notebook_names = self.get_notebook_names(path)
236 notebooks = [self.get_notebook(name, path, content=False) for name in notebook_names]
236 notebooks = [self.get_notebook(name, path, content=False)
237 for name in notebook_names if self.should_list(name)]
237 notebooks = sorted(notebooks, key=sort_key)
238 notebooks = sorted(notebooks, key=sort_key)
238 return notebooks
239 return notebooks
239
240
@@ -17,12 +17,13 b' Authors:'
17 # Imports
17 # Imports
18 #-----------------------------------------------------------------------------
18 #-----------------------------------------------------------------------------
19
19
20 from fnmatch import fnmatch
20 import itertools
21 import itertools
21 import os
22 import os
22
23
23 from IPython.config.configurable import LoggingConfigurable
24 from IPython.config.configurable import LoggingConfigurable
24 from IPython.nbformat import current, sign
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 # Classes
29 # Classes
@@ -36,6 +37,10 b' class NotebookManager(LoggingConfigurable):'
36 def _notary_default(self):
37 def _notary_default(self):
37 return sign.NotebookNotary(parent=self)
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 # NotebookManager API part 1: methods that must be
44 # NotebookManager API part 1: methods that must be
40 # implemented in subclasses.
45 # implemented in subclasses.
41
46
@@ -241,3 +246,6 b' class NotebookManager(LoggingConfigurable):'
241 self.log.warn("Notebook %s/%s is not trusted", path, name)
246 self.log.warn("Notebook %s/%s is not trusted", path, name)
242 self.notary.mark_cells(nb, trusted)
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