From 5fb445dadfff6d023afacad523d4f0a31b382913 Mon Sep 17 00:00:00 2001 From: sujanadh Date: Tue, 5 Sep 2023 10:42:10 +0545 Subject: [PATCH] fix: updated category based on the available yaml file --- src/backend/app/projects/project_crud.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backend/app/projects/project_crud.py b/src/backend/app/projects/project_crud.py index d02f0979d7..8ef06eb401 100644 --- a/src/backend/app/projects/project_crud.py +++ b/src/backend/app/projects/project_crud.py @@ -37,6 +37,7 @@ import segno import shapely.wkb as wkblib import sqlalchemy +import pkg_resources from fastapi import File, HTTPException, UploadFile from geoalchemy2.shape import from_shape from geojson import dump @@ -1044,9 +1045,15 @@ def read_xlsforms( ): """Read the list of XLSForms from the disk.""" xlsforms = list() + package_name = "osm_fieldwork" for xls in os.listdir(directory): if xls.endswith(".xls") or xls.endswith(".xlsx"): - xlsforms.append(xls) + file_name = xls.split(".")[0] + yaml_file_name = f"data_models/{file_name}.yaml" + if pkg_resources.resource_exists(package_name,yaml_file_name): + xlsforms.append(xls) + else: + continue log.info(xls) inspect(db_models.DbXForm) forms = table(