#NEWLINE# def parse_header_ar( self , val ) : #NEWLINE# #INDENT# "Set SPF values from RFC 5451 Authentication Results header.\n        \n        Useful when SPF has already been run on a trusted gateway machine.\n\n        Expects the entire header as an input.\n\n        Examples:\n        >>> q = query('192.0.2.3','strong-bad@email.example.com','mx.example.org')\n        >>> q.mechanism = 'unknown'\n        >>> p = q.parse_header_ar('''Authentication-Results: bmsi.com; spf=neutral \\n     (abuse@kitterman.com: 192.0.2.3 is neither permitted nor denied by domain of email.example.com) \\n     smtp.mailfrom=email.example.com \\n    (sender=strong-bad@email.example.com; helo=mx.example.org; client-ip=192.0.2.3; receiver=abuse@kitterman.com; mechanism=?all)''')\n        >>> q.get_header(q.result, header_type='authres', aid='bmsi.com')\n        'Authentication-Results: bmsi.com; spf=neutral (unknown: 192.0.2.3 is neither permitted nor denied by domain of email.example.com) smtp.mailfrom=email.example.com (sender=email.example.com; helo=mx.example.org; client-ip=192.0.2.3; receiver=unknown; mechanism=unknown)'\n        >>> p = q.parse_header_ar('''Authentication-Results: bmsi.com; spf=None (mail.bmsi.com: test; client-ip=163.247.46.150) smtp.mailfrom=admin@squiebras.cl (helo=mail.squiebras.cl; receiver=mail.bmsi.com;\\n mechanism=mx/24)''')\n        >>> q.get_header(q.result, header_type='authres', aid='bmsi.com')\n        'Authentication-Results: bmsi.com; spf=none (unknown: 192.0.2.3 is neither permitted nor denied by domain of email.example.com) smtp.mailfrom=admin@squiebras.cl (sender=admin@squiebras.cl; helo=mx.example.org; client-ip=192.0.2.3; receiver=unknown; mechanism=unknown)'\n        " #NEWLINE# import authres #NEWLINE# val = ' ' . join ( ( s . strip ( ) for s in val . split ( '\n' ) ) ) #NEWLINE# arobj = authres . AuthenticationResultsHeader . parse ( val ) #NEWLINE# for resobj in arobj . results : #NEWLINE# #INDENT# if ( resobj . method == 'spf' ) : #NEWLINE# #INDENT# self . authserv = arobj . authserv_id #NEWLINE# self . result = resobj . result #NEWLINE# if ( resobj . properties [ 0 ] . name == 'mailfrom' ) : #NEWLINE# #INDENT# self . d = resobj . properties [ 0 ] . value #NEWLINE# self . s = resobj . properties [ 0 ] . value #NEWLINE# #UNINDENT# if ( resobj . properties [ 0 ] . name == 'helo' ) : #NEWLINE# #INDENT# self . h = resobj . properties [ 0 ] . value #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return