File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -65,20 +65,26 @@ def convert(
65
65
"""Read any technology data as a SpatialData object and save it as a `.zarr` directory.
66
66
67
67
Either `--technology` or `--config-path` has to be provided."""
68
+ import shutil
68
69
from pathlib import Path
69
70
70
71
from spatialdata import SpatialData
71
72
72
73
from sopa import io
73
- from sopa ._constants import SopaKeys
74
+ from sopa ._constants import SopaFiles , SopaKeys
74
75
75
76
sdata_path : Path = Path (data_path ).with_suffix (".zarr" ) if sdata_path is None else Path (sdata_path )
76
77
77
- if not overwrite and sdata_path .exists ():
78
- assert not any (sdata_path .iterdir ()), (
79
- f"Zarr directory { sdata_path } already exists. Sopa will not continue to avoid overwritting files."
80
- )
81
- sdata_path .rmdir () # remove empty directory
78
+ if sdata_path .exists ():
79
+ if overwrite :
80
+ cache_dir = sdata_path .resolve () / SopaFiles .SOPA_CACHE_DIR
81
+ if cache_dir .exists () and cache_dir .is_dir ():
82
+ shutil .rmtree (cache_dir )
83
+ else :
84
+ assert not any (sdata_path .iterdir ()), (
85
+ f"Zarr directory { sdata_path } already exists. Sopa will not continue to avoid overwritting files. Use the `--overwrite` flag to overwrite it."
86
+ )
87
+ sdata_path .rmdir () # remove empty directory
82
88
83
89
assert technology is not None or config_path is not None , "Provide the argument `--technology` or `--config-path`"
84
90
You can’t perform that action at this time.
0 commit comments