diff --git a/IPython/html/services/notebooks/filenbmanager.py b/IPython/html/services/notebooks/filenbmanager.py
index 8d4d68a..c3b2c05 100644
--- a/IPython/html/services/notebooks/filenbmanager.py
+++ b/IPython/html/services/notebooks/filenbmanager.py
@@ -182,7 +182,8 @@ class FileNotebookManager(NotebookManager):
dirs = []
for name in dir_names:
os_path = self._get_os_path(name, path)
- if os.path.isdir(os_path) and not is_hidden(os_path, self.notebook_dir):
+ if os.path.isdir(os_path) and not is_hidden(os_path, self.notebook_dir)\
+ and not name.startswith('_'):
try:
model = self.get_dir_model(name, path)
except IOError:
diff --git a/IPython/html/services/notebooks/tests/test_notebooks_api.py b/IPython/html/services/notebooks/tests/test_notebooks_api.py
index 5ac0cb1..ce90d53 100644
--- a/IPython/html/services/notebooks/tests/test_notebooks_api.py
+++ b/IPython/html/services/notebooks/tests/test_notebooks_api.py
@@ -26,6 +26,9 @@ from IPython.utils.data import uniq_stable
def notebooks_only(nb_list):
return [nb for nb in nb_list if nb['type']=='notebook']
+def dirs_only(nb_list):
+ return [x for x in nb_list if x['type']=='directory']
+
class NBAPI(object):
"""Wrapper for notebook API calls."""
@@ -100,14 +103,16 @@ class APITest(NotebookTestBase):
('foo/bar', 'baz'),
(u'å b', u'ç d')
]
+ hidden_dirs = ['.hidden', '__pycache__']
dirs = uniq_stable([d for (d,n) in dirs_nbs])
del dirs[0] # remove ''
+ top_level_dirs = {d.split('/')[0] for d in dirs}
def setUp(self):
nbdir = self.notebook_dir.name
- for d in self.dirs:
+ for d in (self.dirs + self.hidden_dirs):
d.replace('/', os.sep)
if not os.path.isdir(pjoin(nbdir, d)):
os.mkdir(pjoin(nbdir, d))
@@ -124,7 +129,7 @@ class APITest(NotebookTestBase):
def tearDown(self):
nbdir = self.notebook_dir.name
- for dname in ['foo', 'Directory with spaces in', u'unicodé', u'å b']:
+ for dname in (list(self.top_level_dirs) + self.hidden_dirs):
shutil.rmtree(pjoin(nbdir, dname), ignore_errors=True)
if os.path.isfile(pjoin(nbdir, 'inroot.ipynb')):
@@ -156,6 +161,11 @@ class APITest(NotebookTestBase):
expected = { normalize('NFC', name) for name in expected }
self.assertEqual(nbnames, expected)
+ def test_list_dirs(self):
+ dirs = dirs_only(self.nb_api.list().json())
+ dir_names = {d['name'] for d in dirs}
+ self.assertEqual(dir_names, self.top_level_dirs) # Excluding hidden dirs
+
def test_list_nonexistant_dir(self):
with assert_http_error(404):
self.nb_api.list('nonexistant')