Refactor and enhance type hints across multiple modules

- Updated the `from_tuple` method in `Prof` class to specify return type.
- Added type hints for various methods in `LehmannsClient`, `OpenAI`, `WebRequest`, and `ZoteroController` classes to improve code clarity and type safety.
- Modified `pdf_to_csv` function to return a string instead of a DataFrame.
- Enhanced error handling and type hints in `wordparser` and `xmlparser` modules.
- Removed unused UI file `Ui_medianadder.ts`.
- Improved the layout and structure of the `semesterapparat_ui` to enhance user experience.
- Updated file picker to support `.doc` files in addition to `.docx`.
- Added unique item handling in `Ui` class to prevent duplicates in apparat list.
- General code cleanup and consistency improvements across various files.
This commit is contained in:
2025-10-21 09:09:54 +02:00
parent 560d8285b5
commit 0406fe4f6f
26 changed files with 437 additions and 396 deletions

View File

@@ -16,7 +16,7 @@ logger = log
font = "Cascadia Mono"
def print_document(file: str):
def print_document(file: str) -> None:
# send document to printer as attachment of email
import smtplib
from email.mime.application import MIMEApplication
@@ -98,7 +98,7 @@ class SemesterDocument:
self.filename = filename
if full:
log.info("Full document generation")
self.cleanup()
self.cleanup
log.info("Cleanup done")
self.make_document()
log.info("Document created")
@@ -221,15 +221,15 @@ class SemesterDocument:
self.create_sorted_table()
def save_document(self, name):
def save_document(self, name: str) -> None:
# Save the document
self.doc.save(name)
def create_pdf(self):
def create_pdf(self) -> None:
# Save the document
import comtypes.client
word = comtypes.client.CreateObject("Word.Application")
word = comtypes.client.CreateObject("Word.Application") # type: ignore
self.save_document(self.filename + ".docx")
docpath = os.path.abspath(self.filename + ".docx")
doc = word.Documents.Open(docpath)
@@ -240,13 +240,13 @@ class SemesterDocument:
log.debug("PDF saved")
@property
def cleanup(self):
def cleanup(self) -> None:
if os.path.exists(f"{self.filename}.docx"):
os.remove(f"{self.filename}.docx")
os.remove(f"{self.filename}.pdf")
@property
def send(self):
def send(self) -> None:
print_document(self.filename + ".pdf")
log.debug("Document sent to printer")
@@ -309,11 +309,11 @@ class SemapSchilder:
self.doc.save(f"{self.filename}.docx")
log.debug(f"Document saved as {self.filename}.docx")
def create_pdf(self):
def create_pdf(self) -> None:
# Save the document
import comtypes.client
word = comtypes.client.CreateObject("Word.Application")
word = comtypes.client.CreateObject("Word.Application") # type: ignore
self.save_document()
docpath = os.path.abspath(f"{self.filename}.docx")
doc = word.Documents.Open(docpath)
@@ -323,14 +323,14 @@ class SemapSchilder:
word.Quit()
log.debug("PDF saved")
def cleanup(self):
def cleanup(self) -> None:
if os.path.exists(f"{self.filename}.docx"):
os.remove(f"{self.filename}.docx")
if os.path.exists(f"{self.filename}.pdf"):
os.remove(f"{self.filename}.pdf")
@property
def send(self):
def send(self) -> None:
print_document(self.filename + ".pdf")
log.debug("Document sent to printer")