23
23
import httplib
24
24
import mimetypes
25
25
import time
26
-
27
26
from astroquery .utils .tap .xmlparser import utils
28
27
from astroquery .utils .tap import taputils
29
28
from astroquery import version
@@ -41,7 +40,7 @@ class TapConn:
41
40
"""
42
41
43
42
def __init__ (self , ishttps ,
44
- host ,
43
+ host , * ,
45
44
server_context = None ,
46
45
port = 80 ,
47
46
sslport = 443 ,
@@ -142,7 +141,7 @@ def __get_data_context(self, encodedData=None):
142
141
else :
143
142
return self .__dataContext
144
143
145
- def __get_datalink_context (self , subContext , encodedData = None ):
144
+ def __get_datalink_context (self , subContext , * , encodedData = None ):
146
145
if self .__datalinkContext is None :
147
146
raise ValueError ("datalink_context must be specified at TAP "
148
147
+ "object creation for this action to be "
@@ -170,7 +169,7 @@ def __get_table_edit_context(self):
170
169
def __get_server_context (self , subContext ):
171
170
return f"{ self .__serverContext } /{ subContext } "
172
171
173
- def execute_tapget (self , subcontext , verbose = False ):
172
+ def execute_tapget (self , subcontext , * , verbose = False ):
174
173
"""Executes a TAP GET request
175
174
The connection is done through HTTP or HTTPS depending on the login
176
175
status (logged in -> HTTPS)
@@ -189,12 +188,12 @@ def execute_tapget(self, subcontext, verbose=False):
189
188
"""
190
189
if subcontext .startswith ("http" ):
191
190
# absolute url
192
- return self .__execute_get (subcontext , verbose )
191
+ return self .__execute_get (subcontext , verbose = verbose )
193
192
else :
194
193
context = self .__get_tap_context (subcontext )
195
- return self .__execute_get (context , verbose )
194
+ return self .__execute_get (context , verbose = verbose )
196
195
197
- def execute_dataget (self , query , verbose = False ):
196
+ def execute_dataget (self , query , * , verbose = False ):
198
197
"""Executes a data GET request
199
198
The connection is done through HTTP or HTTPS depending on the login
200
199
status (logged in -> HTTPS)
@@ -213,7 +212,7 @@ def execute_dataget(self, query, verbose=False):
213
212
context = self .__get_data_context (query )
214
213
return self .__execute_get (context , verbose )
215
214
216
- def execute_datalinkget (self , subcontext , query , verbose = False ):
215
+ def execute_datalinkget (self , subcontext , query , * , verbose = False ):
217
216
"""Executes a datalink GET request
218
217
The connection is done through HTTP or HTTPS depending on the login
219
218
status (logged in -> HTTPS)
@@ -234,8 +233,8 @@ def execute_datalinkget(self, subcontext, query, verbose=False):
234
233
context = self .__get_datalink_context (subcontext , query )
235
234
return self .__execute_get (context , verbose )
236
235
237
- def __execute_get (self , context , verbose = False ):
238
- conn = self .__get_connection (verbose )
236
+ def __execute_get (self , context , * , verbose = False ):
237
+ conn = self .__get_connection (verbose = verbose )
239
238
if verbose :
240
239
print (f"host = { conn .host } :{ conn .port } " )
241
240
print (f"context = { context } " )
@@ -246,7 +245,7 @@ def __execute_get(self, context, verbose=False):
246
245
return response
247
246
248
247
def execute_tappost (self , subcontext , data ,
249
- content_type = CONTENT_TYPE_POST_DEFAULT ,
248
+ content_type = CONTENT_TYPE_POST_DEFAULT , * ,
250
249
verbose = False ):
251
250
"""Executes a POST request
252
251
The connection is done through HTTP or HTTPS depending on the login
@@ -269,10 +268,10 @@ def execute_tappost(self, subcontext, data,
269
268
An HTTP(s) response object
270
269
"""
271
270
context = self .__get_tap_context (subcontext )
272
- return self .__execute_post (context , data , content_type , verbose )
271
+ return self .__execute_post (context , data , content_type , verbose = verbose )
273
272
274
273
def execute_datapost (self , data ,
275
- content_type = CONTENT_TYPE_POST_DEFAULT ,
274
+ content_type = CONTENT_TYPE_POST_DEFAULT , * ,
276
275
verbose = False ):
277
276
"""Executes a POST request
278
277
The connection is done through HTTP or HTTPS depending on the login
@@ -292,10 +291,10 @@ def execute_datapost(self, data,
292
291
An HTTP(s) response object
293
292
"""
294
293
context = self .__get_data_context ()
295
- return self .__execute_post (context , data , content_type , verbose )
294
+ return self .__execute_post (context , data , content_type , verbose = verbose )
296
295
297
296
def execute_datalinkpost (self , subcontext , data ,
298
- content_type = CONTENT_TYPE_POST_DEFAULT ,
297
+ content_type = CONTENT_TYPE_POST_DEFAULT , * ,
299
298
verbose = False ):
300
299
"""Executes a POST request
301
300
The connection is done through HTTP or HTTPS depending on the login
@@ -318,10 +317,10 @@ def execute_datalinkpost(self, subcontext, data,
318
317
An HTTP(s) response object
319
318
"""
320
319
context = self .__get_datalink_context (subcontext )
321
- return self .__execute_post (context , data , content_type , verbose )
320
+ return self .__execute_post (context , data , content_type , verbose = verbose )
322
321
323
322
def execute_upload (self , data ,
324
- content_type = CONTENT_TYPE_POST_DEFAULT ,
323
+ content_type = CONTENT_TYPE_POST_DEFAULT , * ,
325
324
verbose = False ):
326
325
"""Executes a POST upload request
327
326
The connection is done through HTTP or HTTPS depending on the login
@@ -341,9 +340,9 @@ def execute_upload(self, data,
341
340
An HTTP(s) response object
342
341
"""
343
342
context = self .__get_upload_context ()
344
- return self .__execute_post (context , data , content_type , verbose )
343
+ return self .__execute_post (context , data , content_type , verbose = verbose )
345
344
346
- def execute_share (self , data , verbose = False ):
345
+ def execute_share (self , data , * , verbose = False ):
347
346
"""Executes a POST upload request
348
347
The connection is done through HTTP or HTTPS depending on the login
349
348
status (logged in -> HTTPS)
@@ -368,7 +367,7 @@ def execute_share(self, data, verbose=False):
368
367
verbose = verbose )
369
368
370
369
def execute_table_edit (self , data ,
371
- content_type = CONTENT_TYPE_POST_DEFAULT ,
370
+ content_type = CONTENT_TYPE_POST_DEFAULT , * ,
372
371
verbose = False ):
373
372
"""Executes a POST upload request
374
373
The connection is done through HTTP or HTTPS depending on the login
@@ -388,10 +387,10 @@ def execute_table_edit(self, data,
388
387
An HTTP(s) response object
389
388
"""
390
389
context = self .__get_table_edit_context ()
391
- return self .__execute_post (context , data , content_type , verbose )
390
+ return self .__execute_post (context , data , content_type , verbose = verbose )
392
391
393
392
def execute_table_tool (self , data ,
394
- content_type = CONTENT_TYPE_POST_DEFAULT ,
393
+ content_type = CONTENT_TYPE_POST_DEFAULT , * ,
395
394
verbose = False ):
396
395
"""Executes a POST upload request
397
396
The connection is done through HTTP or HTTPS depending on the login
@@ -411,12 +410,12 @@ def execute_table_tool(self, data,
411
410
An HTTP(s) response object
412
411
"""
413
412
context = self .__get_table_edit_context ()
414
- return self .__execute_post (context , data , content_type , verbose )
413
+ return self .__execute_post (context , data , content_type , verbose = verbose )
415
414
416
415
def __execute_post (self , context , data ,
417
- content_type = CONTENT_TYPE_POST_DEFAULT ,
416
+ content_type = CONTENT_TYPE_POST_DEFAULT , * ,
418
417
verbose = False ):
419
- conn = self .__get_connection (verbose )
418
+ conn = self .__get_connection (verbose = verbose )
420
419
if verbose :
421
420
print (f"host = { conn .host } :{ conn .port } " )
422
421
print (f"context = { context } " )
@@ -428,7 +427,7 @@ def __execute_post(self, context, data,
428
427
self .__currentStatus = response .status
429
428
return response
430
429
431
- def execute_secure (self , subcontext , data , verbose = False ):
430
+ def execute_secure (self , subcontext , data , * , verbose = False ):
432
431
"""Executes a secure POST request
433
432
The connection is done through HTTPS
434
433
@@ -445,7 +444,7 @@ def execute_secure(self, subcontext, data, verbose=False):
445
444
-------
446
445
An HTTPS response object
447
446
"""
448
- conn = self .__get_connection_secure (verbose )
447
+ conn = self .__get_connection_secure (verbose = verbose )
449
448
context = self .__get_server_context (subcontext )
450
449
self .__postHeaders ["Content-type" ] = CONTENT_TYPE_POST_DEFAULT
451
450
conn .request ("POST" , context , data , self .__postHeaders )
@@ -638,7 +637,7 @@ def get_host_url_secure(self):
638
637
return f'{ self .__connHost } :{ self .__connPortSsl } { self .__get_tap_context ("" )} '
639
638
640
639
def check_launch_response_status (self , response , debug ,
641
- expected_response_status ,
640
+ expected_response_status , * ,
642
641
raise_exception = True ):
643
642
"""Checks the response status code
644
643
Returns True if the response status code is the
@@ -673,13 +672,13 @@ def check_launch_response_status(self, response, debug,
673
672
else :
674
673
return isError
675
674
676
- def __get_connection (self , verbose = False ):
677
- return self .__connectionHandler .get_connection (self .__isHttps ,
678
- self .__cookie ,
679
- verbose )
675
+ def __get_connection (self , * , verbose = False ):
676
+ return self .__connectionHandler .get_connection (ishttps = self .__isHttps ,
677
+ cookie = self .__cookie ,
678
+ verbose = verbose )
680
679
681
- def __get_connection_secure (self , verbose = False ):
682
- return self .__connectionHandler .get_connection_secure (verbose )
680
+ def __get_connection_secure (self , * , verbose = False ):
681
+ return self .__connectionHandler .get_connection_secure (verbose = verbose )
683
682
684
683
def encode_multipart (self , fields , files ):
685
684
"""Encodes a multipart form request
@@ -731,7 +730,7 @@ def __init__(self, host, port, sslport):
731
730
self .__connPort = port
732
731
self .__connPortSsl = sslport
733
732
734
- def get_connection (self , ishttps = False , cookie = None , verbose = False ):
733
+ def get_connection (self , * , ishttps = False , cookie = None , verbose = False ):
735
734
if (ishttps ) or (cookie is not None ):
736
735
if verbose :
737
736
print ("------>https" )
0 commit comments