def scan_postgrey_line(date, log, collector):
 m = re.match('action=(greylist|pass), reason=(.*?), (?:delay=\\d+, )?client_name=(.*), client_address=(.*), sender=(.*), recipient=(.*)', log)
 if m:
  (action, reason, client_name, client_address, sender, recipient) = m.groups()
  key = (client_address, sender)
  if ((action == 'greylist') and (reason == 'new')):
   collector['postgrey'].setdefault(recipient, {})[key] = (date, None)
  elif ((action == 'pass') and (reason == 'triplet found') and (key in collector['postgrey'].get(recipient, {}))):
   collector['postgrey'][recipient][key] = (collector['postgrey'][recipient][key][0], date)

def scan_postgrey_line ( date , log , collector ) : m = re . match ( 'action=(greylist|pass), reason=(.*?), (?:delay=\\d+, )?client_name=(.*), client_address=(.*), sender=(.*), recipient=(.*)' , log ) if m : ( action , reason , client_name , client_address , sender , recipient ) = m . groups ( ) key = ( client_address , sender ) if ( ( action == 'greylist' ) and ( reason == 'new' ) ) : collector [ 'postgrey' ] . setdefault ( recipient , { } ) [ key ] = ( date , None ) elif ( ( action == 'pass' ) and ( reason == 'triplet found' ) and ( key in collector [ 'postgrey' ] . get ( recipient , { } ) ) ) : collector [ 'postgrey' ] [ recipient ] [ key ] = ( collector [ 'postgrey' ] [ recipient ] [ key ] [ 0 ] , date )
scan a postgrey log line and extract interesting data .