<s> """<STR_LIT>""" <EOL> import re <EOL> from lxml import html as lxml_html <EOL> from config import pass_through_mailboxes , action_mailboxes , default_mailbox <EOL> from rfc_822_email_address_validator import is_valid_email_address <EOL> def valid_email_address ( email_address ) : <EOL> """<STR_LIT>""" <EOL> result = False <EOL> if email_address : <EOL> if is_valid_email_address ( email_address . strip ( '<STR_LIT>' ) ) : <EOL> result = True <EOL> return result <EOL> def get_email_address ( s ) : <EOL> """<STR_LIT>""" <EOL> for token in s . split ( ) : <EOL> if token . find ( '<STR_LIT:@>' ) > - <NUM_LIT:1> : <EOL> for email_part in token . split ( '<STR_LIT::>' ) : <EOL> if email_part . find ( '<STR_LIT:@>' ) > - <NUM_LIT:1> : <EOL> return email_part . strip ( '<STR_LIT>' ) <EOL> def domain_recipients_valid ( domain_recipients = [ ] ) : <EOL> """<STR_LIT>""" <EOL> result = None <EOL> try : <EOL> if domain_recipients [ <NUM_LIT:0> ] in action_mailboxes . keys ( ) or domain_recipients [ <NUM_LIT:0> ] in pass_through_mailboxes or default_mailbox is not None : <EOL> result = domain_recipients [ <NUM_LIT:0> ] <EOL> except IndexError : <EOL> pass <EOL> return result <EOL> subject_prefix_pattern = re . compile ( '<STR_LIT>' , re . IGNORECASE ) <EOL> def get_base_subject ( subject_string ) : <EOL> """<STR_LIT>""" <EOL> if not subject_prefix_pattern . search ( subject_string ) : <EOL> return subject_string <EOL> else : <EOL> return get_base_subject ( subject_prefix_pattern . sub ( '<STR_LIT>' , subject_string ) . lstrip ( ) ) <EOL> def get_text_from_html ( html_string ) : <EOL> """<STR_LIT>""" <EOL> document = lxml_html . document_fromstring ( html_string ) <EOL> return document . text_content ( ) </s>
