From 04e5d99a40b9558f05ba580ab60ca2fe3799c3d8 Mon Sep 17 00:00:00 2001 From: jpike Date: Tue, 3 Dec 2024 09:01:41 -0500 Subject: [PATCH] Check if file path is relative or abs before changing If the path is already an abs path, do not update it. Change-Id: I9ac305c76c91dc2c8a3c62e999bba28aa1389a56 --- framework/resources/resource_finder.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/framework/resources/resource_finder.py b/framework/resources/resource_finder.py index 73cb731..d4baf5c 100644 --- a/framework/resources/resource_finder.py +++ b/framework/resources/resource_finder.py @@ -1,5 +1,6 @@ # This utility file contains functions to help the code find the path to resource files # when starlingx gets used as a submodule, or from outside code. +import os.path from pathlib import Path @@ -18,6 +19,9 @@ def get_stx_resource_path(relative_path: str) -> str: will return /home/user/repo/starlingx/framework/resources/resource_finder.py """ + # check to see if the path really is relative, if not just return the path + if os.path.isabs(relative_path): + return relative_path path_of_this_file = Path(__file__) root_folder_of_stx = path_of_this_file.parent.parent.parent path_to_resource = f"{str(root_folder_of_stx)}/{relative_path}"