The root directory of the notebook server should never be hidden (#2907)

* The root directory of the notebook server should never be hidden

Closes gh-2382

* Test that root dir is not hidden
Thomas Kluyver 9 years ago committed by Grant Nestor
parent 43a97807fc
commit 12592ef3bb

@ -61,10 +61,14 @@ def test_is_hidden():
os.makedirs(subdir1)
nt.assert_equal(is_hidden(subdir1, root), False)
nt.assert_equal(is_file_hidden(subdir1), False)
subdir2 = os.path.join(root, '.subdir2')
os.makedirs(subdir2)
nt.assert_equal(is_hidden(subdir2, root), True)
nt.assert_equal(is_file_hidden(subdir2), True)
nt.assert_equal(is_file_hidden(subdir2), True)#
# root dir is always visible
nt.assert_equal(is_hidden(subdir2, subdir2), False)
subdir34 = os.path.join(root, 'subdir3', '.subdir4')
os.makedirs(subdir34)
nt.assert_equal(is_hidden(subdir34, root), True)

@ -173,6 +173,10 @@ def is_hidden(abs_path, abs_root=''):
determined by either name starting with '.' or the UF_HIDDEN flag as
reported by stat.
If abs_path is the same directory as abs_root, it will be visible even if
that is a hidden folder. This only checks the visibility of files
and directories *within* abs_root.
Parameters
----------
abs_path : unicode
@ -181,6 +185,9 @@ def is_hidden(abs_path, abs_root=''):
The absolute path of the root directory in which hidden directories
should be checked for.
"""
if os.path.normpath(abs_path) == os.path.normpath(abs_root):
return False
if is_file_hidden(abs_path):
return True

Loading…
Cancel
Save