human
Complete the below
def get_course_update_items(course_updates, provided_index=0):

    ''''Returns list of course_updates data dictionaries either from new format if available or
    from old. This function don\'t modify old data to new data (in db), instead returns data
    in common old dictionary format.
    New Format: {"items" : [{"id": computed_id, "date": date, "content": html-string}],
    "data": "<ol>[<li><h2>date</h2>content</li>]</ol>"}
    Old Format: {"data": "<ol>[<li><h2>date</h2>content</li>]</ol>"}'
    '''

=====
Can you provide a the Python program you requested?
assistant
#Here is the Python program you requested.
    def _course_info_content(html_parsed):
        '\n                                Constructs    the    HTML    for    the    course    info    update,    not    including    the    header.\n                                '
        if (len(html_parsed) == 1):
            content = html_parsed[0].tail
        else:
            content = (html_parsed[0].tail if (html_parsed[0].tail is not None) else '')
            content += '\n'.join([html.tostring(ele) for ele in html_parsed[1:]])
        return content
    if (course_updates and getattr(course_updates, 'items', None)):
        if (provided_index and (0 < provided_index <= len(course_updates.items))):
            return course_updates.items[(provided_index - 1)]
        else:
            return list(reversed(course_updates.items))
    course_update_items = []
    if course_updates:
        try:
            course_html_parsed = html.fromstring(course_updates.data)
        except (etree.XMLSyntaxError, etree.ParserError):
            log.error(('Cannot    parse:    ' + course_updates.data))
            escaped = escape(course_updates.data)
            course_html_parsed = html.fromstring((('<ol><li>' + escaped) + '</li></ol>'))
        if (course_html_parsed.tag == 'ol'):
            for (index, update) in enumerate(course_html_parsed):
                if (len(update) > 0):
                    content = _course_info_content(update)
                    computed_id = (len(course_html_parsed) - index)
                    payload = {'id': computed_id, 'date': update.findtext('h2'), 'content': content}
                    if (provided_index == 0):
                        course_update_items.append(payload)
                    elif (provided_index == computed_id):
                        return payload
    return course_update_items