<commit_before>from ngw.core.models import FIELD_EMAIL


def normalize_name(name):
    '''
    looks for upper case words, put them at the end
    '''
    words = name.split(' ')
    lastname = []
    while True:
        if len(words) == 0:
            break
        word = words[0]
        if word == word.upper():
            lastname.append(word)
            del words[0]
        else:
            break
    return ' '.join(words + lastname)


def parse_who_result(mailcontent):
    mailman_members = []
    for line in mailcontent.split('\n'):
        if '@' not in line:
            continue
        line = line.strip()
        if ' ' in line:
            email, name = line.split(' ', 1)
            assert (name[0] == '(' and name[-1] == ')',
                    'Invalid name, () not found on line '+line)
            name = name[1:-1]
        else:
            email = line
            name = ''
        mailman_members.append((name, email))
    return mailman_members


def format_mailadd(name, email):
    if name:
        result = name + ' '
    else:
        result = ''
    result += '<%s>' % email
    return result


def synchronise_group(cg, mailcontent):
    '''
    takes a contact group
    returns a list of tupples: ('msg', unsubscribe_addr, subscribe_addr)
    '''
    result = []
    mailman_members = parse_who_result(mailcontent)<commit_msg>Fix assert<commit_after>from ngw.core.models import FIELD_EMAIL


def normalize_name(name):
    '''
    looks for upper case words, put them at the end
    '''
    words = name.split(' ')
    lastname = []
    while True:
        if len(words) == 0:
            break
        word = words[0]
        if word == word.upper():
            lastname.append(word)
            del words[0]
        else:
            break
    return ' '.join(words + lastname)


def parse_who_result(mailcontent):
    mailman_members = []
    for line in mailcontent.split('\n'):
        if '@' not in line:
            continue
        line = line.strip()
        if ' ' in line:
            email, name = line.split(' ', 1)
            assert ((name[0] == '(' and name[-1] == ')'),
                    'Invalid name, () not found on line '+line)
            name = name[1:-1]
        else:
            email = line
            name = ''
        mailman_members.append((name, email))
    return mailman_members


def format_mailadd(name, email):
    if name:
        result = name + ' '
    else:
        result = ''
    result += '<%s>' % email
    return result


def synchronise_group(cg, mailcontent):
    '''
    takes a contact group
    returns a list of tupples: ('msg', unsubscribe_addr, subscribe_addr)
    '''
    result = []
    mailman_members = parse_who_result(mailcontent)
{'fraction_non_alphanumeric': 0.12294182217343579, 'fraction_numerical': 0.005854372484449323, 'mean_word_length': 1.8360995850622406, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4689966', 'n_tokens_mistral': 822, 'n_tokens_neox': 806, 'n_words': 224}