(value)
return mailbox_list, value
mailbox-list = (mailbox *("," mailbox)) / obs-mbox-list
        obs-mbox-list = *([CFWS] ",") mailbox *("," [mailbox / CFWS])

    For this routine we go outside the formal grammar in order to improve error
    handling.  We recognize the end of the mailbox list only at the end of the
    value or at a ';' (the group terminator).  This is so that we can turn
    invalid mailboxes into InvalidMailbox tokens and continue parsing any
    remaining valid mailboxes.  We also allow all mailbox entries to be null,
    and this condition is handled appropriately at a higher level.
mailbox-list = (mailbox *("," mailbox)) / obs-mbox-list
        obs-mbox-list = *([CFWS] ",") mailbox *("," [mailbox / CFWS])
mailbox - list = ( mailbox * ( mailbox )) / obs - mbox - list obs - mbox - list = * ( [ CFWS ] ) mailbox * ( [ mailbox / CFWS ] )
def get_mailbox_list(value):
    """ mailbox-list = (mailbox *("," mailbox)) / obs-mbox-list
        obs-mbox-list = *([CFWS] ",") mailbox *("," [mailbox / CFWS])

    For this routine we go outside the formal grammar in order to improve error
    handling.  We recognize the end of the mailbox list only at the end of the
    value or at a ';' (the group terminator).  This is so that we can turn
    invalid mailboxes into InvalidMailbox tokens and continue parsing any
    remaining valid mailboxes.  We also allow all mailbox entries to be null,
    and this condition is handled appropriately at a higher level.

    """
    mailbox_list = MailboxList()
    while value and value[0] != ';':
        try:
            token, value = get_mailbox(value)
            mailbox_list.append(token)
        except errors.HeaderParseError:
            leader = None
            if value[0] in CFWS_LEADER:
                leader, value = get_cfws(value)
                if not value or value[0] in ',;':
                    mailbox_list.append(leader)
                    mailbox_list.defects.append(errors.ObsoleteHeaderDefect(
                        "empty element in mailbox-list"))
                else:
                    token, value = get_invalid_mailbox(value, ',;')
                    if leader is not None:
                        token[:0] = [leader]
                    mailbox_list.append(token)
                    mailbox_list.defects.append(errors.InvalidHeaderDefect(
                        "invalid mailbox in mailbox-list"))
            elif value[0] == ',':
                mailbox_list.defects.append(errors.ObsoleteHeaderDefect(
                    "empty element in mailbox-list"))
            else:
                token, value = get_invalid_mailbox(value, ',;')
                if leader is not None:
                    token[:0] = [leader]
                mailbox_list.append(token)
                mailbox_list.defects.append(errors.InvalidHeaderDefect(
                    "invalid mailbox in mailbox-list"))
        if value and value[0] not in ',;':
            # Crap after mailbox; treat it as an invalid mailbox.
            # The mailbox info will still be available.
            mailbox = mailbox_list[-1]
            mailbox.token_type = 'invalid-mailbox'
            token, value = get_invalid_mailbox(value, ',;')
            mailbox.extend(token)
            mailbox_list.defects.append(errors.InvalidHeaderDefect(
                "invalid mailbox in mailbox-list"))
        if value and value[0] == ',':
            mailbox_list.append(ListSeparator)
            value = value[1:]
    return mailbox_list, value
def get_mailbox_list ( value ) : mailbox_list = MailboxList ( ) while value and value [ 0 ] != ';' : try : token , value = get_mailbox ( value ) mailbox_list . append ( token ) except errors . HeaderParseError : leader = None if value [ 0 ] in CFWS_LEADER : leader , value = get_cfws ( value ) if not value or value [ 0 ] in ',;' : mailbox_list . append ( leader ) mailbox_list . defects . append ( errors . ObsoleteHeaderDefect ( "empty element in mailbox-list" ) ) else : token , value = get_invalid_mailbox ( value , ',;' ) if leader is not None : token [ : 0 ] = [ leader ] mailbox_list . append ( token ) mailbox_list . defects . append ( errors . InvalidHeaderDefect ( "invalid mailbox in mailbox-list" ) ) elif value [ 0 ] == ',' : mailbox_list . defects . append ( errors . ObsoleteHeaderDefect ( "empty element in mailbox-list" ) ) else : token , value = get_invalid_mailbox ( value , ',;' ) if leader is not None : token [ : 0 ] = [ leader ] mailbox_list . append ( token ) mailbox_list . defects . append ( errors . InvalidHeaderDefect ( "invalid mailbox in mailbox-list" ) ) if value and value [ 0 ] not in ',;' : # Crap after mailbox; treat it as an invalid mailbox. # The mailbox info will still be available. mailbox = mailbox_list [ - 1 ] mailbox . token_type = 'invalid-mailbox' token , value = get_invalid_mailbox ( value , ',;' ) mailbox . extend ( token ) mailbox_list . defects . append ( errors . InvalidHeaderDefect ( "invalid mailbox in mailbox-list" ) ) if value and value [ 0 ] == ',' : mailbox_list . append ( ListSeparator ) value = value [ 1 : ] return mailbox_list , value