def scan_dovecot_line(date, line, collector):
 m = re.match('(imap|pop3)-login: Login: user=<(.*?)>, method=PLAIN, rip=(.*?),', line)
 if m:
  (prot, login, ip) = (m.group(1), m.group(2), m.group(3))
  logins_key = ('%s-logins' % prot)
  if (ip != '127.0.0.1'):
   collector[logins_key].setdefault(login, {})[ip] = date
  collector['activity-by-hour'][logins_key][date.hour] += 1

def scan_dovecot_line ( date , line , collector ) : m = re . match ( '(imap|pop3)-login: Login: user=<(.*?)>, method=PLAIN, rip=(.*?),' , line ) if m : ( prot , login , ip ) = ( m . group ( 1 ) , m . group ( 2 ) , m . group ( 3 ) ) logins_key = ( '%s-logins' % prot ) if ( ip != '127.0.0.1' ) : collector [ logins_key ] . setdefault ( login , { } ) [ ip ] = date collector [ 'activity-by-hour' ] [ logins_key ] [ date . hour ] += 1
scan a dovecot log line and extract interesting data .