format code
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
from .icon import Icon
|
||||
from .stringtodate import stringToDate
|
||||
from .documentation import launch_documentation
|
||||
from .documentation import launch_documentation
|
||||
|
||||
@@ -7,13 +7,14 @@ from PyQt6.QtCore import QDate
|
||||
from src import config
|
||||
import datetime
|
||||
|
||||
|
||||
# query all loans that happened in the last 7 days
|
||||
def generate_report():
|
||||
'''Generate an excel report for all actions that happened in the last seven days
|
||||
"""Generate an excel report for all actions that happened in the last seven days
|
||||
|
||||
Returns:
|
||||
str: a string represeting the generated table
|
||||
'''
|
||||
"""
|
||||
db = Database()
|
||||
path = db.db_path
|
||||
year = datetime.datetime.now().year
|
||||
@@ -23,7 +24,7 @@ def generate_report():
|
||||
report_path = os.path.join(config.report.path, f"report_{year}_{week}.tsv")
|
||||
day = QDate.currentDate().addDays(-7).toString("yyyy-MM-dd")
|
||||
query = f"""SELECT * FROM loans WHERE loan_date >= '{day}';"""
|
||||
#print(query)
|
||||
# print(query)
|
||||
|
||||
colnames = ["UserId", "Title", "Action", "Datum"]
|
||||
table = PrettyTable(colnames)
|
||||
|
||||
@@ -3,18 +3,23 @@ from wsgiref.simple_server import make_server
|
||||
from src import docport, log
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def website():
|
||||
config = Configurator()
|
||||
|
||||
# Set up static file serving from the 'site/' directory
|
||||
config.add_static_view(name='/', path=os.path.join(os.getcwd(), 'site'), cache_max_age=3600)
|
||||
config.add_static_view(
|
||||
name="/", path=os.path.join(os.getcwd(), "site"), cache_max_age=3600
|
||||
)
|
||||
|
||||
app = config.make_wsgi_app()
|
||||
return app
|
||||
|
||||
|
||||
def launch_documentation():
|
||||
app = website()
|
||||
server = make_server('localhost', 6543, app)
|
||||
server = make_server("localhost", 6543, app)
|
||||
log.info("Serving MkDocs documentation on http://0.0.0.0:{}".format(docport))
|
||||
with open(os.devnull, "w") as devnull:
|
||||
old_stdout = sys.stdout
|
||||
@@ -27,6 +32,6 @@ def launch_documentation():
|
||||
sys.stdout = old_stdout
|
||||
sys.stderr = old_stderr
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
||||
|
||||
0
src/utils/filepicker.py
Normal file
0
src/utils/filepicker.py
Normal file
@@ -58,7 +58,7 @@ class ReportThread(QThread):
|
||||
# # wruitng the table to a file
|
||||
if self.format == "tsv":
|
||||
table = table.get_csv_string()
|
||||
tsv_table = table.replace(",", "\t")#.replace("Rückgabe", "Rückgabe")
|
||||
tsv_table = table.replace(",", "\t") # .replace("Rückgabe", "Rückgabe")
|
||||
# write the file
|
||||
with open("report.tsv", "w") as f:
|
||||
f.write(tsv_table)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
# import qdate
|
||||
from PyQt6 import QtCore
|
||||
from src import log
|
||||
|
||||
|
||||
def stringToDate(date: str) -> QtCore.QDate:
|
||||
"""Takes an input string and returns a QDate object.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user