def on_report_values(self,
                         progress: ProgressTask = None) -> ErrorCollector:
        """Erstellen der Wertungstabellen

        Args:
            progress (ProgressTask, optional): Fortschrittsanzeige. Defaults to None.

        Returns:
            ErrorCollector: Fehler
        """
        errors = ErrorCollector()

        for station in self.database.get_stations():
            for group in self.database.get_groups():
                table = ValuesReportTable(self.folder, self.settings,
                                          self.database, station, group)
                table.open()
                if errors.has_error():
                    return errors

                table.write()
                if errors.has_error():
                    return errors

                if progress:
                    progress.inc_value()

        if errors.has_error():
            return errors

        logging.info("Wertungszettel wurden erfolgreich erstellt.")
        return errors
def main(force_open=False):
    """Hauptfunktion

    Args:
        force_open (bool, optional): True, wenn Ordnerdialog erzwungen werden soll. Defaults to False.
    """
    # TKinter initialisieren
    root = tkinter.Tk()
    root.iconbitmap(ICON_PATH)
    root.withdraw()

    # Ordner abfragen, ggf. Dialog öffnen
    folder = CompetitionLoader.read_last_path()
    if not folder or force_open:
        folder = CompetitionLoader.open_dialog(os.getcwd())
        if not folder:
            return

    # Veranstaltung initialisieren
    errors = ErrorCollector()
    competition = CompetitionLoader.load(folder)
    if (competition is None) or errors.has_error():
        errors.show_messagebox()
        return
    else:
        errors.remove()

    CompetitionLoader.write_last_path(competition.folder)

    # GUI öffnen, Aktionen beim Beenden
    reason = competition.open_gui(root)
    if reason == ExitReason.OPEN:
        main(True)
    elif reason == ExitReason.REFRESH:
        main()
    def on_report_group(self) -> ErrorCollector:
        """Erstellen der Riegenübersicht

        Returns:
            ErrorCollector: Fehler
        """
        errors = ErrorCollector()

        table = GroupReportTable(self.folder, self.settings, self.database)
        table.open()
        if errors.has_error():
            return errors

        table.write()
        if errors.has_error():
            return errors

        logging.info("Riegenübersicht wurde erfolgreich erstellt.")
        return errors
    def on_scoring_refresh(
            self,
            progress: ProgressTask = None) -> (ErrorCollector, typing.List):
        """Einlesen der Wertungstabellen

         Args:
            progress (ProgressTask, optional): Fortschrittsanzeige. Defaults to None.

        Returns:
            ErrorCollector: Fehler
            typing.List: Matrix
        """
        errors = ErrorCollector()
        matrix = []

        self.database.remove_all_scoring_values()

        for station in self.database.get_stations():
            matrix_line = []
            for group in self.database.get_groups():
                table = ValuesInputTable(self.folder, self.settings,
                                         self.database, station, group)
                if table.file_exists():
                    table.open()
                else:
                    table.status = logging.ERROR

                if progress:
                    progress.inc_value()

                matrix_line.append(table.status)
            matrix.append(matrix_line)

        if errors.has_error():
            return errors, matrix

        logging.info("Wertungszettel wurden erfolgreich eingelesen.")
        return errors, matrix
    def on_scoring_create(self,
                          progress: ProgressTask = None) -> ErrorCollector:
        """Auswertung erstellen.

        Args:
            progress (ProgressTask, optional): Fortschrittsanzeige. Defaults to None.

        Returns:
            ErrorCollector: Fehler
        """
        errors = ErrorCollector()

        table = ScoringTable(self.folder, self.settings, self.database,
                             progress)
        table.open()
        if errors.has_error():
            return errors

        table.write()
        if errors.has_error():
            return errors

        logging.info("Auswertung wurde erfolgreich erstellt.")
        return errors
    def on_report_stations(self,
                           progress: ProgressTask = None) -> ErrorCollector:
        """Erstellen der Stationszettel

        Args:
            progress (ProgressTask, optional): Fortschrittsanzeige. Defaults to None.

        Returns:
            ErrorCollector: Fehler
        """
        errors = ErrorCollector()

        table = StationReportTable(self.folder, self.settings, self.database,
                                   progress)
        table.open()
        if errors.has_error():
            return errors

        table.write()
        if errors.has_error():
            return errors

        logging.info("Stationszettel wurde erfolgreich erstellt.")
        return errors
import logging

import coloredlogs

from util.error_collector import ErrorCollector

coloredlogs.install(fmt='%(asctime)s,%(msecs)d %(levelname)-5s '
                    '[%(filename)s:%(lineno)d] %(message)s',
                    datefmt='%Y-%m-%d:%H:%M:%S',
                    level=logging.DEBUG)

logging.info("Hallo Welt!")
logging.error("Test!")

ec = ErrorCollector()
logging.info("hi! %s", "data")
logging.error("Error!")
ec.show_messagebox()
    def load(cls, folder: str) -> Competition:
        """Laden der Veranstaltung

        Args:
            folder (str): Ordner der Veranstaltung

        Returns:
            Competition: Veranstaltung
        """
        errors = ErrorCollector()

        # Ordner überprüfen
        if not os.path.isdir(folder):
            logging.error("Angegebner Ordner %s existiert nicht.", folder)
            return None

        # Einstellungen lesen
        settings = SettingsTable(folder)
        settings.open()
        if errors.has_error():
            errors.remove()
            return None

        # Datenbank erstellen, Gruppen und Stationen auslesen
        database = Database(settings)
        settings.read_groups(database)
        settings.read_stations(database)
        settings.read_sclasses(database)
        if errors.has_error():
            errors.remove()
            return None

        # Meldung auslesen
        attendees_table = AttendeesTable(folder, settings, database)
        attendees_table.open()
        if errors.has_error():
            errors.remove()
            return None

        database.do_grouping()
        if errors.has_error():
            errors.remove()
            return None

        return Competition(folder, settings, database)