<s> from email . utils import parseaddr , getaddresses <EOL> class Contact ( object ) : <EOL> def __init__ ( self , raw_addr = None , parsed_raw_addr = None ) : <EOL> if raw_addr : <EOL> parsed_raw_addr = parseaddr ( raw_addr ) <EOL> self . name = parsed_raw_addr [ <NUM_LIT:0> ] <EOL> self . email = parsed_raw_addr [ <NUM_LIT:1> ] <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . name , self . email ) <EOL> @ classmethod <EOL> def create_contacts_from_message_field ( cls , field_name , message ) : <EOL> contacts = [ ] <EOL> raw_addrs = message . get_all ( field_name , [ ] ) <EOL> for parsed_raw_addr in getaddresses ( raw_addrs ) : <EOL> contacts . append ( Contact ( parsed_raw_addr = parsed_raw_addr ) ) <EOL> return contacts </s>
