Skip to content

Commit

Permalink
test: add missing URI
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-c committed Sep 11, 2023
1 parent d19acef commit df70caf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions cwl_utils/parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,24 +160,27 @@ def load_document_by_uri(
load_all: bool = False,
) -> Any:
"""Load a CWL object from a URI or a path."""
base_uri = ""
real_uri = ""
if isinstance(path, str):
uri = urlparse(path)
id_ = uri.fragment or None
if not uri.scheme or uri.scheme == "file":
real_path = Path(unquote_plus(uri.path)).resolve().as_uri()
real_uri = Path(unquote_plus(uri.path)).resolve().as_uri()
base_uri = Path(unquote_plus(uri.path)).resolve().parent.as_uri()
else:
real_path = path
real_uri = path
base_uri = os.path.dirname(path)
else:
real_path = path.resolve().as_uri()
base_uri = path.resolve().parent.as_uri()
id_ = path.resolve().name.split("#")[1] if "#" in path.resolve().name else None

baseuri = str(real_path)

if loadingOptions is None:
loadingOptions = cwl_v1_2.LoadingOptions(fileuri=baseuri)
loadingOptions = cwl_v1_2.LoadingOptions(fileuri=real_uri, baseuri=base_uri)

doc = loadingOptions.fetcher.fetch_text(real_path)
return load_document_by_string(doc, baseuri, loadingOptions, id_, load_all)
doc = loadingOptions.fetcher.fetch_text(real_uri)
return load_document_by_string(doc, real_uri, loadingOptions, id_, load_all)


def load_document(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_load_document() -> None:
"""Test load_document for a CommandLineTool."""
with open(TEST_v1_0_CWL) as cwl_h:
yaml_obj = yaml.load(cwl_h)
cwl_obj = load_document(yaml_obj)
cwl_obj = load_document(yaml_obj, Path(TEST_v1_0_CWL).resolve().as_uri())
assert cwl_obj.cwlVersion == "v1.0"
assert cwl_obj.inputs[0].id.endswith("input_file")

Expand Down

0 comments on commit df70caf

Please sign in to comment.