def filter_match(filename, recip, sender=None): """Check if the give e-mail addresses match lines in filename.""" import Defaults import FilterParser filter = FilterParser.FilterParser(Defaults.DB_CONNECTION) filter.read(filename) (actions, matchline) = filter.firstmatch(recip, [sender]) # print the results checking_msg = 'Checking ' + filename print checking_msg print '-' * len(checking_msg) if recip: print 'To:', recip if sender: print 'From:', sender print '-' * len(checking_msg) if actions: print 'MATCH:', matchline else: print 'Sorry, no matching lines.'