diff --git a/__init__.py b/__init__.py index 208b4a2..c0d93f4 100644 --- a/__init__.py +++ b/__init__.py @@ -62,11 +62,12 @@ __INTERPRETER__ = (3, ) """The Tested Interpreter-Versions""" -def dirlist(path='.', rekursive=True): +def dirlist(path='.', expression='*', rekursive=True): """ Function returning a list of directories below a given path. :param str path: folder which is the basepath for searching files. + :param str expression: expression to fit including shell-style wildcards. It is only used for the first directory level, if rekursive is set to True. :param bool rekursive: search all subfolders if True. :returns: list of filenames including the pathe :rtype: list @@ -82,12 +83,11 @@ def dirlist(path='.', rekursive=True): li = list() if os.path.exists(path): logger.debug('DIRLIST: path (%s) exists - looking for directories to append', path) - for dirname in os.listdir(path): - fulldir = os.path.join(path, dirname) - if os.path.isdir(fulldir): - li.append(fulldir) + for dirname in glob.glob(os.path.join(path, expression)): + if os.path.isdir(dirname): + li.append(dirname) if rekursive: - li.extend(dirlist(fulldir)) + li.extend(dirlist(dirname)) else: logger.warning('DIRLIST: path (%s) does not exist - empty filelist will be returned', path) return li