From: Andreas Monzner Date: Mon, 21 Apr 2008 20:07:35 +0000 (+0000) Subject: speedup resolveFilename a bit X-Git-Tag: 2.6.0~1309 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/3d48300d74e5f41d3db939b088ad41238a90fa88?ds=sidebyside speedup resolveFilename a bit --- diff --git a/lib/python/Tools/Directories.py b/lib/python/Tools/Directories.py index 395402ee..8e7e4d7e 100644 --- a/lib/python/Tools/Directories.py +++ b/lib/python/Tools/Directories.py @@ -71,39 +71,36 @@ def resolveFilename(scope, base = "", path_prefix = None): flags = tmp[1] if flags == PATH_CREATE: - if (not pathExists(path)): + if not pathExists(path): mkdir(path) - #if len(base) > 0 and base[0] == '/': - #path = ("", None) - - if not fileExists(path + base): - #try: - if fallbackPaths.has_key(scope): - for x in fallbackPaths[scope]: - if x[1] == FILE_COPY: - if fileExists(x[0] + base): - system("cp " + x[0] + base + " " + path + base) - break - elif x[1] == FILE_MOVE: - if fileExists(x[0] + base): - system("mv " + x[0] + base + " " + path + base) - break - elif x[1] == PATH_COPY: - if pathExists(x[0]): - if not pathExists(defaultPaths[scope][0]): - mkdir(path) - system("cp -a " + x[0] + "* " + path) - break - elif x[1] == PATH_MOVE: - if pathExists(x[0]): - system("mv " + x[0] + " " + path) - break + fallbackPath = fallbackPaths.get(scope) + + if fallbackPath and not fileExists(path + base): + for x in fallbackPath: + if x[1] == FILE_COPY: + if fileExists(x[0] + base): + system("cp " + x[0] + base + " " + path + base) + break + elif x[1] == FILE_MOVE: + if fileExists(x[0] + base): + system("mv " + x[0] + base + " " + path + base) + break + elif x[1] == PATH_COPY: + if pathExists(x[0]): + if not pathExists(defaultPaths[scope][0]): + mkdir(path) + system("cp -a " + x[0] + "* " + path) + break + elif x[1] == PATH_MOVE: + if pathExists(x[0]): + system("mv " + x[0] + " " + path) + break + # FIXME: we also have to handle DATADIR etc. here. return path + base - # this is only the BASE - an extension must be added later. - + def pathExists(path): return os_path.exists(path)