Merge pull request #2222 from gonguinguen/patch-5
Added followlinks argument to listdir
This commit is contained in:
+3
-2
@@ -148,7 +148,8 @@ def listdir(path,
|
|||||||
add_dirs=False,
|
add_dirs=False,
|
||||||
sort=True,
|
sort=True,
|
||||||
maxnum=None,
|
maxnum=None,
|
||||||
exclude_content_from=None
|
exclude_content_from=None,
|
||||||
|
followlinks=False
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Like `os.listdir()` but you can specify a regex pattern to filter files.
|
Like `os.listdir()` but you can specify a regex pattern to filter files.
|
||||||
@@ -164,7 +165,7 @@ def listdir(path,
|
|||||||
n = 0
|
n = 0
|
||||||
regex = re.compile(expression)
|
regex = re.compile(expression)
|
||||||
items = []
|
items = []
|
||||||
for (root, dirs, files) in os.walk(path, topdown=True):
|
for (root, dirs, files) in os.walk(path, topdown=True, followlinks=followlinks):
|
||||||
for dir in dirs[:]:
|
for dir in dirs[:]:
|
||||||
if dir.startswith('.'):
|
if dir.startswith('.'):
|
||||||
dirs.remove(dir)
|
dirs.remove(dir)
|
||||||
|
|||||||
Reference in New Issue
Block a user