third_party/blink/tools/blinkpy/common/pretty_diff.py
def parse(lines):
        """Creates a BinaryHunk instance starting with lines[0].

        Returns a tuple of the BinaryHunk instance and unconsumed lines.
        """
        match = re.match(r'(literal|delta) (\d+)', lines[0])
        if not match:
            raise ValueError('No "literal <size>" or "delta <size>".')
        bin_type = match.group(1)
        size = int(match.group(2))
        bin_data = b''

        lines = lines[1:]
        for i, line in enumerate(lines):
            if len(line) == 0:
                return (BinaryHunk(bin_type, size, bin_data), lines[i + 1:])
            line_length_letter = line[0]
            # Map a letter to a number.
            #   A-Z -> 1-26
            #   a-z -> 27-52
            line_length = 1 + ord(line_length_letter) - ord('A')
            if line_length_letter >= 'a':
                line_length = 27 + ord(line_length_letter) - ord('a')
            if line_length * 5 > (len(line) - 1) * 4:
                raise ValueError('Base85 length mismatch: length by the first '
                                 'letter:{}, actual:{}, line:"{}"'.format(
                                     line_length * 5, (len(line) - 1) * 4,
                                     line))
            if six.PY2:
                bin_data += decode_base85(line[1:])[0:line_length]
            else:
                bin_data += base64.b85decode(line[1:].encode('utf8'))
        raise ValueError('No blank line terminating a binary hunk.')
Creates a BinaryHunk instance starting with lines[0].

        Returns a tuple of the BinaryHunk instance and unconsumed lines.
        
Creates a BinaryHunk instance starting with lines[0].
Returns a tuple of the BinaryHunk instance and unconsumed lines.
Creates a BinaryHunk instance starting with lines [ 0 ] . Returns a tuple of the BinaryHunk instance and unconsumed lines .
def parse(lines):
        match = re.match(r'(literal|delta) (\d+)', lines[0])
        if not match:
            raise ValueError('No "literal <size>" or "delta <size>".')
        bin_type = match.group(1)
        size = int(match.group(2))
        bin_data = b''
        lines = lines[1:]
        for i, line in enumerate(lines):
            if len(line) == 0:
                return (BinaryHunk(bin_type, size, bin_data), lines[i + 1:])
            line_length_letter = line[0]
            line_length = 1 + ord(line_length_letter) - ord('A')
            if line_length_letter >= 'a':
                line_length = 27 + ord(line_length_letter) - ord('a')
            if line_length * 5 > (len(line) - 1) * 4:
                raise ValueError('Base85 length mismatch: length by the first '
                                 'letter:{}, actual:{}, line:"{}"'.format(
                                     line_length * 5, (len(line) - 1) * 4,
                                     line))
            if six.PY2:
                bin_data += decode_base85(line[1:])[0:line_length]
            else:
                bin_data += base64.b85decode(line[1:].encode('utf8'))
        raise ValueError('No blank line terminating a binary hunk.')
def parse ( lines ) : match = re . match ( r'(literal|delta) (\d+)' , lines [ 0 ] ) if not match : raise ValueError ( 'No "literal <size>" or "delta <size>".' ) bin_type = match . group ( 1 ) size = int ( match . group ( 2 ) ) bin_data = b'' lines = lines [ 1 : ] for i , line in enumerate ( lines ) : if len ( line ) == 0 : return ( BinaryHunk ( bin_type , size , bin_data ) , lines [ i + 1 : ] ) line_length_letter = line [ 0 ] line_length = 1 + ord ( line_length_letter ) - ord ( 'A' ) if line_length_letter >= 'a' : line_length = 27 + ord ( line_length_letter ) - ord ( 'a' ) if line_length * 5 > ( len ( line ) - 1 ) * 4 : raise ValueError ( 'Base85 length mismatch: length by the first ' 'letter:{}, actual:{}, line:"{}"' . format ( line_length * 5 , ( len ( line ) - 1 ) * 4 , line ) ) if six . PY2 : bin_data += decode_base85 ( line [ 1 : ] ) [ 0 : line_length ] else : bin_data += base64 . b85decode ( line [ 1 : ] . encode ( 'utf8' ) ) raise ValueError ( 'No blank line terminating a binary hunk.' )
Creates a BinaryHunk instance starting with lines[0].
Creates a BinaryHunk instance starting with lines [ 0 ] .
"""Creates a BinaryHunk instance starting with lines[0].

        Returns a tuple of the BinaryHunk instance and unconsumed lines.
        """ # Map a letter to a number. #   A-Z -> 1-26 #   a-z -> 27-52
lines