Skip to content

Commit

Permalink
fix removesuffix requires python >= 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelquast committed Dec 8, 2023
1 parent c05d6c3 commit e468580
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion eomaps/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@
from matplotlib.transforms import TransformedPath
import warnings
import logging
import sys

_log = logging.getLogger(__name__)


def _removesuffix(s, suffix):
if s.endswith(suffix):
return s[: -len(suffix)]
else:
return s[:]


class _ClickCallbacks(object):
"""
A collection of callback-functions.
Expand Down Expand Up @@ -1347,7 +1355,11 @@ def overlay_layer(self, layer, key="x"):
if not self._m.BM.bg_layer.endswith(f"|{layer}"):
self._m.show_layer(self._m.BM.bg_layer, layer)
else:
newlayer = self._m.BM.bg_layer.removesuffix(f"|{layer}")
if sys.version_info >= (3, 9):
newlayer = self._m.BM.bg_layer.removesuffix(f"|{layer}")
else:
newlayer = _removesuffix(self._m.BM.bg_layer, f"|{layer}")

if len(newlayer) > 0:
self._m.show_layer(newlayer)

Expand Down

0 comments on commit e468580

Please sign in to comment.