mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-31 10:11:17 +00:00
AndroidDevice: Add a common_base_path utility function
Adds a utility function to determine the lowest common base path of a passed list of files.
This commit is contained in:
parent
b10b5970c3
commit
b1da0fe958
@ -848,3 +848,16 @@ def memoized(func):
|
||||
return __memo_cache[id_string]
|
||||
|
||||
return memoize_wrapper
|
||||
|
||||
|
||||
def commonprefix(file_list, sep=os.sep):
|
||||
"""
|
||||
Find the lowest common base folder of a passed list of files.
|
||||
"""
|
||||
common_path = os.path.commonprefix(file_list)
|
||||
cp_split = common_path.split(sep)
|
||||
other_split = file_list[0].split(sep)
|
||||
last = len(cp_split) - 1
|
||||
if cp_split[last] != other_split[last]:
|
||||
cp_split = cp_split[:-1]
|
||||
return sep.join(cp_split)
|
||||
|
Loading…
x
Reference in New Issue
Block a user