Skip to content

Commit 3011a1d

Browse files
committed
Emit deprecation warnings for deprecated request classes
1 parent 2db5b61 commit 3011a1d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/spacetrack/base.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343

4444
BASE_URL = "https://www.space-track.org/"
4545

46+
REQUEST_CLASS_DEPRECATION_MSG = (
47+
"The {class_} request class is deprecated and scheduled to be "
48+
"removed. Visit https://www.space-track.org for more information."
49+
)
50+
4651

4752
class AuthenticationError(Exception):
4853
"""Space-Track authentication error."""
@@ -242,6 +247,14 @@ class SpaceTrackClient:
242247
("dirs", "publicfiles"): set(),
243248
("download", "publicfiles"): set(),
244249
}
250+
deprecated_controllers = {
251+
"basicspacedata": {
252+
"tle",
253+
"tle_latest",
254+
"tle_publish",
255+
"omm",
256+
},
257+
}
245258
param_fields = {
246259
("download", "publicfiles"): {"name"},
247260
}
@@ -440,6 +453,16 @@ def _generic_request_generator(
440453
valid_params = self.param_fields.get((class_, controller), set())
441454
params = dict()
442455

456+
if (
457+
controller in self.deprecated_controllers
458+
and class_ in self.deprecated_controllers[controller]
459+
):
460+
warnings.warn(
461+
REQUEST_CLASS_DEPRECATION_MSG.format(class_=class_),
462+
DeprecationWarning,
463+
stacklevel=4,
464+
)
465+
443466
url = f"{controller}/query/class/{class_}"
444467

445468
for key, value in kwargs.items():

0 commit comments

Comments
 (0)