Skip to content

Commit

Permalink
MNT: Remove py3.9 pathlib handling
Browse files Browse the repository at this point in the history
  • Loading branch information
greglucas committed Feb 26, 2023
1 parent f1c9bd2 commit e4d1ab0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/cartopy/io/img_nest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down

0 comments on commit e4d1ab0

Please sign in to comment.