Skip to content

Commit

Permalink
csv: Fall back to GenericCSV for csv files with no match
Browse files Browse the repository at this point in the history
If we fail to find a matching driver and the file appears to be a
".csv" file, return GenericCSV as a match. This will make us try to
open the file with the generic driver and thus capture loading error
messages and show them to the user. Otherwise we would just fail to
match a driver, and report the format is unsupported, which is
confusing to a user.

Related to #11519
  • Loading branch information
kk7ds committed Sep 4, 2024
1 parent 544b01f commit e993b49
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions chirp/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ def __repr__(self):
ex.metadata = metadata
raise ex
else:
# If we don't find anything else and the file appears to be a CSV
# file, then explicitly open it with the generic driver so we can
# get relevant errors instead of just "Unknown file format".
if image_file.lower().endswith('.csv'):
rclass = get_radio('Generic_CSV')
return rclass(image_file)
raise errors.ImageDetectFailed("Unknown file format")


Expand Down

0 comments on commit e993b49

Please sign in to comment.