From fa2bba673dace001ada41666460f3204f92cd27c Mon Sep 17 00:00:00 2001 From: Remi Cresson <remi.cresson@irstea.fr> Date: Thu, 2 Jun 2022 13:12:55 +0200 Subject: [PATCH] FIX, REFAC: use f-string and os.path.join() for paths concat --- decloud/preprocessing/sentinel1_prepare.py | 3 ++- decloud/preprocessing/sentinel2_prepare.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/decloud/preprocessing/sentinel1_prepare.py b/decloud/preprocessing/sentinel1_prepare.py index 281d59d..a7b9bbc 100644 --- a/decloud/preprocessing/sentinel1_prepare.py +++ b/decloud/preprocessing/sentinel1_prepare.py @@ -22,6 +22,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ """Pre-process one Sentinel-1 image""" +import os import logging import argparse import otbApplication @@ -79,7 +80,7 @@ def main(args): constants.PATCHSIZE_REF) # Calibration + concatenation + tiling/compression - out_fn = system.pathify(params.out_s1_dir) + out_fn + out_fn = os.path.join(params.out_s1_dir, out_fn) if system.is_complete(out_fn): logging.info("File %s already exists. Skipping.", system.remove_ext_filename(out_fn)) else: diff --git a/decloud/preprocessing/sentinel2_prepare.py b/decloud/preprocessing/sentinel2_prepare.py index 38951e7..9e7221e 100644 --- a/decloud/preprocessing/sentinel2_prepare.py +++ b/decloud/preprocessing/sentinel2_prepare.py @@ -43,7 +43,7 @@ def fconc(il, suffix, tilesize, out_tile_dir, pixel_type=otbApplication.ImagePix logging.info("Concatenate + Tile + Compress GeoTiff for files: %s", "".join(il)) out_fn = system.basename(il[0]) out_fn = out_fn[:out_fn.rfind("_")] - out_fn = out_tile_dir + out_fn + "_" + suffix + out_fn = os.path.join(out_tile_dir, out_fn + "_" + suffix) out_fn += ".tif?&gdal:co:COMPRESS=DEFLATE" out_fn += "&streaming:type=tiled&streaming:sizemode=height&streaming:sizevalue={}".format(4 * tilesize) out_fn += "&gdal:co:TILED=YES&gdal:co:BLOCKXSIZE={ts}&gdal:co:BLOCKYSIZE={ts}".format(ts=tilesize) @@ -130,7 +130,7 @@ def main(args): logging.info("Product name is %s", product_name) # Out directory - out_tile_dir = system.pathify(params.out_s2_dir) + tile_name + "/" + product_name + "/" + out_tile_dir = os.path.join(params.out_s2_dir, tile_name, product_name) logging.info("Create or use the following output directory: %s", out_tile_dir) system.mkdir(out_tile_dir) -- GitLab