Verbesserung der Konfiguration des Eingabeverzeichnisses
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
[Allgemein]
|
||||
|
||||
# Pfad (relativ oder absolut zu den Eingabedateien)
|
||||
pfad = data/
|
||||
pfad = /Users/wolfgang/Documents/daten/
|
||||
@@ -2097,7 +2097,7 @@ endobj
|
||||
endobj
|
||||
357 0 obj
|
||||
<<
|
||||
/Author () /CreationDate (D:20251012163216+02'00') /Creator (\(unspecified\)) /Keywords () /ModDate (D:20251012163216+02'00') /Producer (xhtml2pdf <https://github.com/xhtml2pdf/xhtml2pdf/>)
|
||||
/Author () /CreationDate (D:20251013151454+02'00') /Creator (\(unspecified\)) /Keywords () /ModDate (D:20251013151454+02'00') /Producer (xhtml2pdf <https://github.com/xhtml2pdf/xhtml2pdf/>)
|
||||
/Subject () /Title () /Trapped /False
|
||||
>>
|
||||
endobj
|
||||
@@ -2984,7 +2984,7 @@ xref
|
||||
trailer
|
||||
<<
|
||||
/ID
|
||||
[<5a8bd7cb940f8f8099579e9bd8769a19><5a8bd7cb940f8f8099579e9bd8769a19>]
|
||||
[<758ef2327eee35bb2dae1e505bb7cc86><758ef2327eee35bb2dae1e505bb7cc86>]
|
||||
% ReportLab generated PDF document -- digest (http://www.reportlab.com)
|
||||
|
||||
/Info 357 0 R
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!python3
|
||||
#! python3
|
||||
|
||||
import os, glob, sys
|
||||
import argparse, csv
|
||||
@@ -10,26 +10,58 @@ sys.path.append(os.path.abspath("./pages"))
|
||||
import start, halbjahr, birthday, uebersicht, korrektur, somi, ha, checkliste
|
||||
|
||||
|
||||
# 1. Eingabepfad einlesen aus lehrerpdf.ini oder bevorzugt: mylehrerpdf.ini
|
||||
base_file = "mylehrerpdf.ini"
|
||||
if (not(os.path.exists(base_file))):
|
||||
base_file = "lehrerpdf.ini"
|
||||
# 1. Eingabeverzeichnis bestimmen
|
||||
# - Option 1: Argument -d auf Kommandozeile
|
||||
# - Option 2: Datei config.ini im aktuellen Verzeichnis
|
||||
# - Default : lokales Demo-Verzeichnis data/ mit fiktiven Daten
|
||||
|
||||
if (not(os.path.exists(base_file))):
|
||||
print(base_file+" nicht vorhanden!")
|
||||
exit(0)
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-d', dest='dir', required=False)
|
||||
|
||||
base = ConfigParser(allow_no_value=True)
|
||||
base.read(base_file)
|
||||
args = parser.parse_args()
|
||||
path = args.dir
|
||||
|
||||
try:
|
||||
path = base["Allgemein"]["pfad"] # Basispfad
|
||||
except KeyError:
|
||||
print('Der Schlüssel Allgemein oder "pfad" existiert nicht in der Config-Datei!')
|
||||
exit(0)
|
||||
if (not(os.path.exists(path))):
|
||||
print("Basisverzeichnis "+path+" nicht vorhanden!")
|
||||
exit(0)
|
||||
if (not(path)):
|
||||
|
||||
base_file = "config.ini"
|
||||
|
||||
if (not(os.path.exists(base_file))):
|
||||
|
||||
print("Kein Verzeichnis angegeben, verwende das Demo-Verzeichnis mit fiktiven Daten.")
|
||||
|
||||
path = "data/"
|
||||
|
||||
if (not(os.path.exists(path))):
|
||||
print("Basisverzeichnis "+path+" nicht vorhanden!")
|
||||
exit(0)
|
||||
|
||||
else:
|
||||
|
||||
base = ConfigParser(allow_no_value=True)
|
||||
base.read(base_file)
|
||||
|
||||
try:
|
||||
path = base["Allgemein"]["pfad"] # Basispfad
|
||||
except KeyError:
|
||||
print('Der Schlüssel Allgemein oder "pfad" existiert nicht in der Config-Datei!')
|
||||
exit(0)
|
||||
|
||||
print("Verwende Verzeichnis aus config.ini.")
|
||||
|
||||
if (not(os.path.exists(path))):
|
||||
print("Basisverzeichnis "+path+" nicht vorhanden!")
|
||||
exit(0)
|
||||
|
||||
else:
|
||||
|
||||
print("Verwende Verzeichnis aus Kommandozeilenoption -d")
|
||||
|
||||
if (not(os.path.exists(path))):
|
||||
print("Basisverzeichnis "+path+" nicht vorhanden!")
|
||||
exit(0)
|
||||
|
||||
if (not(path.endswith("/"))):
|
||||
path = path + "/"
|
||||
|
||||
print("Verarbeite das Verzeichnis: "+path)
|
||||
|
||||
@@ -132,7 +164,7 @@ body = body + start.erstelleStartseite(lerngruppen, path, config, inputs)
|
||||
# Verarbeite nacheinander alle Eingabedateien = Lerngruppen
|
||||
for datei in dateien:
|
||||
|
||||
print("Verarbeite Datei: "+datei)
|
||||
print(" - Verarbeite Datei: "+datei)
|
||||
|
||||
if (not(os.path.exists(datei))):
|
||||
print("Datei "+datei+" nicht vorhanden!")
|
||||
@@ -187,7 +219,7 @@ for datei in dateien:
|
||||
gebdatum = row[2]
|
||||
gebdaten.append(gebdatum)
|
||||
except IndexError:
|
||||
print(' - Einträge für Geburtstag fehlen für Lerngruppe "'+kursid+'"!')
|
||||
print(' - Einträge für Geburtstag fehlen für Lerngruppe "'+kursid+'"!')
|
||||
gebdaten = []
|
||||
gebdaten_all = False
|
||||
|
||||
@@ -220,7 +252,7 @@ for datei in dateien:
|
||||
|
||||
# Geburtstagsseite zusammenbauen
|
||||
if (len(gebdaten)==0):
|
||||
print(' - Geburtstagsliste wird weggelassen.')
|
||||
print(' - Geburtstagsliste wird weggelassen.')
|
||||
else:
|
||||
if (namen_kurzlang=="lang"):
|
||||
body = body + birthday.erstelleGeburtstagsBogen(kursid, klassekurs_name, lerngruppen, path, namen, gebdaten, config, inputs, kurs_inputs)
|
||||
|
||||
Reference in New Issue
Block a user