23 lines
753 B
Python
23 lines
753 B
Python
"""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)
|