@@ -60,7 +60,8 @@ def open_rasterio(
60
60
61
61
if cache :
62
62
path = cache_dir / name
63
- # need to always do that, otherwise the context manager might fail
63
+ # need to always do that, otherwise we might close the
64
+ # path using the context manager
64
65
cache_dir = pathlib .Path (cache_dir )
65
66
else :
66
67
cache_dir = tempfile .TemporaryDirectory ()
@@ -75,7 +76,8 @@ def open_rasterio(
75
76
return _open_rasterio (path , ** kws )
76
77
77
78
url = f"{ github_url } /raw/{ branch } /tests/data/{ path .name } "
78
- # make sure the directory is deleted afterwards
79
+ # if cache_dir points to a temporary directory, make sure it is
80
+ # deleted afterwards
79
81
with cache_dir :
80
82
download_to (url , path )
81
83
return _open_rasterio (path , ** kws )
@@ -128,7 +130,8 @@ def construct_url(full_name):
128
130
129
131
if cache :
130
132
path = cache_dir / name
131
- # need to always do that, otherwise the context manager might fail
133
+ # need to always do that, otherwise we might close the
134
+ # path using the context manager
132
135
cache_dir = pathlib .Path (cache_dir )
133
136
else :
134
137
cache_dir = tempfile .TemporaryDirectory ()
@@ -140,7 +143,8 @@ def construct_url(full_name):
140
143
if cache and path .is_file ():
141
144
return _open_dataset (path , ** kws )
142
145
143
- # make sure the directory is deleted afterwards if it was temporary
146
+ # if cache_dir points to a temporary directory, make sure it is
147
+ # deleted afterwards
144
148
with cache_dir :
145
149
download_to (construct_url (path .name ), path )
146
150
0 commit comments