bump python version, ruff check

This commit is contained in:
2026-02-10 14:33:54 +01:00
parent 639afe9b95
commit 2e5cda6689
70 changed files with 2946 additions and 1858 deletions

View File

@@ -8,40 +8,39 @@
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
QMetaObject, QObject, QPoint, QRect,
QSize, QTime, QUrl, Qt)
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
QFont, QFontDatabase, QGradient, QIcon,
QImage, QKeySequence, QLinearGradient, QPainter,
QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QApplication, QDialog, QGridLayout, QSizePolicy,
QTabWidget, QWidget)
from PySide6.QtCore import (
QCoreApplication,
QMetaObject,
)
from PySide6.QtWidgets import (
QGridLayout,
QTabWidget,
)
class Ui_Dialog(object):
def setupUi(self, Dialog):
if not Dialog.objectName():
Dialog.setObjectName(u"Dialog")
Dialog.setObjectName("Dialog")
Dialog.resize(800, 600)
self.gridLayout_2 = QGridLayout(Dialog)
self.gridLayout_2.setObjectName(u"gridLayout_2")
self.gridLayout_2.setObjectName("gridLayout_2")
self.gridLayout = QGridLayout()
self.gridLayout.setObjectName(u"gridLayout")
self.gridLayout.setObjectName("gridLayout")
self.tabs = QTabWidget(Dialog)
self.tabs.setObjectName(u"tabs")
self.tabs.setObjectName("tabs")
self.gridLayout.addWidget(self.tabs, 0, 0, 1, 1)
self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 1, 1)
self.retranslateUi(Dialog)
QMetaObject.connectSlotsByName(Dialog)
# setupUi
def retranslateUi(self, Dialog):
Dialog.setWindowTitle(QCoreApplication.translate("Dialog", u"Dialog", None))
# retranslateUi
Dialog.setWindowTitle(QCoreApplication.translate("Dialog", "Dialog", None))
# retranslateUi

View File

@@ -2,7 +2,7 @@ import logging
import os
from wsgiref.simple_server import WSGIRequestHandler
from pyramid.config import Configurator
from flask import Flask, send_from_directory
from src import LOG_DIR
@@ -33,12 +33,16 @@ class QuietHandler(WSGIRequestHandler):
def website() -> object:
config = Configurator()
app = Flask(__name__, static_folder=os.path.join(os.getcwd(), "docs", "public"))
# 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
)
# Serve the main index.html at root
@app.route("/")
def index():
return send_from_directory(app.static_folder, "index.html")
app = config.make_wsgi_app()
return app # type: ignore
# Serve all other static files
@app.route("/<path:path>")
def serve_static(path):
return send_from_directory(app.static_folder, path)
return app

View File

@@ -8,7 +8,9 @@ from src.database import Database
from src.shared.logging import log
def recreate_file(name: str, app_id: int, filetype: str, open_file: bool = True) -> Path:
def recreate_file(
name: str, app_id: int, filetype: str, open_file: bool = True
) -> Path:
"""
Recreate a file from the database and optionally open it.
@@ -25,14 +27,14 @@ def recreate_file(name: str, app_id: int, filetype: str, open_file: bool = True)
path = db.recreateFile(name, app_id, filetype=filetype)
path = Path(path)
log.info(f"File created: {path}")
if open_file:
path = path.resolve()
if os.getenv("OS") == "Windows_NT":
os.startfile(path)
else:
os.system(f"open {path}")
return path
@@ -56,21 +58,21 @@ def recreate_elsa_file(filename: str, filetype: str, open_file: bool = True) ->
"""
if filename.startswith("(") and filename.endswith(")"):
filename = str(filename[1:-1].replace("'", ""))
if not isinstance(filename, str):
raise ValueError("filename must be a string")
db = Database()
path = db.recreateElsaFile(filename, filetype)
path = Path(path)
if open_file:
path = path.resolve()
if os.getenv("OS") == "Windows_NT":
os.startfile(path)
else:
os.system(f"open {path}")
return path
@@ -84,7 +86,7 @@ def delete_temp_contents() -> None:
"""Delete the contents of the temp directory."""
database = settings.database
path = database.temp.expanduser()
for root, dirs, files in os.walk(path, topdown=False):
for file in files:
try:
@@ -96,5 +98,5 @@ def delete_temp_contents() -> None:
os.rmdir(os.path.join(root, dir))
except Exception as e:
log.warning(f"Could not remove directory {dir}: {e}")
log.info(f"Temp directory cleared: {path}")

View File

@@ -1,11 +1,13 @@
alphabet = "abcdefghijklmnopqrstuvwxyzäöüß"
alphabet = [c for c in alphabet]
from __future__ import annotations
from string import ascii_lowercase
alphabet = [c for c in ascii_lowercase]
MAX_APP_ID = 180
def name_sort(name: str, index_len: int = 8) -> str:
"""
name_to_index converts a name to an index.
"""
"""name_sort converts a name to an index."""
name = name.lower()
sort_number = []
for i, c in enumerate(name):
@@ -17,14 +19,13 @@ def name_sort(name: str, index_len: int = 8) -> str:
for i in sort_number:
res += str(i)
# get the first 8 characters
res = res[:index_len]
return res
return res[:index_len]
def app_sort(app_id: int) -> str:
if not isinstance(app_id, int):
raise ValueError("app_id must be an integer")
if app_id >= 180:
if app_id >= MAX_APP_ID:
raise ValueError("app_id must be smaller than 180")
length = 4
app_id = str(app_id)