mirror of
https://github.com/Paillat-dev/discord-emojis.git
synced 2026-01-02 17:14:55 +00:00
♻️ Refactor implementation for future new parsers additions (#16)
This commit is contained in:
32
src/parsers/base.py
Normal file
32
src/parsers/base.py
Normal 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.
|
||||
|
||||
"""
|
||||
Reference in New Issue
Block a user