Files
Udacity_Nanodegree_Intermed…/Meme_Generator/QuoteEngine/IngestorInterface.py

25 lines
665 B
Python

"""Ingestor Interface module for quote ingestion."""
from abc import ABC, abstractmethod
from typing import List
from .QuoteModel import QuoteModel
class IngestorInterface(ABC):
"""Base Ingestor Interface."""
allowed_extensions = []
@classmethod
def can_ingest(cls, path: str) -> bool:
"""Check if the ingestor can ingest the file based on its extension."""
ext = path.split(".")[-1]
return ext in cls.allowed_extensions
@classmethod
@abstractmethod
def parse(cls, path: str) -> List[QuoteModel]:
"""Abstract method to parse the file and return a list of QuoteModel
objects."""
pass