From 0c3612996d7501380a4d5ec7d766c018cae9708f Mon Sep 17 00:00:00 2001 From: Dan Nowacki Date: Mon, 2 Dec 2024 10:07:03 -0800 Subject: [PATCH] path fixes --- lib/cartopy/io/ogc_clients.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/cartopy/io/ogc_clients.py b/lib/cartopy/io/ogc_clients.py index 4a774b386..bc0599a89 100644 --- a/lib/cartopy/io/ogc_clients.py +++ b/lib/cartopy/io/ogc_clients.py @@ -543,8 +543,8 @@ def _load_cache(self): if self._default_cache: warnings.warn( 'Cartopy created the following directory to cache ' - 'WMTSRasterSource tiles: {}'.format(cache_dir)) - self.cache = self.cache.union(set(os.listdir(cache_dir))) + f'WMTSRasterSource tiles: {cache_dir}') + self.cache = self.cache.union(set(cache_dir.iterdir())) def _choose_matrix(self, tile_matrices, meters_per_unit, max_pixel_span): # Get the tile matrices in order of increasing resolution. @@ -683,15 +683,12 @@ def _wmts_images(self, wmts, layer, matrix_set_name, extent, # Try it from disk cache if self.cache_path is not None: filename = f"{img_key[0]}_{img_key[1]}.npy" - cached_file = os.path.join( - self._cache_dir, - filename - ) + cached_file = self._cache_dir / filename else: filename = None cached_file = None - if filename in self.cache: + if cached_file in self.cache: img = Image.fromarray(np.load(cached_file, allow_pickle=False)) else: try: