| | |
| | | from mystudy.lecture import Lecture, parse_lecture_line |
| | | from mystudy.lecture import Lecture, parse_lecture_line, Lecture2HTMLConverter |
| | | from sys import argv |
| | | |
| | | |
| | | def read_file_to_lecture(filename: str) -> list[Lecture]: |
| | | lectures = [] |
| | | with open(filename, 'r') as file: |
| | | while line := file.readline(): |
| | | if len(line.strip()) > 0: |
| | | l = parse_lecture_line(line) |
| | | lectures.append(l) |
| | | return lectures |
| | | count_line = 0 |
| | | try: |
| | | with open(filename, 'r') as file: |
| | | while line := file.readline(): |
| | | count_line += 1 |
| | | if len(line.strip()) > 0: |
| | | l = parse_lecture_line(line) |
| | | lectures.append(l) |
| | | return lectures |
| | | except (IndexError, ValueError): |
| | | print(f"[{count_line}] Dateiformat fehlerbehaftet") |
| | | |
| | | |
| | | def main(): |
| | | filename = argv[1] |
| | | print(filename) |
| | | lectures = read_file_to_lecture(filename) |
| | | for l in lectures: |
| | | print(l) |
| | | |
| | | def start(): |
| | | try: |
| | | filename = argv[1] |
| | | lectures = read_file_to_lecture(filename) |
| | | if lectures is not None: |
| | | converter = Lecture2HTMLConverter() |
| | | html_code = converter.to_html(lectures) |
| | | print(html_code) |
| | | except FileNotFoundError: |
| | | print(f"Datei '{filename}' nicht gefunden") |