import re


def split_line(line):
    """ Split a line

    Treat part enclosed by parentheses as a single unit
    """
    line = re.sub('\s*=\s*','=',line)
    parts = []
    for p in re.split(',|\s',line):
        part = p.strip()
        if len(part)>0:
            parts.append(part)
    output = []
    i = 0
    # Deal with parentheses
    while i<len(parts):
        if parts[i].find('(') > -1:
            # Open parenthesis, need to find the closing one
            num_open = parts[i].count('(')
            num_close = parts[i].count(')')
            j = i
            while num_open>num_close:
                # Search until all parentheses are closed
                j += 1
                num_open += parts[j].count('(')
                num_close += parts[j].count(')')
            part = ' '.join(parts[i:j+1])
            i = j
        else:
            part = parts[i]
        output.append(part)
        i += 1
    return output