Skip to content

Commit 9b95c35

Browse files
committed
Split default IO down into to/from href methods
This allows subclasses of DefaultStacIO to not have to re-impelment link resolution if they don't want to.
1 parent 61f62b1 commit 9b95c35

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pystac/stac_io.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ def read_text(
176176
href = source.get_absolute_href()
177177
if href is None:
178178
raise IOError(f"Could not get an absolute HREF from link {source}")
179+
return self.read_text_from_href(href, *args, **kwargs)
179180

181+
def read_text_from_href(self, href: str, *args: Any, **kwargs: Any) -> str:
180182
parsed = urlparse(href)
181183
if parsed.scheme != "":
182184
try:
@@ -197,7 +199,11 @@ def write_text(
197199
href = dest.get_absolute_href()
198200
if href is None:
199201
raise IOError(f"Could not get an absolute HREF from link {dest}")
202+
return self.write_text_to_href(href, txt, *args, **kwargs)
200203

204+
def write_text_to_href(
205+
self, href: str, txt: str, *args: Any, **kwargs: Any
206+
) -> None:
201207
dirname = os.path.dirname(href)
202208
if dirname != "" and not os.path.isdir(dirname):
203209
os.makedirs(dirname)

0 commit comments

Comments
 (0)