File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -61,10 +61,14 @@ def test_is_hidden():
61
61
os .makedirs (subdir1 )
62
62
nt .assert_equal (is_hidden (subdir1 , root ), False )
63
63
nt .assert_equal (is_file_hidden (subdir1 ), False )
64
+
64
65
subdir2 = os .path .join (root , '.subdir2' )
65
66
os .makedirs (subdir2 )
66
67
nt .assert_equal (is_hidden (subdir2 , root ), True )
67
- nt .assert_equal (is_file_hidden (subdir2 ), True )
68
+ nt .assert_equal (is_file_hidden (subdir2 ), True )#
69
+ # root dir is always visible
70
+ nt .assert_equal (is_hidden (subdir2 , subdir2 ), False )
71
+
68
72
subdir34 = os .path .join (root , 'subdir3' , '.subdir4' )
69
73
os .makedirs (subdir34 )
70
74
nt .assert_equal (is_hidden (subdir34 , root ), True )
Original file line number Diff line number Diff line change @@ -173,6 +173,10 @@ def is_hidden(abs_path, abs_root=''):
173
173
determined by either name starting with '.' or the UF_HIDDEN flag as
174
174
reported by stat.
175
175
176
+ If abs_path is the same directory as abs_root, it will be visible even if
177
+ that is a hidden folder. This only checks the visibility of files
178
+ and directories *within* abs_root.
179
+
176
180
Parameters
177
181
----------
178
182
abs_path : unicode
@@ -181,6 +185,9 @@ def is_hidden(abs_path, abs_root=''):
181
185
The absolute path of the root directory in which hidden directories
182
186
should be checked for.
183
187
"""
188
+ if os .path .normpath (abs_path ) == os .path .normpath (abs_root ):
189
+ return False
190
+
184
191
if is_file_hidden (abs_path ):
185
192
return True
186
193
You can’t perform that action at this time.
0 commit comments