♻️ Refactor implementation for future new parsers additions (#16)

This commit is contained in:
2025-10-01 20:38:30 +02:00
committed by GitHub
parent a9d753ed25
commit a1e97fc1b2
9 changed files with 179 additions and 104 deletions

32
src/parsers/base.py Normal file
View File

@@ -0,0 +1,32 @@
# Copyright (c) Paillat-dev
# SPDX-License-Identifier: MIT
from abc import ABC, abstractmethod
class ParseError(Exception, ABC):
"""Base class for all parsing errors."""
class BuildParser(ABC):
"""Base class for all build parsers."""
FILE_NAME: str
def __init__(self, discord_build: str) -> None:
"""Initialize the parser with the discord build.
Args:
discord_build (str): The content of the discord build to parse.
"""
self.discord_build: str = discord_build
@abstractmethod
def __call__(self) -> tuple[bytes, str]:
"""Return a tuple of the parsed data we want to obtain and a hash for verifying whether the data has changed.
Returns:
Tuple[T, str]: A tuple containing the parsed data and a hash string.
"""