-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change For Dynamic Table Output #79
Change For Dynamic Table Output #79
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I was tried querying with your changes and everything looked good. Great work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making this fix! It looks good. I just had one non-blocking suggestion if you wanted to try it out. But it is also fine as is.
imap_data_access/cli.py
Outdated
# Calculate the maximum width for each column based on the header and the data | ||
column_widths = { | ||
"Instrument": max( | ||
len("Instrument"), | ||
*(len(str(item.get("instrument", ""))) for item in query_results), | ||
), | ||
"Data Level": max( | ||
len("Data Level"), | ||
*(len(str(item.get("data_level", ""))) for item in query_results), | ||
), | ||
"Descriptor": max( | ||
len("Descriptor"), | ||
*(len(str(item.get("descriptor", ""))) for item in query_results), | ||
), | ||
"Start Date": max( | ||
len("Start Date"), | ||
*(len(str(item.get("start_date", ""))) for item in query_results), | ||
), | ||
"Repointing": max( | ||
len("Repointing"), | ||
*(len(str(item.get("repointing", ""))) for item in query_results), | ||
), | ||
"Version": max( | ||
len("Version"), | ||
*(len(str(item.get("version", ""))) for item in query_results), | ||
), | ||
"Filename": max( | ||
len("Filename"), | ||
*( | ||
len(os.path.basename(item.get("file_path", ""))) | ||
for item in query_results | ||
), | ||
), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to think of a clever way to avoid duplicated code. Does something like this work?
# Calculate the maximum width for each column based on the header and the data | |
column_widths = { | |
"Instrument": max( | |
len("Instrument"), | |
*(len(str(item.get("instrument", ""))) for item in query_results), | |
), | |
"Data Level": max( | |
len("Data Level"), | |
*(len(str(item.get("data_level", ""))) for item in query_results), | |
), | |
"Descriptor": max( | |
len("Descriptor"), | |
*(len(str(item.get("descriptor", ""))) for item in query_results), | |
), | |
"Start Date": max( | |
len("Start Date"), | |
*(len(str(item.get("start_date", ""))) for item in query_results), | |
), | |
"Repointing": max( | |
len("Repointing"), | |
*(len(str(item.get("repointing", ""))) for item in query_results), | |
), | |
"Version": max( | |
len("Version"), | |
*(len(str(item.get("version", ""))) for item in query_results), | |
), | |
"Filename": max( | |
len("Filename"), | |
*( | |
len(os.path.basename(item.get("file_path", ""))) | |
for item in query_results | |
), | |
), | |
} | |
column_widths = {} | |
for header in headers[:-1]: | |
column_width[header] = max(len(header), *(len(str(item.get(header.lower(), ""))) for item in query_results) | |
# Calculate the maximum width for each column based on the header and the data | |
column_widths["Filename"] = max(len("Filename"), *(len(os.path.basename(item.get("file_path", ""))) for item in query_results) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It produces the same results
@daralynnrhode It looks like this PR is ready to go, so I am going to merge this now so that it can be included in today's release. |
82e73ce
into
IMAP-Science-Operations-Center:main
Making the output table be dynamic with sizing
Overview
Making changes to the
_print_query_results_table()
so the sizing of the table can be dynamic based on thequery_results
received.Closes #53
New Dependencies
New Files
Deleted Files
Updated Files
Testing