Skip to content

Commit 54fe088

Browse files
Jorge Fernandez HernandezJorge Fernandez Hernandez
Jorge Fernandez Hernandez
authored and
Jorge Fernandez Hernandez
committed
EUCLIDPCR-1971 Changed suggested in the PR: the astropy Table.read makes use of the format and the documentation of the parameter format has been improved.
1 parent 5e1ec3b commit 54fe088

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

Diff for: astroquery/utils/tap/core.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
"""
1616
import getpass
1717
import os
18-
import requests
1918
import tempfile
20-
from astropy.table.table import Table
2119
from urllib.parse import urlencode
2220

21+
import requests
22+
from astropy.table.table import Table
23+
2324
from astroquery import log
2425
from astroquery.utils.tap import taputils
2526
from astroquery.utils.tap.conn.tapconn import TapConn
@@ -1342,7 +1343,8 @@ def upload_table(self, *, upload_resource=None, table_name=None, table_descripti
13421343
table_description : str, optional, default None
13431344
table description
13441345
format : str, optional, default 'votable'
1345-
resource format
1346+
resource format. Only formats described in
1347+
https://docs.astropy.org/en/stable/io/unified.html#built-in-table-readers-writers are accepted.
13461348
verbose : bool, optional, default 'False'
13471349
flag to display information about the process
13481350
"""
@@ -1415,7 +1417,7 @@ def __uploadTableMultipart(self, resource, *, table_name=None, table_description
14151417
chunk = f.read()
14161418
files = [['FILE', os.path.basename(resource), chunk]]
14171419
else:
1418-
table = Table.read(str(resource))
1420+
table = Table.read(str(resource), format=resource_format)
14191421
fh = tempfile.NamedTemporaryFile(delete=False)
14201422
table.write(fh, format='votable')
14211423
fh.close()

Diff for: astroquery/utils/tap/tests/test_tap.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ def test_upload_table():
973973

974974
file_ecsv = get_pkg_data_filename(os.path.join("data", 'test_upload_file', '1744351221317O-result.ecsv'),
975975
package=package)
976-
job = tap.upload_table(upload_resource=file_ecsv, table_name=table_name, format='ecsv')
976+
job = tap.upload_table(upload_resource=file_ecsv, table_name=table_name, format='ascii.ecsv')
977977

978978
assert (job.jobid == jobid)
979979

@@ -1002,7 +1002,7 @@ def test_upload_table():
10021002
with pytest.raises(IORegistryError) as exc_info:
10031003
job = tap.upload_table(upload_resource=file_json, table_name=table_name, format='json')
10041004

1005-
argument_ = "Format could not be identified based on the file name or contents, please provide a 'format' argument."
1005+
argument_ = "No reader defined for format 'json' and class 'Table'."
10061006
assert (argument_ in str(exc_info.value))
10071007

10081008
# Make use of an astropy table

0 commit comments

Comments
 (0)