From 255de3d3615ff181b45172e184ef763c86081952 Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Wed, 30 Nov 2016 11:40:03 +0100 Subject: [PATCH] Use os.path.relpath in place of string.replace There is a standard library function for that! Change-Id: If1de6e38c35c9c5f0fa28b756724e91daf12a776 --- horizon/utils/file_discovery.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/horizon/utils/file_discovery.py b/horizon/utils/file_discovery.py index 00e0ff370..b5784b5d1 100644 --- a/horizon/utils/file_discovery.py +++ b/horizon/utils/file_discovery.py @@ -28,7 +28,7 @@ def discover_files(base_path, sub_path='', ext='', trim_base_path=False): file_list = [] for root, dirs, files in walk(path.join(base_path, sub_path)): if trim_base_path: - root = root.replace(base_path, '', 1) + root = path.relpath(root, base_path) file_list.extend([path.join(root, file_name) for file_name in files if file_name.endswith(ext)])