File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 12
12
Type ,
13
13
Union ,
14
14
)
15
+ import warnings
15
16
16
17
from urllib .parse import urlparse
17
18
from urllib .request import urlopen
@@ -256,11 +257,21 @@ class STAC_IO:
256
257
257
258
@staticmethod
258
259
def read_text_method (uri : str ) -> str :
260
+ warnings .warn (
261
+ "STAC_IO is deprecated. "
262
+ "Please use instances of StacIO (e.g. StacIO.default())." ,
263
+ DeprecationWarning ,
264
+ )
259
265
return StacIO .default ().read_text (uri )
260
266
261
267
@staticmethod
262
268
def write_text_method (uri : str , txt : str ) -> None :
263
269
"""Default method for writing text."""
270
+ warnings .warn (
271
+ "STAC_IO is deprecated. "
272
+ "Please use instances of StacIO (e.g. StacIO.default())." ,
273
+ DeprecationWarning ,
274
+ )
264
275
return StacIO .default ().write_text (uri , txt )
265
276
266
277
@staticmethod
@@ -269,6 +280,11 @@ def stac_object_from_dict(
269
280
href : Optional [str ] = None ,
270
281
root : Optional ["Catalog_Type" ] = None ,
271
282
) -> "STACObject_Type" :
283
+ warnings .warn (
284
+ "STAC_IO is deprecated. "
285
+ "Please use instances of StacIO (e.g. StacIO.default())." ,
286
+ DeprecationWarning ,
287
+ )
272
288
return pystac .serialization .stac_object_from_dict (d , href , root )
273
289
274
290
# This is set in __init__.py
Original file line number Diff line number Diff line change
1
+ import unittest
2
+ import warnings
3
+
4
+ from pystac .stac_io import STAC_IO
5
+ from tests .utils import TestCases
6
+
7
+
8
+ class StacIOTest (unittest .TestCase ):
9
+ def test_stac_io_issues_warnings (self ):
10
+ with warnings .catch_warnings (record = True ) as w :
11
+ # Cause all warnings to always be triggered.
12
+ warnings .simplefilter ("always" )
13
+ # Trigger a warning.
14
+ STAC_IO .read_text (
15
+ TestCases .get_path ("data-files/collections/multi-extent.json" )
16
+ )
17
+
18
+ # Verify some things
19
+ self .assertEqual (len (w ), 1 )
20
+ self .assertTrue (issubclass (w [- 1 ].category , DeprecationWarning ))
You can’t perform that action at this time.
0 commit comments