From a84f473feb838d7c1db16c208a3e574a700a1caa Mon Sep 17 00:00:00 2001 From: Joeri Exelmans Date: Thu, 2 Mar 2023 15:46:34 +0100 Subject: [PATCH] Got rid of 'Header' class in abstract syntax (moved its attributes right into XournalFile) --- src/xopp2py/abstract_syntax.py | 12 ++++-------- src/xopp2py/parser.py | 9 ++++----- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/xopp2py/abstract_syntax.py b/src/xopp2py/abstract_syntax.py index d1cee03..c627c6b 100644 --- a/src/xopp2py/abstract_syntax.py +++ b/src/xopp2py/abstract_syntax.py @@ -3,11 +3,6 @@ from dataclasses import dataclass from decimal import Decimal -@dataclass -class Header: - creator: str # e.g., "Xournal++ 1.1.2" - fileversion: int # e.g., 4 - @dataclass class Background: type: str # could be enum @@ -37,7 +32,8 @@ class Page: @dataclass class XournalFile: - header: Header - title: str # obscure feature - preview: bytes # PNG-encoded preview of the (first page) of the file + creator: str # e.g., "Xournal++ 1.1.2" + fileversion: int # e.g., 4 + title: str # obscure feature + preview: bytes # PNG-encoded preview of the (first page) of the file pages: list[Page] \ No newline at end of file diff --git a/src/xopp2py/parser.py b/src/xopp2py/parser.py index defc091..6b9649c 100644 --- a/src/xopp2py/parser.py +++ b/src/xopp2py/parser.py @@ -50,10 +50,8 @@ def parseFile(path) -> abstract_syntax.XournalFile: for (event, element) in context: if event == "start": if element.tag == "xournal": - header = abstract_syntax.Header( - creator=element.get("creator"), - fileversion=int(element.get("fileversion")), - ) + creator=element.get("creator") + fileversion=int(element.get("fileversion")) elif element.tag == "title": title = element.text elif element.tag == "preview": @@ -65,7 +63,8 @@ def parseFile(path) -> abstract_syntax.XournalFile: raise Error("Unsupported tag:" + element.tag) return abstract_syntax.XournalFile( - header=header, + creator=creator, + fileversion=fileversion, title=title, preview=preview, pages=pages)