diff --git a/src/python/dm/common/utility/osUtility.py b/src/python/dm/common/utility/osUtility.py index be6e5937a7ea74d7e6e24eafe9c1e95c11e5b3dd..09c0bd4e12bb84138670f59ba290a12732642c5a 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. """