Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion notebook/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions notebook/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down