Skip to content

Commit 380fc6b

Browse files
mhsarmientojespinosaar
authored andcommitted
Updated comments part with the changes proposed
1 parent c9bf976 commit 380fc6b

File tree

3 files changed

+42
-57
lines changed

3 files changed

+42
-57
lines changed

astroquery/gaia/core.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -903,20 +903,23 @@ def launch_job_async(self, query, name=None, output_file=None,
903903

904904
def rename_table(self, table_name=None, new_table_name=None, new_column_names_dict={},
905905
verbose=False):
906-
"""
907-
This new method allows to update the column names of a user table.
908-
header example: rename_table(table_name=old_table_name, new_table_name=new_table_name -optional-
909-
, new_column_names_dict=[old_column1:new_column1, old_column2:new_colum2...])
910-
Parameters
911-
----------
912-
table_name: str, required
913-
old name of the user's table
914-
new_table_name: str, required
915-
new name of the user's table
916-
new_column_names_dict: dict str:str, required
917-
dict with pairs "old_column1_name:new_column1_name"
918-
verbose : bool, optional, default 'False'
919-
flag to display information about the process
906+
""" This new method allows you to update the column names of a user table.
907+
908+
Parameters
909+
----------
910+
table_name: str, required
911+
old name of the user's table
912+
new_table_name: str, required
913+
new name of the user's table
914+
new_column_names_dict: dict str:str, required
915+
dict with pairs "old_column1_name:new_column1_name"
916+
verbose : bool, optional, default 'False'
917+
flag to display information about the process
918+
919+
Example
920+
-------
921+
TapPlus.rename_table.rename_table(table_name=old_table_name, new_table_name=new_table_name,
922+
new_column_names_dict=[old_column1:new_column1, old_column2:new_column2, ...])
920923
"""
921924
return TapPlus.rename_table(self, table_name=table_name, new_table_name=new_table_name,
922925
new_column_names_dict=new_column_names_dict, verbose=verbose)

astroquery/utils/tap/conn/tapconn.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def __init__(self, ishttps,
8787
self.__connPort = port
8888
self.__connPortSsl = sslport
8989
if server_context is not None:
90-
if(server_context.startswith("/")):
90+
if (server_context.startswith("/")):
9191
self.__serverContext = server_context
9292
else:
9393
self.__serverContext = f"/{server_context}"
@@ -107,7 +107,7 @@ def __init__(self, ishttps,
107107

108108
def __create_context(self, context):
109109
if (context is not None and context != ""):
110-
if(str(context).startswith("/")):
110+
if (str(context).startswith("/")):
111111
return f"{self.__serverContext}{context}"
112112
else:
113113
return f"{self.__serverContext}/{context}"
@@ -125,7 +125,7 @@ def __interna_init(self):
125125
self.__postHeaders = {
126126
"Content-type": CONTENT_TYPE_POST_DEFAULT,
127127
"Accept": "text/plain"
128-
}
128+
}
129129
self.__getHeaders = {}
130130
self.__cookie = None
131131
self.__currentStatus = 0
@@ -414,9 +414,6 @@ def execute_table_tool(self, data,
414414
context = self.__get_table_edit_context()
415415
return self.__execute_post(context, data, content_type, verbose)
416416

417-
418-
419-
420417
def __execute_post(self, context, data,
421418
content_type=CONTENT_TYPE_POST_DEFAULT,
422419
verbose=False):
@@ -602,7 +599,7 @@ def get_file_from_header(self, headers):
602599
if content_disposition is not None:
603600
p = content_disposition.find('filename="')
604601
if p >= 0:
605-
filename = content_disposition[p+10:len(content_disposition)-1]
602+
filename = content_disposition[p + 10:len(content_disposition) - 1]
606603
content_encoding = self.find_header(headers, 'Content-Encoding')
607604
if content_encoding is not None:
608605
if "gzip" == content_encoding.lower():
@@ -736,7 +733,7 @@ def encode_multipart(self, fields, files):
736733

737734
def __str__(self):
738735
return f"\tHost: {self.__connHost}\n\tUse HTTPS: {self.__isHttps}" \
739-
f"\n\tPort: {self.__connPort}\n\tSSL Port: {self.__connPortSsl}"
736+
f"\n\tPort: {self.__connPort}\n\tSSL Port: {self.__connPortSsl}"
740737

741738

742739
class ConnectionHandler:

astroquery/utils/tap/core.py

Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
Created on 30 jun. 2016
1414
Modified on 1 jun. 2021 by mhsarmiento
1515
Version: gaia-astroquery-1.0
16-
17-
1816
"""
1917
from astroquery.utils.tap import taputils
2018
from astroquery.utils.tap.conn.tapconn import TapConn
@@ -1650,23 +1648,28 @@ def delete_user_table(self, table_name=None, force_removal=False,
16501648
msg = f"Table '{table_name}' deleted."
16511649
print(msg)
16521650

1653-
def rename_table(self, table_name=None, new_table_name=None, new_column_names_dict={},
1651+
def rename_table(self, table_name=None, new_table_name=None, new_column_names_dict=None,
16541652
verbose=False):
1653+
""" This new method allows you to update the column names of a user table.
1654+
1655+
Parameters
1656+
----------
1657+
table_name: str, required
1658+
old name of the user's table
1659+
new_table_name: str, required
1660+
new name of the user's table
1661+
new_column_names_dict: dict str:str, required
1662+
dict with pairs "old_column1_name:new_column1_name"
1663+
verbose : bool, optional, default 'False'
1664+
flag to display information about the process
1665+
1666+
Example
1667+
-------
1668+
rename_table(table_name=old_table_name, new_table_name=new_table_name,
1669+
new_column_names_dict=[old_column1:new_column1, old_column2:new_column2, ...])
16551670
"""
1656-
This new method allows to update the column names of a user table.
1657-
header example: rename_table(table_name=old_table_name, new_table_name=new_table_name -optional-
1658-
, new_column_names_dict=[old_column1:new_column1, old_column2:new_colum2...])
1659-
Parameters
1660-
----------
1661-
table_name: str, required
1662-
old name of the user's table
1663-
new_table_name: str, required
1664-
new name of the user's table
1665-
new_column_names_dict: dict str:str, required
1666-
dict with pairs "old_column1_name:new_column1_name"
1667-
verbose : bool, optional, default 'False'
1668-
flag to display information about the process
1669-
"""
1671+
if new_column_names_dict is None:
1672+
new_column_names_dict = {}
16701673
args = {}
16711674

16721675
if table_name is None:
@@ -1676,25 +1679,13 @@ def rename_table(self, table_name=None, new_table_name=None, new_column_names_di
16761679
raise ValueError("Please introduce as minimum a new table tame or a new name for a column with format "
16771680
"old_column1_name:new_column1_name, ... ,old_columnN_name:new_columnN_name")
16781681

1679-
# # Now we will check that the table exist
1680-
# table = self.load_table(table=table_name, verbose=verbose)
1681-
#
1682-
# # Check now if the table exist and contains values
1683-
# if table is None:
1684-
# raise ValueError("Table name not found")
1685-
# columns = table.columns
1686-
# if len(columns) == 0:
1687-
# raise ValueError("Table has no columns")
1688-
16891682
if new_table_name is not None or new_table_name != '':
16901683
if new_column_names_dict is None or not new_column_names_dict:
16911684
# case 1: We only need to rename the table
16921685
args = self.get_args_4_rename_table_only_table_name(table_name, new_table_name)
16931686
else:
16941687
# case 2: We need to rename both, columns and column name
16951688
args = self.get_args_4_rename_table_all(table_name, new_table_name, new_column_names_dict)
1696-
# __end_if
1697-
# __end_if
16981689

16991690
if new_table_name is None or new_table_name == '':
17001691
if new_column_names_dict is not None or new_column_names_dict:
@@ -1713,8 +1704,6 @@ def rename_table(self, table_name=None, new_table_name=None, new_column_names_di
17131704
msg = f"Table '{table_name}' updated."
17141705
print(msg)
17151706

1716-
# __end_of_rename_table
1717-
17181707
def get_args_4_rename_table_only_table_name(self, table_name, new_table_name):
17191708

17201709
args = {
@@ -1724,8 +1713,6 @@ def get_args_4_rename_table_only_table_name(self, table_name, new_table_name):
17241713
}
17251714
return args
17261715

1727-
# __end_of_rename_table_only_table_name
1728-
17291716
def get_args_4_rename_table_all(self, table_name, new_table_name, new_column_names_dict):
17301717
count = 0
17311718
new_column_names = ""
@@ -1755,8 +1742,6 @@ def get_args_4_rename_table_all(self, table_name, new_table_name, new_column_nam
17551742
}
17561743
return args
17571744

1758-
# __end_of_rename_table_all
1759-
17601745
def get_args_4_rename_table_only_columns(self, table_name, new_column_names_dict):
17611746
# check if the changes proposed for the columns are correct.
17621747

0 commit comments

Comments
 (0)