Skip to content

Commit 2d5584c

Browse files
committed
Use context manager in list_column function
1 parent dca960a commit 2d5584c

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

astroquery/eso/core.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -377,18 +377,12 @@ def list_column(self, table_name: str) -> None:
377377
count_query = f"select count(*) from {table_name}"
378378
num_records = list(self.query_tap(count_query)[0].values())[0]
379379

380-
# All this block is to print nicely...
381-
# This whole function should be better written and the output
382-
# shown tidier
383-
nlines = len(available_cols) + 2
384-
n_ = astropy.conf.max_lines
385-
m_ = astropy.conf.max_width
386-
astropy.conf.max_lines = nlines
387-
astropy.conf.max_width = sys.maxsize
388-
log.info(f"\nColumns present in the table {table_name}:\n{available_cols}\n"
389-
f"\nNumber of records present in the table {table_name}:\n{num_records}\n")
390-
astropy.conf.max_lines = n_
391-
astropy.conf.max_width = m_
380+
with (astropy.conf.set_temp(
381+
"max_lines", len(available_cols) + 2),
382+
astropy.conf.set_temp(
383+
"max_width", sys.maxsize)):
384+
log.info(f"\nColumns present in the table {table_name}:\n{available_cols}\n"
385+
f"\nNumber of records present in the table {table_name}:\n{num_records}\n")
392386

393387
def _query_on_allowed_values(
394388
self,

0 commit comments

Comments
 (0)