From db62448f00d4fe983d849ab698d1f348386c0dfe Mon Sep 17 00:00:00 2001
From: "benjamin.jakimow" <benjamin.jakimow@geo.hu-berlin.de>
Date: Fri, 11 May 2018 15:36:23 +0200
Subject: [PATCH] file_search now with option directories=True

---
 timeseriesviewer/utils.py | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/timeseriesviewer/utils.py b/timeseriesviewer/utils.py
index 7571f86c..1d99772a 100644
--- a/timeseriesviewer/utils.py
+++ b/timeseriesviewer/utils.py
@@ -58,12 +58,25 @@ def qgisInstance():
         return None
 
 
-def file_search(rootdir, pattern, recursive=False, ignoreCase=False):
+def file_search(rootdir, pattern, recursive=False, ignoreCase=False, directories=False):
+    """
+    Searches for files
+    :param rootdir: root directory to search for files.
+    :param pattern: wildcard ("my*files.*") or regular expression to describe the file name.
+    :param recursive: set True to search recursively.
+    :param ignoreCase: set True to ignore character case.
+    :param directories: set True to search for directories instead of files.
+    :return: [list-of-paths]
+    """
     assert os.path.isdir(rootdir), "Path is not a directory:{}".format(rootdir)
     regType = type(re.compile('.*'))
     results = []
 
     for root, dirs, files in os.walk(rootdir):
+
+        if directories:
+            files = dirs
+
         for file in files:
             if isinstance(pattern, regType):
                 if pattern.search(file):
-- 
GitLab