human
Complete this python program:
def extract_shortcodes(data):
assistant
#Here is the Python code you requested.

    """Return data with replaced shortcodes, shortcodes.
    data is the original data, with the shortcodes replaced by UUIDs.
    a dictionary of shortcodes, where the keys are UUIDs and the values
    are the shortcodes themselves ready to process.
    """
    shortcodes = {}
    splitted = _split_shortcodes(data)
    if (not data):
        return ('', {})
    def extract_data_chunk(data):
        'Take    a    list    of    splitted    shortcodes    and    return    a    string    and    a    tail.\n\n                                The    string    is    data,    the    tail    is    ready    for    a    new    run    of    this    same    function.\n                                '
        text = []
        for (i, token) in enumerate(data):
            if (token[0] == 'SHORTCODE_START'):
                name = token[3]
                sc_id = _new_sc_id()
                text.append(sc_id)
                for j in range(i, len(data)):
                    if ((data[j][0] == 'SHORTCODE_END') and (data[j][3] == name)):
                        shortcodes[sc_id] = ''.join((t[1] for t in data[i:(j + 1)]))
                        return (''.join(text), data[(j + 1):])
                shortcodes[sc_id] = token[1]
                return (''.join(text), data[(i + 1):])
            elif (token[0] == 'TEXT'):
                text.append(token[1])
                return (''.join(text), data[1:])
            elif (token[0] == 'SHORTCODE_END'):
                raise Exception('Closing    unopened    shortcode    {}'.format(token[3]))
    text = []
    tail = splitted
    while True:
        (new_text, tail) = extract_data_chunk(tail)
        text.append(new_text)
        if (not tail):
            break
    return (''.join(text), shortcodes)