From 5f7c64b08931135c02d57ccc6da1904524ba6e04 Mon Sep 17 00:00:00 2001
From: Sergei Trofimov <sergei.trofimov@arm.com>
Date: Tue, 10 Oct 2017 11:27:09 +0100
Subject: [PATCH] framework/resource: add match_path method

This method is used to partially match a resource; its implementation
cannot rely on the resource file actually being present and must match
against the specified path alone.

match() implementation now defaults to match_path(), as for most
resource types, the path is sufficient to uniquely match a resource.
---
 wa/framework/resource.py | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/wa/framework/resource.py b/wa/framework/resource.py
index ec8d36bc..b137fae9 100644
--- a/wa/framework/resource.py
+++ b/wa/framework/resource.py
@@ -72,6 +72,9 @@ class Resource(object):
         self.owner = owner
 
     def match(self, path):
+        return self.match_path(path)
+
+    def match_path(self, path):
         raise NotImplementedError()
 
     def __str__(self):
@@ -86,7 +89,7 @@ class File(Resource):
         super(File, self).__init__(owner)
         self.path = path
 
-    def match(self, path):
+    def match_path(self, path):
         return self.path == path
 
     def __str__(self):
@@ -102,7 +105,7 @@ class Executable(Resource):
         self.abi = abi
         self.filename = filename
 
-    def match(self, path):
+    def match_path(self, path):
         return self.filename == os.path.basename(path)
 
     def __str__(self):
@@ -118,7 +121,7 @@ class ReventFile(Resource):
         self.stage = stage
         self.target = target
 
-    def match(self, path):
+    def match_path(self, path):
         filename = os.path.basename(path)
         parts = filename.split('.')
         if len(parts) > 2:
@@ -133,7 +136,7 @@ class JarFile(Resource):
 
     kind = 'jar'
 
-    def match(self, path):
+    def match_path(self, path):
         # An owner always  has at most one jar file, so
         # always match
         return True
@@ -154,6 +157,10 @@ class ApkFile(Resource):
         self.exact_abi = exact_abi
         self.supported_abi = supported_abi
 
+    def match_path(self, path):
+        ext = os.path.splitext(path)[1].lower()
+        return ext == '.apk'
+
     def match(self, path):
         name_matches = True
         version_matches = True