mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-03-21 18:18:41 +00:00
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.
This commit is contained in:
parent
a6cb9eb6a4
commit
5f7c64b089
@ -72,6 +72,9 @@ class Resource(object):
|
|||||||
self.owner = owner
|
self.owner = owner
|
||||||
|
|
||||||
def match(self, path):
|
def match(self, path):
|
||||||
|
return self.match_path(path)
|
||||||
|
|
||||||
|
def match_path(self, path):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
@ -86,7 +89,7 @@ class File(Resource):
|
|||||||
super(File, self).__init__(owner)
|
super(File, self).__init__(owner)
|
||||||
self.path = path
|
self.path = path
|
||||||
|
|
||||||
def match(self, path):
|
def match_path(self, path):
|
||||||
return self.path == path
|
return self.path == path
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
@ -102,7 +105,7 @@ class Executable(Resource):
|
|||||||
self.abi = abi
|
self.abi = abi
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
|
|
||||||
def match(self, path):
|
def match_path(self, path):
|
||||||
return self.filename == os.path.basename(path)
|
return self.filename == os.path.basename(path)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
@ -118,7 +121,7 @@ class ReventFile(Resource):
|
|||||||
self.stage = stage
|
self.stage = stage
|
||||||
self.target = target
|
self.target = target
|
||||||
|
|
||||||
def match(self, path):
|
def match_path(self, path):
|
||||||
filename = os.path.basename(path)
|
filename = os.path.basename(path)
|
||||||
parts = filename.split('.')
|
parts = filename.split('.')
|
||||||
if len(parts) > 2:
|
if len(parts) > 2:
|
||||||
@ -133,7 +136,7 @@ class JarFile(Resource):
|
|||||||
|
|
||||||
kind = 'jar'
|
kind = 'jar'
|
||||||
|
|
||||||
def match(self, path):
|
def match_path(self, path):
|
||||||
# An owner always has at most one jar file, so
|
# An owner always has at most one jar file, so
|
||||||
# always match
|
# always match
|
||||||
return True
|
return True
|
||||||
@ -154,6 +157,10 @@ class ApkFile(Resource):
|
|||||||
self.exact_abi = exact_abi
|
self.exact_abi = exact_abi
|
||||||
self.supported_abi = supported_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):
|
def match(self, path):
|
||||||
name_matches = True
|
name_matches = True
|
||||||
version_matches = True
|
version_matches = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user