def parse_string(self, string):
        """Parses a string as returned by the EHLO command and adds all
        discovered extensions. This string should *not* have the response code
        prefixed to its lines.

        :param string: The string to parse.
        :returns: The first line of the string, which will be a free-form
                  message response to the EHLO command.

        """
        header = None
        string += '\r\n'
        for match in line_pattern.finditer(string):
            if not header:
                header = match.group(1)
            else:
                ext_match = parse_pattern.match(match.group(1))
                if ext_match:
                    name = ext_match.group(1)
                    arg = ext_match.group(2)
                    if arg:
                        self.add(name, arg)
                    else:
                        self.add(name)
        return header or string.rstrip('\r\n')
dataset/ETHPy150Open slimta/python-slimta/slimta/smtp/extensions.py/Extensions.parse_string/original