leaf_focus/report/processing/parse.py
def find_def(self, line: Line) -> Outcome:
        """Check to see if the definition's first entry matches the line."""
        found = []
        for parser in self._parsers:
            text_norm = line.text
            text_norm = self._normalise.text(text_norm)
            text_norm = self._normalise.collapse_spaces(text_norm)
            text_norm = text_norm.strip().casefold()
            is_match, extracted = parser.match(text_norm)
            if is_match:
                found.append(
                    Outcome(
                        is_match=True,
                        match_count=1,
                        parser=parser,
                        extracted=extracted,
                        text=text_norm,
                    )
                )

        found_count = len(found)
        if found_count < 1:
            if line.text not in self._skipped_lines:
                self._skipped_lines[line.text] = 0
            self._skipped_lines[line.text] += 1

            return Outcome(is_match=False, match_count=0)

        if found_count == 1:
            return found[0]

        if found_count > 1:
            values = "', '".join([f.parser.value for f in found])
            raise ValueError(
                f"Text '{line.text}' matched {found_count} parsers: '{values}'."
            )
Check to see if the definition's first entry matches the line.
Check to see if the definition's first entry matches the line.
Check to see if the definition ' s first entry matches the line .
def find_def(self, line: Line) -> Outcome:
        found = []
        for parser in self._parsers:
            text_norm = line.text
            text_norm = self._normalise.text(text_norm)
            text_norm = self._normalise.collapse_spaces(text_norm)
            text_norm = text_norm.strip().casefold()
            is_match, extracted = parser.match(text_norm)
            if is_match:
                found.append(
                    Outcome(
                        is_match=True,
                        match_count=1,
                        parser=parser,
                        extracted=extracted,
                        text=text_norm,
                    )
                )
        found_count = len(found)
        if found_count < 1:
            if line.text not in self._skipped_lines:
                self._skipped_lines[line.text] = 0
            self._skipped_lines[line.text] += 1
            return Outcome(is_match=False, match_count=0)
        if found_count == 1:
            return found[0]
        if found_count > 1:
            values = "', '".join([f.parser.value for f in found])
            raise ValueError(
                f"Text '{line.text}' matched {found_count} parsers: '{values}'."
            )
def find_def ( self , line : Line ) -> Outcome : found = [ ] for parser in self . _parsers : text_norm = line . text text_norm = self . _normalise . text ( text_norm ) text_norm = self . _normalise . collapse_spaces ( text_norm ) text_norm = text_norm . strip ( ) . casefold ( ) is_match , extracted = parser . match ( text_norm ) if is_match : found . append ( Outcome ( is_match = True , match_count = 1 , parser = parser , extracted = extracted , text = text_norm , ) ) found_count = len ( found ) if found_count < 1 : if line . text not in self . _skipped_lines : self . _skipped_lines [ line . text ] = 0 self . _skipped_lines [ line . text ] += 1 return Outcome ( is_match = False , match_count = 0 ) if found_count == 1 : return found [ 0 ] if found_count > 1 : values = "', '" . join ( [ f . parser . value for f in found ] ) raise ValueError ( f"Text '{line.text}' matched {found_count} parsers: '{values}'." )
Check to see if the definition's first entry matches the line.
Check to see if the definition ' s first entry matches the line .
"""Check to see if the definition's first entry matches the line."""
self
line
Line