Skip to content

Commit

Permalink
Fix no mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mraspaud committed Mar 8, 2024
1 parent ae140b3 commit 9390945
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions satpy/readers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ def _get_compression(file):
return None


def open_file_or_filename(unknown_file_thing, mode="r"):
def open_file_or_filename(unknown_file_thing, mode=None):
"""Try to open the provided file "thing" if needed, otherwise return the filename or Path.
This wraps the logic of getting something like an fsspec OpenFile object
Expand All @@ -797,7 +797,10 @@ def open_file_or_filename(unknown_file_thing, mode="r"):
f_obj = unknown_file_thing
else:
try:
f_obj = unknown_file_thing.open(mode=mode)
if mode is None:
f_obj = unknown_file_thing.open()
else:
f_obj = unknown_file_thing.open(mode=mode)
except AttributeError:
f_obj = unknown_file_thing
return f_obj

0 comments on commit 9390945

Please sign in to comment.