diff env/lib/python3.7/site-packages/planemo/test/data.py @ 2:6af9afd405e9 draft

"planemo upload commit 0a63dd5f4d38a1f6944587f52a8cd79874177fc1"
author shellac
date Thu, 14 May 2020 14:56:58 -0400
parents 26e78fe6e8c4
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/env/lib/python3.7/site-packages/planemo/test/data.py	Thu May 14 14:56:58 2020 -0400
@@ -0,0 +1,37 @@
+"""Utilities related to reasoning about test data."""
+
+import os
+
+
+def find_test_data_directory(tool_paths, **kwds):
+    path = "."
+    if len(tool_paths) > 0:
+        path = tool_paths[0]
+
+    # Find test data directory associated with path.
+    test_data = kwds.get("test_data", None)
+    if test_data:
+        return os.path.abspath(test_data)
+    else:
+        test_data = search_tool_path_for(path, "test-data")
+        if test_data:
+            return test_data
+
+
+def search_tool_path_for(path, target, extra_paths=[]):
+    """Check for presence of a target in different artifact directories."""
+    if not os.path.isdir(path):
+        tool_dir = os.path.dirname(path)
+    else:
+        tool_dir = path
+    possible_dirs = [tool_dir, "."] + extra_paths
+    for possible_dir in possible_dirs:
+        possible_path = os.path.join(possible_dir, target)
+        if os.path.exists(possible_path):
+            return os.path.abspath(possible_path)
+    return None
+
+
+__all__ = (
+    "search_tool_path_for",
+)