| 138 | |
| 139 | import abc |
| 140 | class FormalParserInterface(metaclass=abc.ABCMeta): |
| 141 | @classmethod |
| 142 | def __subclasshook__(cls, subclass): |
| 143 | return (hasattr(subclass, 'load_data_source') and |
| 144 | callable(subclass.load_data_source) and |
| 145 | hasattr(subclass, 'extract_text') and |
| 146 | callable(subclass.extract_text) or |
| 147 | NotImplemented) |
| 148 | |
| 149 | @abc.abstractmethod |
| 150 | def load_data_source(self, path: str, file_name: str): |
| 151 | """Load in the data set""" |
| 152 | raise NotImplementedError |
| 153 | |
| 154 | @abc.abstractmethod |
| 155 | def extract_text(self, full_file_path: str): |
| 156 | """Extract text from the data set""" |
| 157 | raise NotImplementedError |
| 158 | |
| 159 | class PdfParserNew(FormalParserInterface): |
| 160 | """Extract text from a PDF.""" |
nothing calls this directly
no outgoing calls
no test coverage detected