From fed454fc7401cf54b0fb6d7c9c69d92f62897376 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Tue, 28 Mar 2017 09:44:24 +0100 Subject: [PATCH] getters: fix some issues - get_by_extension was comparing the expected extension to the entire tuple returned by os.path.splitext(), rather than just the extension part. - UserDirectory getter was looking in the root dependencies directory, rather than the subdirectory for the owner. - Filer getter was not handling non-existing paths properly. --- wa/framework/getters.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/wa/framework/getters.py b/wa/framework/getters.py index 9ce5f94e..651ca5a2 100644 --- a/wa/framework/getters.py +++ b/wa/framework/getters.py @@ -52,7 +52,7 @@ def get_by_extension(path, ext): found = [] for entry in os.listdir(path): - entry_ext = os.path.splitext(entry) + entry_ext = os.path.splitext(entry)[1] if entry_ext == ext: found.append(os.path.join(path, entry)) return found @@ -112,7 +112,8 @@ class UserDirectory(ResourceGetter): def get(self, resource): basepath = settings.dependencies_directory - return get_from_location(basepath, resource) + directory = _d(os.path.join(basepath, resource.owner.name)) + return get_from_location(directory, resource) class Http(ResourceGetter): @@ -318,7 +319,9 @@ class Filer(ResourceGetter): result = get_from_location(local_path, resource) if result: return result - if remote_path: + if not os.path.exists(local_path): + return None + if os.path.exists(remote_path): # Didn't find it cached locally; now check the remoted result = get_from_location(remote_path, resource) if not result: