Traceback (most recent call last):
File "/Users/tech3371/Library/Caches/pypoetry/virtualenvs/sds-data-manager-Be1fnlCS-py3.10/bin/imap-data-access", line 8, in
sys.exit(main())
File "/Users/tech3371/Library/Caches/pypoetry/virtualenvs/sds-data-manager-Be1fnlCS-py3.10/lib/python3.10/site-packages/imap_data_access/cli.py", line 295, in main
args.func(args)
File "/Users/tech3371/Library/Caches/pypoetry/virtualenvs/sds-data-manager-Be1fnlCS-py3.10/lib/python3.10/site-packages/imap_data_access/cli.py", line 117, in _query_parser
_print_query_results_table(query_results)
File "/Users/tech3371/Library/Caches/pypoetry/virtualenvs/sds-data-manager-Be1fnlCS-py3.10/lib/python3.10/site-packages/imap_data_access/cli.py", line 82, in _print_query_results_table
print(format_string.format(*values))
TypeError: unsupported format string passed to NoneType.format
Additional notes
No response
Affected areas (code, data, or process)
cli.py and code line 79
Suggested fix?
def _print_query_results_table(query_results: list[dict]):
"""Print the query results in a table.
Parameters
----------
query_results : list
A list of dictionaries containing the query results
"""
num_files = len(query_results)
print(f"Found [{num_files}] matching files")
if num_files == 0:
return
format_string = "{:<10}|{:<10}|{:<10}|{:<10}|{:<10}|{:<7}|{:<50}|"
# Add hyphens for a separator between header and data
hyphens = "-" * 111 + "|"
print(hyphens)
header = [
"Instrument",
"Data Level",
"Descriptor",
"Start Date",
"Repointing",
"Version",
"Filename",
]
print(format_string.format(*header))
print(hyphens)
# Print data
for item in query_results:
values = [
item["instrument"],
item["data_level"],
item["descriptor"],
item["start_date"],
item["repointing"],
item["version"],
os.path.basename(item["file_path"]),
]
# Convert None to an empty string (or another default value)
values = [v if v is not None else '' for v in values]
print(format_string.format(*values))
# Close the table
print(hyphens)
Description of the issue
Query fails with None error
Steps to reproduce the issue
Run this command
Code Snippet:
Expected behavior (What should happen)
imap-data-access query --instrument 'mag' Found [1] matching files table output
Actual behavior (What does happen)
Found [1] matching files ---------------------------------------------------------------------------------------------------------------
Traceback (most recent call last): File "/Users/tech3371/Library/Caches/pypoetry/virtualenvs/sds-data-manager-Be1fnlCS-py3.10/bin/imap-data-access", line 8, in
sys.exit(main())
File "/Users/tech3371/Library/Caches/pypoetry/virtualenvs/sds-data-manager-Be1fnlCS-py3.10/lib/python3.10/site-packages/imap_data_access/cli.py", line 295, in main
args.func(args)
File "/Users/tech3371/Library/Caches/pypoetry/virtualenvs/sds-data-manager-Be1fnlCS-py3.10/lib/python3.10/site-packages/imap_data_access/cli.py", line 117, in _query_parser
_print_query_results_table(query_results)
File "/Users/tech3371/Library/Caches/pypoetry/virtualenvs/sds-data-manager-Be1fnlCS-py3.10/lib/python3.10/site-packages/imap_data_access/cli.py", line 82, in _print_query_results_table
print(format_string.format(*values))
TypeError: unsupported format string passed to NoneType.format
Additional notes
No response
Affected areas (code, data, or process)
cli.py and code line 79
Suggested fix?
def _print_query_results_table(query_results: list[dict]): """Print the query results in a table.