From 2fd8a0b9b6488a0e38333d6d8be499f61e6a1854 Mon Sep 17 00:00:00 2001 From: Landon Wark Date: Wed, 13 Mar 2024 10:31:55 -0500 Subject: [PATCH] Updates to report functions. --- src/submissions/__init__.py | 12 ++++++++++-- src/submissions/frontend/widgets/submission_table.py | 2 +- src/submissions/tools.py | 11 ++++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/submissions/__init__.py b/src/submissions/__init__.py index b0bb685..59282e5 100644 --- a/src/submissions/__init__.py +++ b/src/submissions/__init__.py @@ -1,7 +1,6 @@ # __init__.py from pathlib import Path -from tools import CustomFormatter # Version of the realpython-reader package __project__ = "submissions" @@ -11,7 +10,16 @@ __copyright__ = "2022-2024, Government of Canada" project_path = Path(__file__).parents[2].absolute() -bcolors = CustomFormatter.bcolors() +class bcolors: + HEADER = '\033[95m' + OKBLUE = '\033[94m' + OKCYAN = '\033[96m' + OKGREEN = '\033[92m' + WARNING = '\033[93m' + FAIL = '\033[91m' + ENDC = '\033[0m' + BOLD = '\033[1m' + UNDERLINE = '\033[4m' # Hello Landon, this is your past self here. I'm trying not to screw you over like I usually do, so I will # set out the workflow I've imagined for creating new submission types. diff --git a/src/submissions/frontend/widgets/submission_table.py b/src/submissions/frontend/widgets/submission_table.py index 26ce7c0..34263ce 100644 --- a/src/submissions/frontend/widgets/submission_table.py +++ b/src/submissions/frontend/widgets/submission_table.py @@ -8,7 +8,7 @@ from PyQt6.QtCore import Qt, QAbstractTableModel, QSortFilterProxyModel from PyQt6.QtGui import QAction, QCursor from backend.db.models import BasicSubmission from backend.excel import make_report_html, make_report_xlsx -from tools import Report, Result, row_map +from tools import Report, Result, row_map, get_first_blank_df_row from xhtml2pdf import pisa from .functions import select_save_file, select_open_file from .misc import ReportDatePicker diff --git a/src/submissions/tools.py b/src/submissions/tools.py index 8c539f9..8d6cef0 100644 --- a/src/submissions/tools.py +++ b/src/submissions/tools.py @@ -115,7 +115,16 @@ def check_regex_match(pattern:str, check:str) -> bool: return bool(re.match(fr"{pattern}", check)) except TypeError: return False - + +def get_first_blank_df_row(df:pd.DataFrame) -> int: + #First, find NaN entries in first column + # blank_row_bool = df.iloc[:,2].isna() + # logger.debug(f"Blank row bool: {blank_row_bool}") + # #Next, get index of first NaN entry + # blank_row_index = [i for i, x in enumerate(blank_row_bool) if x][0] + # return blank_row_index + return df.shape[0] + 1 + # Settings class Settings(BaseSettings):