def get_page_count(self):
        super(Python, self).get_page_count()

        page_count = 1

        if self.mime_type == 'application/pdf' or self.soffice_file:
            # If file is a PDF open it with slate to determine the page count
            if self.soffice_file:
                file_object = IteratorIO(self.soffice_file).file_buffer
            else:
                file_object = self.file_object

            try:
                page_count = len(list(PDFPage.get_pages(file_object)))
            except Exception as exception:
                error_message = _(
                    'Exception determining PDF page count; %s'
                ) % exception
                logger.error(error_message)
                raise PageCountError(error_message)
            else:
                logger.debug('Document contains %d pages', page_count)
                return page_count
            finally:
                file_object.seek(0)
        else:
            try:
                image = Image.open(self.file_object)
            except __HOLE__ as exception:
                error_message = _(
                    'Exception determining PDF page count; %s'
                ) % exception
                logger.error(error_message)
                raise PageCountError(error_message)
            finally:
                self.file_object.seek(0)

            try:
                while True:
                    image.seek(image.tell() + 1)
                    page_count += 1
            except EOFError:
                # end of sequence
                pass

            return page_count
dataset/ETHPy150Open mayan-edms/mayan-edms/mayan/apps/converter/backends/python.py/Python.get_page_count