Remove unused functions from app.py

This commit is contained in:
Peter Stockings
2025-01-27 14:54:31 +11:00
parent f70438e4e4
commit 07c2111b55

44
app.py
View File

@@ -1,5 +1,4 @@
from datetime import datetime, date, timedelta
from dateutil.relativedelta import relativedelta
from datetime import date
import os
from flask import Flask, abort, render_template, redirect, request, url_for
import jinja_partials
@@ -9,7 +8,6 @@ from db import DataBase
from utils import convert_str_to_date, generate_plot
from flask_htmx import HTMX
import minify_html
from urllib.parse import quote
import os
from dotenv import load_dotenv
@@ -586,32 +584,10 @@ def search_endpoints():
def closeConnection(exception):
db.close_connection()
@app.template_filter('list_to_string')
def list_to_string(list):
return [str(i) for i in list]
@app.template_filter('strftime')
def strftime(date, format="%b %d %Y"):
return date.strftime(format)
@app.template_filter('get_first_element_from_list_with_matching_attribute')
def get_first_element_from_list_with_matching_attribute(list, attribute, value):
if not list:
return None
for element in list:
if element[attribute] == value:
return element
return None
@app.template_filter('replace_double_quote_strings_with_single_quote')
def replace_double_quote_strings_with_single_quote(str):
return str.replace('"', "'")
@ app.context_processor
def my_utility_processor():
@@ -623,26 +599,10 @@ def my_utility_processor():
return 'bg-gray-200'
return ''
def get_first_element_from_list_with_matching_attribute(list, attribute, value):
if not list:
return None
for element in list:
if element[attribute] == value:
return element
return None
def in_list(val, checked_vals, attr='checked'):
if not checked_vals:
return attr
return attr if val in checked_vals else ''
def strftime(date, format="%b %d %Y"):
return date.strftime(format)
def list_to_string(list):
return [str(i) for i in list]
return dict(is_selected_page=is_selected_page, get_first_element_from_list_with_matching_attribute=get_first_element_from_list_with_matching_attribute, in_list=in_list, strftime=strftime, datetime=datetime, timedelta=timedelta, relativedelta=relativedelta, list_to_string=list_to_string, quote=quote)
return dict(is_selected_page=is_selected_page, strftime=strftime)
if __name__ == '__main__':