(value)
return phrase, value
phrase = 1*word / obs-phrase
        obs-phrase = word *(word / "." / CFWS)

    This means a phrase can be a sequence of words, periods, and CFWS in any
    order as long as it starts with at least one word.  If anything other than
    words is detected, an ObsoleteHeaderDefect is added to the token's defect
    list.  We also accept a phrase that starts with CFWS followed by a dot;
    this is registered as an InvalidHeaderDefect, since it is not supported by
    even the obsolete grammar.
phrase = 1*word / obs-phrase
        obs-phrase = word *(word / "." / CFWS)
phrase = 1 * word / obs - phrase obs - phrase = word * ( word / . / CFWS )
def get_phrase(value):
    """ phrase = 1*word / obs-phrase
        obs-phrase = word *(word / "." / CFWS)

    This means a phrase can be a sequence of words, periods, and CFWS in any
    order as long as it starts with at least one word.  If anything other than
    words is detected, an ObsoleteHeaderDefect is added to the token's defect
    list.  We also accept a phrase that starts with CFWS followed by a dot;
    this is registered as an InvalidHeaderDefect, since it is not supported by
    even the obsolete grammar.

    """
    phrase = Phrase()
    try:
        token, value = get_word(value)
        phrase.append(token)
    except errors.HeaderParseError:
        phrase.defects.append(errors.InvalidHeaderDefect(
            "phrase does not start with word"))
    while value and value[0] not in PHRASE_ENDS:
        if value[0]=='.':
            phrase.append(DOT)
            phrase.defects.append(errors.ObsoleteHeaderDefect(
                "period in 'phrase'"))
            value = value[1:]
        else:
            try:
                token, value = get_word(value)
            except errors.HeaderParseError:
                if value[0] in CFWS_LEADER:
                    token, value = get_cfws(value)
                    phrase.defects.append(errors.ObsoleteHeaderDefect(
                        "comment found without atom"))
                else:
                    raise
            phrase.append(token)
    return phrase, value
def get_phrase ( value ) : phrase = Phrase ( ) try : token , value = get_word ( value ) phrase . append ( token ) except errors . HeaderParseError : phrase . defects . append ( errors . InvalidHeaderDefect ( "phrase does not start with word" ) ) while value and value [ 0 ] not in PHRASE_ENDS : if value [ 0 ] == '.' : phrase . append ( DOT ) phrase . defects . append ( errors . ObsoleteHeaderDefect ( "period in 'phrase'" ) ) value = value [ 1 : ] else : try : token , value = get_word ( value ) except errors . HeaderParseError : if value [ 0 ] in CFWS_LEADER : token , value = get_cfws ( value ) phrase . defects . append ( errors . ObsoleteHeaderDefect ( "comment found without atom" ) ) else : raise phrase . append ( token ) return phrase , value