Skip to content

Commit e5cbe11

Browse files
committed
Make utils._is_url private
1 parent 86c6055 commit e5cbe11

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- Update migrate code to handle license changes in STAC spec 1.1.0 ([#1491](https://github.com/stac-utils/pystac/pull/1491))
1818
- Allow links to have `file://` prefix - but don't write them that way by default ([#1489](https://github.com/stac-utils/pystac/pull/1489))
1919
- Raise `STACError` with message when a link is expected to resolve to a STAC object but doesn't ([#1500](https://github.com/stac-utils/pystac/pull/1500))
20+
- Raise an error on APILayoutStrategy when root_href is non-url ([#1498](https://github.com/stac-utils/pystac/pull/1498))
2021

2122
### Fixed
2223

pystac/catalog.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
from pystac.utils import (
3232
HREF,
3333
StringEnum,
34+
_is_url,
3435
is_absolute_href,
35-
is_url,
3636
make_absolute_href,
3737
make_relative_href,
3838
)
@@ -771,7 +771,7 @@ def normalize_hrefs(
771771
if not is_absolute_href(root_href):
772772
root_href = make_absolute_href(root_href, os.getcwd(), start_is_dir=True)
773773

774-
if isinstance(_strategy, APILayoutStrategy) and not is_url(root_href):
774+
if isinstance(_strategy, APILayoutStrategy) and not _is_url(root_href):
775775
raise STACError("When using APILayoutStrategy the root_href must be a URL")
776776

777777
def process_item(

pystac/stac_io.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
merge_common_properties,
1717
migrate_to_latest,
1818
)
19-
from pystac.utils import HREF, is_url, safe_urlparse
19+
from pystac.utils import HREF, _is_url, safe_urlparse
2020

2121
# Use orjson if available
2222
try:
@@ -294,7 +294,7 @@ def read_text_from_href(self, href: str) -> str:
294294
href : The URI of the file to open.
295295
"""
296296
href_contents: str
297-
if is_url(href):
297+
if _is_url(href):
298298
try:
299299
logger.debug(f"GET {href} Headers: {self.headers}")
300300
req = Request(href, headers=self.headers)
@@ -328,7 +328,7 @@ def write_text_to_href(self, href: str, txt: str) -> None:
328328
href : The path to which the file will be written.
329329
txt : The string content to write to the file.
330330
"""
331-
if is_url(href):
331+
if _is_url(href):
332332
raise NotImplementedError("DefaultStacIO cannot write to urls")
333333
href = safe_urlparse(href).path
334334
dirname = os.path.dirname(href)
@@ -429,7 +429,7 @@ def read_text_from_href(self, href: str) -> str:
429429
Args:
430430
href : The URI of the file to open.
431431
"""
432-
if is_url(href):
432+
if _is_url(href):
433433
# TODO provide a pooled StacIO to enable more efficient network
434434
# access (probably named `PooledStacIO`).
435435
http = PoolManager()

pystac/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ def is_file_path(href: str) -> bool:
608608
return bool(os.path.splitext(parsed.path)[1])
609609

610610

611-
def is_url(href: str) -> bool:
611+
def _is_url(href: str) -> bool:
612+
"""Checks if an HREF is a url rather than a local path"""
612613
parsed = safe_urlparse(href)
613614
return parsed.scheme not in ["", "file"]

0 commit comments

Comments
 (0)