@@ -1098,26 +1098,39 @@ def vectors_async(self, get_query_payload=False,
1098
1098
1099
1099
# ---------------------------------- parser functions
1100
1100
1101
- def _parse_horizons (self , src ):
1101
+ def _parse_result (self , response , verbose = None ):
1102
1102
"""
1103
- Routine for parsing data from JPL Horizons
1103
+ Parse query result to a `~astropy.table.Table` object.
1104
1104
1105
1105
1106
1106
Parameters
1107
1107
----------
1108
1108
1109
- src : list
1110
- raw response from server
1109
+ response : `~requests.Response`
1110
+ Response from server.
1111
1111
1112
1112
1113
1113
Returns
1114
1114
-------
1115
1115
1116
- data : `astropy.Table`
1116
+ data : `~ astropy.table .Table`
1117
1117
1118
1118
"""
1119
1119
1120
- self .raw_response = src
1120
+ self .last_response = response
1121
+ try :
1122
+ response .raise_for_status ()
1123
+ except HTTPError :
1124
+ # don't cache any HTTP errored queries (especially when the API is down!)
1125
+ try :
1126
+ self ._last_query .remove_cache_file (self .cache_location )
1127
+ except OSError :
1128
+ # this is allowed: if `cache` was set to False, this
1129
+ # won't be needed
1130
+ pass
1131
+ raise
1132
+
1133
+ self .raw_response = response .text
1121
1134
1122
1135
# return raw response, if desired
1123
1136
if self .return_raw :
@@ -1126,7 +1139,7 @@ def _parse_horizons(self, src):
1126
1139
return self .raw_response
1127
1140
1128
1141
# split response by line break
1129
- src = src .split ('\n ' )
1142
+ src = response . text .split ('\n ' )
1130
1143
1131
1144
data_start_idx = 0
1132
1145
data_end_idx = 0
@@ -1315,43 +1328,6 @@ def _parse_horizons(self, src):
1315
1328
1316
1329
return data
1317
1330
1318
- def _parse_result (self , response , verbose = None ):
1319
- """
1320
- Routine for managing parser calls;
1321
-
1322
- This routine decides based on `self.query_type` which parser
1323
- has to be used.
1324
-
1325
-
1326
- Parameters
1327
- ----------
1328
-
1329
- response : string
1330
- raw response from server
1331
-
1332
-
1333
- Returns
1334
- -------
1335
-
1336
- data : `astropy.Table`
1337
-
1338
- """
1339
-
1340
- self .last_response = response
1341
- try :
1342
- response .raise_for_status ()
1343
- except HTTPError :
1344
- # don't cache any HTTP errored queries (especially when the API is down!)
1345
- try :
1346
- self ._last_query .remove_cache_file (self .cache_location )
1347
- except OSError :
1348
- # this is allowed: if `cache` was set to False, this
1349
- # won't be needed
1350
- pass
1351
- raise
1352
- data = self ._parse_horizons (response .text )
1353
- return data
1354
-
1355
1331
1356
1332
# the default tool for users to interact with is an instance of the Class
1357
1333
Horizons = HorizonsClass ()
0 commit comments