Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tasi/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def att(

try:
len(timestamps)
except:
except TypeError:
timestamps = [timestamps]

if self.index.nlevels == 1:
Expand Down Expand Up @@ -184,7 +184,7 @@ def atid(
"""
try:
len(ids)
except BaseException:
except TypeError:
ids = [ids]

if attributes is None:
Expand Down
12 changes: 8 additions & 4 deletions tasi/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ def __getitem__(self, key):
# if the levels do not match, try wrapping the key in a list
try:
df = super().__getitem__([key])
except Exception as err:
# this will not work for slices. Just ignore this.
print(err)
pass
except (KeyError, ValueError, TypeError) as err:
# this will not work for slices. Log and ignore gracefully.
import logging
logging.getLogger(__name__).debug(
"Dialog LocLocator index fallback failed for key %r: %s",
key,
err,
)
return self.obj._ensure_correct_type(df, key)
except AttributeError:
# if the result is no pandas object anymore. This occurs if the user selects specific table cell using any
Expand Down
2 changes: 1 addition & 1 deletion tasi/io/public/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def flatten_dataframe_columns(df: pd.DataFrame, max_levels=1):
if df.columns.nlevels > max_levels:
try:
df = df.droplevel(level=1, axis=1)
except:
except (KeyError, ValueError, IndexError):
df = df.droplevel(level=1)

return df
Expand Down
6 changes: 3 additions & 3 deletions tasi/plotting/wms.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ def get_tile(self, x1, y1, x2, y2):
try:
fp = _io.BytesIO(tile)
return _Image.open(fp)
except BaseException:
except (OSError, IOError, ValueError) as err:
raise RuntimeError(
"Failed to decode data for {} - @ {} extent".format(
self.name, [x1, y1, x2, y2]
"Failed to decode data for {} - @ {} extent: {}".format(
self.name, [x1, y1, x2, y2], err
)
)

Expand Down