Skip to content

Commit

Permalink
Fix isdir TypeError when passing it a boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
TimoRoth authored and fmaussion committed Aug 16, 2021
1 parent de8f56f commit 129cf4b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion oggm/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,15 @@ def init_glacier_regions(rgidf=None, *, reset=False, force=False,
return gdirs


def _isdir(path):
"""os.path.isdir, returning False instead of an error on non-string/path-like objects
"""
try:
return os.path.isdir(path)
except TypeError:
return False


def init_glacier_directories(rgidf=None, *, reset=False, force=False,
from_prepro_level=None, prepro_border=None,
prepro_rgi_version=None, prepro_base_url=None,
Expand Down Expand Up @@ -508,7 +517,7 @@ def init_glacier_directories(rgidf=None, *, reset=False, force=False,
# List of str
pass

if os.path.isdir(from_tar):
if _isdir(from_tar):
gdirs = execute_entity_task(gdir_from_tar, entities,
from_tar=from_tar)
else:
Expand Down

0 comments on commit 129cf4b

Please sign in to comment.