Skip to content

Commit

Permalink
Add more print debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
jsignell committed Jan 10, 2025
1 parent 8c35501 commit d34dc2d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 2 additions & 1 deletion pystac/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def get_href(self, transform_href: bool = True) -> str | None:
href = self._target_object.get_self_href()
else:
href = self._target_href
print("starting href:", href)

if (
transform_href
Expand All @@ -191,7 +192,7 @@ def get_href(self, transform_href: bool = True) -> str | None:
owner_href = self.owner.get_self_href()
if owner_href is not None:
href = make_relative_href(href, owner_href)

print("new href:", href)
return href

@property
Expand Down
2 changes: 0 additions & 2 deletions pystac/stac_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,6 @@ def read_text_from_href(self, href: str) -> str:
raise Exception(f"Could not read uri {href}") from e
else:
href = safe_urlparse(href).path
if href.startswith("/D:/"):
href = href[1:]
with open(href, encoding="utf-8") as f:
href_contents = f.read()
return href_contents
Expand Down
11 changes: 6 additions & 5 deletions pystac/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def safe_urlparse(href: str) -> URLParseResult:
and not href.lower().startswith(f"{parsed.scheme}://")
)
):
return URLParseResult(
output = URLParseResult(
scheme="",
netloc="",
path="{}:{}".format(
Expand All @@ -73,15 +73,19 @@ def safe_urlparse(href: str) -> URLParseResult:
query=parsed.query,
fragment=parsed.fragment,
)
print("non-file scheme gives:", output.path)
return output
if parsed.scheme == "file" and parsed.netloc:
return URLParseResult(
output = URLParseResult(

Check warning on line 79 in pystac/utils.py

View check run for this annotation

Codecov / codecov/patch

pystac/utils.py#L79

Added line #L79 was not covered by tests
scheme=parsed.scheme,
netloc="",
path=f"{parsed.netloc}{parsed.path}",
params=parsed.params,
query=parsed.query,
fragment=parsed.fragment,
)
print("file scheme gives:", output.path)
return output

Check warning on line 88 in pystac/utils.py

View check run for this annotation

Codecov / codecov/patch

pystac/utils.py#L87-L88

Added lines #L87 - L88 were not covered by tests
else:
return parsed

Expand Down Expand Up @@ -215,10 +219,7 @@ def _make_relative_href_path(
# posixpath doesn't play well with windows drive letters, so we have to use
# the os-specific path library for the relpath function. This means we can
# only handle windows paths on windows machines.
print("start_dir: ", start_dir)
print("source_path:", source_path)
relpath = make_posix_style(os.path.relpath(source_path, start_dir))
print("relpath:", relpath)

# Ensure we retain a trailing slash from the original source path
if parsed_source.path.endswith("/"):
Expand Down

0 comments on commit d34dc2d

Please sign in to comment.