From 2a7b16d61f77cf942c23f503de6fbdf7d87ff1a6 Mon Sep 17 00:00:00 2001 From: Lisandro Date: Fri, 7 Jun 2019 19:21:10 -0300 Subject: [PATCH] Added followlinks argument to listdir The followlinks argument is then used by the function when it calls os.walk(path... Notice the "followlinks" argument of os.walk() is False by default, so this change won't make any difference. Every actual call to listdir() function won't need to be changed. This change is needed to resolve issue #2221 --- gluon/fileutils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gluon/fileutils.py b/gluon/fileutils.py index f6af6fea..764a8e7b 100644 --- a/gluon/fileutils.py +++ b/gluon/fileutils.py @@ -148,7 +148,8 @@ def listdir(path, add_dirs=False, sort=True, 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. @@ -164,7 +165,7 @@ def listdir(path, n = 0 regex = re.compile(expression) 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[:]: if dir.startswith('.'): dirs.remove(dir)