def build_attributes(attr, values, level=0):
    'Recursive function to build the DAS.'
    if isinstance(values, dict):
        (yield '{indent}{attr} {{\n'.format(indent=(level * INDENT), attr=attr))
        for (k, v) in values.items():
            for line in build_attributes(k, v, (level + 1)):
                (yield line)
        (yield '{indent}}}\n'.format(indent=(level * INDENT)))
    else:
        type = get_type(values)
        if (isinstance(values, string_types) or (not isinstance(values, Iterable)) or (getattr(values, 'shape', None) == ())):
            values = [encode(values)]
        else:
            values = map(encode, values)
        (yield '{indent}{type} {attr} {values};\n'.format(indent=(level * INDENT), type=type, attr=quote(attr), values=', '.join(values)))
Recursive function to build the DAS.
def build_attributes(attr, values, level=0):
    
    if isinstance(values, dict):
        (yield '{indent}{attr} {{\n'.format(indent=(level * INDENT), attr=attr))
        for (k, v) in values.items():
            for line in build_attributes(k, v, (level + 1)):
                (yield line)
        (yield '{indent}}}\n'.format(indent=(level * INDENT)))
    else:
        type = get_type(values)
        if (isinstance(values, string_types) or (not isinstance(values, Iterable)) or (getattr(values, 'shape', None) == ())):
            values = [encode(values)]
        else:
            values = map(encode, values)
        (yield '{indent}{type} {attr} {values};\n'.format(indent=(level * INDENT), type=type, attr=quote(attr), values=', '.join(values)))