summaryrefslogtreecommitdiffstats
path: root/vnftest/common/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'vnftest/common/utils.py')
-rw-r--r--vnftest/common/utils.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/vnftest/common/utils.py b/vnftest/common/utils.py
index 882403f..dfd32d5 100644
--- a/vnftest/common/utils.py
+++ b/vnftest/common/utils.py
@@ -475,7 +475,6 @@ def load_resource(path, mode="r"):
try:
return open(path, mode)
except Exception:
- logger.info("path not loaded as file, trying load as package")
split_path = os.path.split(path)
package = split_path[0].replace("/", ".")
if not pkg_resources.resource_exists(package, split_path[1]):
@@ -483,6 +482,18 @@ def load_resource(path, mode="r"):
return pkg_resources.resource_stream(package, split_path[1])
+def resource_abs_path(path, mode="r"):
+ try:
+ open(path, mode)
+ return path
+ except Exception:
+ split_path = os.path.split(path)
+ package = split_path[0].replace("/", ".")
+ if not pkg_resources.resource_exists(package, split_path[1]):
+ raise ResourceNotFound(resource=path)
+ return pkg_resources.resource_filename(package, split_path[1])
+
+
def format(in_obj, params):
if isinstance(in_obj, list):
ret_list = []