From 1d83534a95ae285d6b76c72b417ee5e337e9227b Mon Sep 17 00:00:00 2001 From: pjpatil12 Date: Wed, 18 Mar 2026 10:19:11 +0530 Subject: [PATCH] updateds folder path and regex --- app/routes/file_format.py | 6 ++---- app/routes/generate_comparison_report.py | 3 --- app/utils/file_utils.py | 12 +++++++++++- app/utils/regex_utils.py | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/routes/file_format.py b/app/routes/file_format.py index 54ed193..2ecc8e1 100644 --- a/app/routes/file_format.py +++ b/app/routes/file_format.py @@ -1,5 +1,6 @@ from flask import Blueprint, render_template, send_from_directory, abort, current_app from app.utils.helpers import login_required +from app.utils.file_utils import get_download_format_folder import os file_format_bp = Blueprint("file_format", __name__) @@ -14,10 +15,7 @@ def download_format(): @login_required def download_excel_format(filename): - download_folder = os.path.join( - current_app.root_path, "static", "downloads/format" - ) - + download_folder = get_download_format_folder() file_path = os.path.join(download_folder, filename) if not os.path.exists(file_path): diff --git a/app/routes/generate_comparison_report.py b/app/routes/generate_comparison_report.py index c48c986..6624792 100644 --- a/app/routes/generate_comparison_report.py +++ b/app/routes/generate_comparison_report.py @@ -224,15 +224,12 @@ def comparison_report(): subcontractor_id=subcontractor_id ).all()] df_dc = build_comparison(dc_client, dc_sub, "MH_NO") - # df_dc = build_comparison_mh_dc(dc_client, dc_sub, "MH_NO") lay_client = [r.serialize() for r in LayingClient.query.all()] lay_sub = [r.serialize() for r in Laying.query.filter_by( subcontractor_id=subcontractor_id ).all()] df_lay = build_comparison(lay_client, lay_sub, "MH_NO") - # df_lay = build_comparison_laying(lay_client, lay_sub, "MH_NO") - # -------- EXCEL -------- output = io.BytesIO() diff --git a/app/utils/file_utils.py b/app/utils/file_utils.py index 8a79d69..326e5c7 100644 --- a/app/utils/file_utils.py +++ b/app/utils/file_utils.py @@ -1,6 +1,16 @@ import os +from flask import current_app from app.config import Config + +def get_download_format_folder(): + return os.path.join( + current_app.root_path, + "static", + "downloads", + "format" + ) + def ensure_upload_folder(): if not os.path.exists(Config.UPLOAD_FOLDER): - os.makedirs(Config.UPLOAD_FOLDER) + os.makedirs(Config.UPLOAD_FOLDER) \ No newline at end of file diff --git a/app/utils/regex_utils.py b/app/utils/regex_utils.py index f6eb7b1..185e36c 100644 --- a/app/utils/regex_utils.py +++ b/app/utils/regex_utils.py @@ -9,4 +9,4 @@ class RegularExpression: PIPE_MM_PATTERN = re.compile(r"^pipe_\d+_mm$") # sum fields of MH dc (d_0_to_0_75) - D_RANGE_PATTERN = re.compile( r"^d_\d+(?:_\d+)?_to_\d+(?:_\d+)?$") \ No newline at end of file + D_RANGE_PATTERN = re.compile( r"^d_\d+(?:_\d+)?_to_\d+(?:_\d+)?$") \ No newline at end of file -- 2.49.1