Update Exploring Near Earth Objects project and add Meme Generator project
This commit is contained in:
22
Meme_Generator/QuoteEngine/Ingestor.py
Normal file
22
Meme_Generator/QuoteEngine/Ingestor.py
Normal file
@@ -0,0 +1,22 @@
|
||||
"""Ingestor module to select appropriate ingestor based on file type."""
|
||||
|
||||
from typing import List
|
||||
from .IngestorInterface import IngestorInterface
|
||||
from .QuoteModel import QuoteModel
|
||||
from .CSVIngestor import CSVIngestor
|
||||
from .TextIngestor import TextIngestor
|
||||
from .DocxIngestor import DocxIngestor
|
||||
from .PDFIngestor import PDFIngestor
|
||||
|
||||
|
||||
class Ingestor(IngestorInterface):
|
||||
"""Subclass to select appropriate ingestor."""
|
||||
|
||||
ingestors = [CSVIngestor, TextIngestor, DocxIngestor, PDFIngestor]
|
||||
|
||||
@classmethod
|
||||
def parse(cls, path: str) -> List[QuoteModel]:
|
||||
"""Select the appropriate ingestor to parse the file."""
|
||||
for ingestor in cls.ingestors:
|
||||
if ingestor.can_ingest(path):
|
||||
return ingestor.parse(path)
|
||||
Reference in New Issue
Block a user