From e77cd66148b89441a201b9b474fb08083accb62e Mon Sep 17 00:00:00 2001
From: Sinisa Veseli <sveseli@aps.anl.gov>
Date: Tue, 26 Jan 2016 03:55:14 +0000
Subject: [PATCH] add function to find files and return dict format

---
 src/python/dm/common/utility/osUtility.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/python/dm/common/utility/osUtility.py b/src/python/dm/common/utility/osUtility.py
index be6e5937..09c0bd4e 100755
--- a/src/python/dm/common/utility/osUtility.py
+++ b/src/python/dm/common/utility/osUtility.py
@@ -103,6 +103,25 @@ class OsUtility:
                     fList = cls.findFiles(fullPath, fList)
         return fList
 
+    @classmethod
+    def findFilesAsDict(cls, dirPath, fileDict=None):
+        """ Find files in a given directory. Return dictionary of 
+            absolute paths.
+            Do not follow symbolic links.
+        """
+        fDict = fileDict
+        if not fDict:
+            fDict = {}
+        if os.path.isdir(dirPath):
+            files = os.listdir(dirPath)
+            for f in files:
+                fullPath = os.path.join(dirPath, f)
+                if os.path.isfile(fullPath):
+                    fDict[fullPath] = os.stat(fullPath)
+                elif os.path.isdir(fullPath):
+                    fDict = cls.findFilesAsDict(fullPath, fDict)
+        return fDict
+
     @classmethod
     def importNameFromFile(cls, name, filePath):
         """ Import specified name from file. """
-- 
GitLab