def METHOD_NAME(self, file_path, entity):
    if not entity.has("mimeType"):
        if file_path.is_dir():
            entity.add("mimeType", DirectoryIngestor.MIME_TYPE)
            return DirectoryIngestor
        entity.add("mimeType", self.MAGIC.from_file(file_path.as_posix()))
    best_score, best_cls = 0, None
    for cls in get_extensions("ingestors"):
        score = cls.match(file_path, entity)
        if score > best_score:
            best_score = score
            best_cls = cls
    if best_cls is None:
        raise ProcessingException("Format not supported")
    return best_cls