diff --git a/lib/cartopy/io/img_nest.py b/lib/cartopy/io/img_nest.py index 441a6d16a..675f5f4c1 100644 --- a/lib/cartopy/io/img_nest.py +++ b/lib/cartopy/io/img_nest.py @@ -122,7 +122,15 @@ def world_files(fname): fext_types.extend([ext.upper() for ext in fext_types]) result = [path.with_suffix(ext) for ext in fext_types] - result += [path.with_stem(path.stem.swapcase()) for path in result] + def _convert_basename(path): + # TODO: Once we support only Python 3.9+ we can inline this + # with path.with_stem(path.stem.swapcase()) + dirname, basename = path.parent, Path(path.name) + base, ext = basename.stem, basename.suffix + result = dirname / (base.swapcase() + ext) + return result + + result += [_convert_basename(path) for path in result] # return string paths rather than Path objects return [str(r) for r in result]