From 61e17bf1823db829aa8818649362e98b47011f08 Mon Sep 17 00:00:00 2001 From: k034b363 Date: Fri, 11 Oct 2024 16:25:40 -0500 Subject: [PATCH] Try checking file type to fix external file deepsource issue --- plantcv/geospatial/points_to_geojson.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plantcv/geospatial/points_to_geojson.py b/plantcv/geospatial/points_to_geojson.py index 6ff4904..0571502 100644 --- a/plantcv/geospatial/points_to_geojson.py +++ b/plantcv/geospatial/points_to_geojson.py @@ -2,11 +2,10 @@ import geojson import rasterio -import os from plantcv.plantcv import fatal_error -def points_to_geojson(img, viewer, out_path="./points.geojson"): +def points_to_geojson(img, viewer, out_path): """Use clicks from a Napari or plantcv-annotate viewer to output a geojson shapefile. Parameters @@ -35,5 +34,8 @@ def points_to_geojson(img, viewer, out_path="./points.geojson"): "name": rasterio.crs.CRS.to_string(img.metadata["crs"]) } } - with open(out_path, 'w') as writefile: - geojson.dump(feature_collection, writefile) + if ".geojson" in out_path: + with open(out_path, 'w') as f: + geojson.dump(feature_collection, f) + else: + fatal_error("File type not supported.")