leaf_focus/report/processing/parse.py
def document(self, document: Document) -> Iterable[ReportEntry]:
        """Parse a document into report items."""

        self._logger.info(
            f"Processing document '{document.short_hash}' "
            f"with {len(document.pages)} pages."
        )

        lines = self.document_lines(document)

        line_info = []
        for line in lines:
            if not line.text:
                # empty lines should already have been filtered
                raise ValueError()

            # check if any line parser matches
            outcome = self.find_def(line)

            # record the outcome for the current line
            line_info.append(Match(line, outcome))

        # record document pages that have no lines
        expected_page_nums = {page.index for page in document.pages}
        actual_page_nums = {
            match.line.page.index
            for match in line_info
            if match and match.line and match.line.page
        }
        missing_page_nums = actual_page_nums - expected_page_nums
        for missing_page_num in sorted(missing_page_nums):
            self._skipped_pages.append(
                SkippedPage(
                    pdf_path=document.pdf_path,
                    pdf_hash_type=document.pdf_hash_type,
                    pdf_hash_value=document.pdf_hash_value,
                    pdf_page=missing_page_num,
                    pdf_url=document.pdf_url,
                )
            )

        # use the line info to build the ReportEntrys
        for item in self.report_items(document, line_info):
            yield item
Parse a document into report items.
Parse a document into report items.
Parse a document into report items .
def document(self, document: Document) -> Iterable[ReportEntry]:
        self._logger.info(
            f"Processing document '{document.short_hash}' "
            f"with {len(document.pages)} pages."
        )
        lines = self.document_lines(document)
        line_info = []
        for line in lines:
            if not line.text:
                raise ValueError()
            outcome = self.find_def(line)
            line_info.append(Match(line, outcome))
        expected_page_nums = {page.index for page in document.pages}
        actual_page_nums = {
            match.line.page.index
            for match in line_info
            if match and match.line and match.line.page
        }
        missing_page_nums = actual_page_nums - expected_page_nums
        for missing_page_num in sorted(missing_page_nums):
            self._skipped_pages.append(
                SkippedPage(
                    pdf_path=document.pdf_path,
                    pdf_hash_type=document.pdf_hash_type,
                    pdf_hash_value=document.pdf_hash_value,
                    pdf_page=missing_page_num,
                    pdf_url=document.pdf_url,
                )
            )
        for item in self.report_items(document, line_info):
            yield item
def document ( self , document : Document ) -> Iterable [ ReportEntry ] : self . _logger . info ( f"Processing document '{document.short_hash}' " f"with {len(document.pages)} pages." ) lines = self . document_lines ( document ) line_info = [ ] for line in lines : if not line . text : raise ValueError ( ) outcome = self . find_def ( line ) line_info . append ( Match ( line , outcome ) ) expected_page_nums = { page . index for page in document . pages } actual_page_nums = { match . line . page . index for match in line_info if match and match . line and match . line . page } missing_page_nums = actual_page_nums - expected_page_nums for missing_page_num in sorted ( missing_page_nums ) : self . _skipped_pages . append ( SkippedPage ( pdf_path = document . pdf_path , pdf_hash_type = document . pdf_hash_type , pdf_hash_value = document . pdf_hash_value , pdf_page = missing_page_num , pdf_url = document . pdf_url , ) ) for item in self . report_items ( document , line_info ) : yield item
Parse a document into report items.
Parse a document into report items .
"""Parse a document into report items.""" # empty lines should already have been filtered # check if any line parser matches # record the outcome for the current line # record document pages that have no lines # use the line info to build the ReportEntrys
self
document
Document