list_generator.py aktualisiert

This commit is contained in:
2025-06-29 14:53:15 +00:00
parent b37e3a791a
commit 8ab1102714

View File

@@ -30,7 +30,6 @@ SERVICE_ACCOUNT_FILE = 'service_account.json'
# --- Ende Konfiguration ---
def get_last_inputs():
"""Lädt die zuletzt verwendeten Eingaben (Typ, Einrichtung/Event, Datum, Modus)."""
try:
with open(LAST_INPUT_FILE, 'r') as f:
data = json.load(f)
@@ -42,7 +41,6 @@ def get_last_inputs():
return DEFAULT_EINRICHTUNGSTYP, DEFAULT_EINRICHTUNG_ODER_EVENT, DEFAULT_FOTODATUM_ODER_EVENTDATUM, DEFAULT_AUSGABEMODUS
def save_last_inputs(einrichtungstyp, einrichtung_event, datum_info, ausgabemodus):
"""Speichert die aktuellen Eingaben."""
try:
with open(LAST_INPUT_FILE, 'w') as f:
json.dump({"einrichtungstyp": einrichtungstyp,
@@ -98,7 +96,7 @@ def generate_kita_schule_content(docs_service, document_id_to_fill, ausgabemodus
sorted_gruppen_namen = sorted(kinder_nach_gruppen.keys())
stand_zeit = datetime.now().strftime("%d.%m.%Y %H:%M Uhr")
requests = []
requests = []
gruppen_spalten_header = "Klasse" if einrichtungstyp_kuerzel == 's' else "Gruppe"
@@ -106,7 +104,11 @@ def generate_kita_schule_content(docs_service, document_id_to_fill, ausgabemodus
gesamt_anmeldungen = 0
for gruppe_name in sorted_gruppen_namen:
anzahl = len(kinder_nach_gruppen[gruppe_name])
summary_lines.append(f"- {gruppen_spalten_header} {gruppe_name}: {anzahl} Anmeldungen")
if anzahl < 10:
anzahl_formatiert = f"{anzahl} "
else:
anzahl_formatiert = f"{anzahl} "
summary_lines.append(f"{gruppen_spalten_header} {gruppe_name}\t{anzahl_formatiert}Anmeldungen")
gesamt_anmeldungen += anzahl
summary_lines.append("--------------------")
summary_lines.append(f"Gesamt: {gesamt_anmeldungen} Anmeldungen")
@@ -193,7 +195,11 @@ def generate_familien_content(docs_service, document_id_to_fill):
gesamt_anmeldungen = 0
for tag_datum_str in sorted_tage:
anzahl = len(termine_nach_tagen[tag_datum_str])
summary_lines.append(f"- Termine am {tag_datum_str}: {anzahl} Anmeldungen")
if anzahl < 10:
anzahl_formatiert = f"{anzahl} "
else:
anzahl_formatiert = f"{anzahl} "
summary_lines.append(f"Termine am {tag_datum_str}\t{anzahl_formatiert}Anmeldungen")
gesamt_anmeldungen += anzahl
summary_lines.append("--------------------")
summary_lines.append(f"Gesamt: {gesamt_anmeldungen} Anmeldungen")
@@ -275,7 +281,7 @@ if __name__ == "__main__":
except Exception as e: print(f"Fehler Docs Erstellung: {e}")
if document_id:
initial_info_lines = [ "Info zum Kopieren für Ihre manuelle Kopf-/Fußzeile:", user_einrichtung_event, user_datum_info, "\n" + "="*70 + "\n" ]
initial_text = "\n".join(initial_info_lines) + "\n"
initial_text = "\n".join(initial_info_lines)
initial_requests = [{'insertText': {'location': {'index': 1}, 'text': initial_text}}]
try: docs_api_service.documents().batchUpdate(documentId=document_id, body={'requests': initial_requests}).execute(); print("Einmalige Info eingefügt.")
except HttpError as err: print(f"Fehler bei einmaliger Info: {err}")