(value)
return domain, value
domain = dot-atom / domain-literal / obs-domain
        obs-domain = atom *("." atom))
domain = dot-atom / domain-literal / obs-domain
        obs-domain = atom *("." atom))
domain = dot - atom / domain - literal / obs - domain obs - domain = atom * ( . atom ))
def get_domain(value):
    """ domain = dot-atom / domain-literal / obs-domain
        obs-domain = atom *("." atom))

    """
    domain = Domain()
    leader = None
    if value[0] in CFWS_LEADER:
        leader, value = get_cfws(value)
    if not value:
        raise errors.HeaderParseError(
            "expected domain but found '{}'".format(value))
    if value[0] == '[':
        token, value = get_domain_literal(value)
        if leader is not None:
            token[:0] = [leader]
        domain.append(token)
        return domain, value
    try:
        token, value = get_dot_atom(value)
    except errors.HeaderParseError:
        token, value = get_atom(value)
    if value and value[0] == '@':
        raise errors.HeaderParseError('Invalid Domain')
    if leader is not None:
        token[:0] = [leader]
    domain.append(token)
    if value and value[0] == '.':
        domain.defects.append(errors.ObsoleteHeaderDefect(
            "domain is not a dot-atom (contains CFWS)"))
        if domain[0].token_type == 'dot-atom':
            domain[:] = domain[0]
        while value and value[0] == '.':
            domain.append(DOT)
            token, value = get_atom(value[1:])
            domain.append(token)
    return domain, value
def get_domain ( value ) : domain = Domain ( ) leader = None if value [ 0 ] in CFWS_LEADER : leader , value = get_cfws ( value ) if not value : raise errors . HeaderParseError ( "expected domain but found '{}'" . format ( value ) ) if value [ 0 ] == '[' : token , value = get_domain_literal ( value ) if leader is not None : token [ : 0 ] = [ leader ] domain . append ( token ) return domain , value try : token , value = get_dot_atom ( value ) except errors . HeaderParseError : token , value = get_atom ( value ) if value and value [ 0 ] == '@' : raise errors . HeaderParseError ( 'Invalid Domain' ) if leader is not None : token [ : 0 ] = [ leader ] domain . append ( token ) if value and value [ 0 ] == '.' : domain . defects . append ( errors . ObsoleteHeaderDefect ( "domain is not a dot-atom (contains CFWS)" ) ) if domain [ 0 ] . token_type == 'dot-atom' : domain [ : ] = domain [ 0 ] while value and value [ 0 ] == '.' : domain . append ( DOT ) token , value = get_atom ( value [ 1 : ] ) domain . append ( token ) return domain , value