third_party/blink/tools/blinkpy/web_tests/models/test_expectations.py
def _reset_lines(self, path):
        """This method returns the Expectation instances for each line
        in an expectations file. If there were any modifications made
        through the remove_expectations or add_expectations member methods
        then this method will update the in memory view of the expectations
        file.

        args:
            path: Absolute path of expectations file."""
        content = self._expectations_dict[path]
        idx = list(self._expectations_dict.keys()).index(path)
        typ_expectations = self._expectations[idx]
        lines = []

        # Store Expectation instances for each line
        lineno_to_exps = defaultdict(list)

        for pattern_to_exps in (typ_expectations.individual_exps,
                                typ_expectations.glob_exps):
            for test in sorted(pattern_to_exps.keys()):
                exps = pattern_to_exps[test]
                for exp in exps:
                    lineno_to_exps[exp.lineno].append(exp)

        removed_linenos = (self._expectation_file_linenos[path] -
                           set(lineno_to_exps.keys()))
        content_lines = content.splitlines()

        for lineno, line in enumerate(content_lines, 1):
            if not line.strip() or line.strip().startswith('#'):
                lines.append(_NotExpectation(line, lineno))
                if lineno in lineno_to_exps:
                    lines.extend(lineno_to_exps[lineno])
                    lineno_to_exps.pop(lineno)
            elif lineno in removed_linenos:
                next_line = ''
                if lineno < len(content_lines):
                    next_line = content_lines[lineno].strip()

                if not next_line or next_line.startswith('#'):
                    self._maybe_remove_comments_and_whitespace(lines)
            else:
                lines.extend(lineno_to_exps[lineno])
                lineno_to_exps.pop(lineno)

        # Handle Expectation instances with line numbers outside of the
        # [1, total file line count] range. There are two cases for
        # Expectation instances with line numbers outside the valid range.
        #
        # 1, If line number is 0 then the Expectation instance will be appended
        #    to the file.
        # 2, If the line number is greater than the total number of lines then
        #    an exception will be raised.
        if lineno_to_exps:
            lines.append(_NotExpectation('', len(content_lines) + 1))

            for line in sorted(reduce(lambda x, y: x + y,
                                      list(lineno_to_exps.values())),
                               key=lambda e: e.test):
                if line.lineno:
                    raise ValueError(
                        "Expectation '%s' was given a line number that "
                        "is greater than the total line count of file %s."
                        % (line.to_string(), path))
                lines.append(line)

        self._expectation_file_linenos[path] = {
            line.lineno for line in lines
            if not isinstance(line, _NotExpectation)}

        return lines
This method returns the Expectation instances for each line
        in an expectations file. If there were any modifications made
        through the remove_expectations or add_expectations member methods
        then this method will update the in memory view of the expectations
        file.

        args:
            path: Absolute path of expectations file.
This method returns the Expectation instances for each line
in an expectations file. If there were any modifications made
through the remove_expectations or add_expectations member methods
then this method will update the in memory view of the expectations
file.

Absolute path of expectations file.
This method returns the Expectation instances for each line in an expectations file . If there were any modifications made through the remove_expectations or add_expectations member methods then this method will update the in memory view of the expectations file . Absolute path of expectations file .
def _reset_lines(self, path):
        content = self._expectations_dict[path]
        idx = list(self._expectations_dict.keys()).index(path)
        typ_expectations = self._expectations[idx]
        lines = []
        lineno_to_exps = defaultdict(list)
        for pattern_to_exps in (typ_expectations.individual_exps,
                                typ_expectations.glob_exps):
            for test in sorted(pattern_to_exps.keys()):
                exps = pattern_to_exps[test]
                for exp in exps:
                    lineno_to_exps[exp.lineno].append(exp)
        removed_linenos = (self._expectation_file_linenos[path] -
                           set(lineno_to_exps.keys()))
        content_lines = content.splitlines()
        for lineno, line in enumerate(content_lines, 1):
            if not line.strip() or line.strip().startswith(''):
                lines.append(_NotExpectation(line, lineno))
                if lineno in lineno_to_exps:
                    lines.extend(lineno_to_exps[lineno])
                    lineno_to_exps.pop(lineno)
            elif lineno in removed_linenos:
                next_line = ''
                if lineno < len(content_lines):
                    next_line = content_lines[lineno].strip()
                if not next_line or next_line.startswith(''):
                    self._maybe_remove_comments_and_whitespace(lines)
            else:
                lines.extend(lineno_to_exps[lineno])
                lineno_to_exps.pop(lineno)
         1, If line number is 0 then the Expectation instance will be appended
            to the file.
         2, If the line number is greater than the total number of lines then
            an exception will be raised.
        if lineno_to_exps:
            lines.append(_NotExpectation('', len(content_lines) + 1))
            for line in sorted(reduce(lambda x, y: x + y,
                                      list(lineno_to_exps.values())),
                               key=lambda e: e.test):
                if line.lineno:
                    raise ValueError(
                        "Expectation '%s' was given a line number that "
                        "is greater than the total line count of file %s."
                        % (line.to_string(), path))
                lines.append(line)
        self._expectation_file_linenos[path] = {
            line.lineno for line in lines
            if not isinstance(line, _NotExpectation)}
        return lines
def _reset_lines ( self , path ) : content = self . _expectations_dict [ path ] idx = list ( self . _expectations_dict . keys ( ) ) . index ( path ) typ_expectations = self . _expectations [ idx ] lines = [ ] lineno_to_exps = defaultdict ( list ) for pattern_to_exps in ( typ_expectations . individual_exps , typ_expectations . glob_exps ) : for test in sorted ( pattern_to_exps . keys ( ) ) : exps = pattern_to_exps [ test ] for exp in exps : lineno_to_exps [ exp . lineno ] . append ( exp ) removed_linenos = ( self . _expectation_file_linenos [ path ] - set ( lineno_to_exps . keys ( ) ) ) content_lines = content . splitlines ( ) for lineno , line in enumerate ( content_lines , 1 ) : if not line . strip ( ) or line . strip ( ) . startswith ( '#' ) : lines . append ( _NotExpectation ( line , lineno ) ) if lineno in lineno_to_exps : lines . extend ( lineno_to_exps [ lineno ] ) lineno_to_exps . pop ( lineno ) elif lineno in removed_linenos : next_line = '' if lineno < len ( content_lines ) : next_line = content_lines [ lineno ] . strip ( ) if not next_line or next_line . startswith ( '#' ) : self . _maybe_remove_comments_and_whitespace ( lines ) else : lines . extend ( lineno_to_exps [ lineno ] ) lineno_to_exps . pop ( lineno ) if lineno_to_exps : lines . append ( _NotExpectation ( '' , len ( content_lines ) + 1 ) ) for line in sorted ( reduce ( lambda x , y : x + y , list ( lineno_to_exps . values ( ) ) ) , key = lambda e : e . test ) : if line . lineno : raise ValueError ( "Expectation '%s' was given a line number that " "is greater than the total line count of file %s." % ( line . to_string ( ) , path ) ) lines . append ( line ) self . _expectation_file_linenos [ path ] = { line . lineno for line in lines if not isinstance ( line , _NotExpectation ) } return lines
This method returns the Expectation instances for each line
in an expectations file.
This method returns the Expectation instances for each line in an expectations file .
"""This method returns the Expectation instances for each line
        in an expectations file. If there were any modifications made
        through the remove_expectations or add_expectations member methods
        then this method will update the in memory view of the expectations
        file.

        args:
            path: Absolute path of expectations file.""" # Store Expectation instances for each line # Handle Expectation instances with line numbers outside of the # [1, total file line count] range. There are two cases for # Expectation instances with line numbers outside the valid range. # # 1, If line number is 0 then the Expectation instance will be appended #    to the file. # 2, If the line number is greater than the total number of lines then #    an exception will be raised.
self
path