Convert the UNTL posted data to a Python dictionary.

def post2pydict(post, ignore_list):
    """Convert the UNTL posted data to a Python dictionary."""
    root_element = PYUNTL_DISPATCH['metadata']()
    untl_form_dict = {}
    # Turn the posted data into usable data
    # (otherwise the value lists get messed up).
    form_post = dict(post.copy())
    # Loop through all the field lists.
    for key, value_list in form_post.items():
        if key not in ignore_list:
            # Split the key into the element_tag (ex. title)
            # and element attribute (ex. qualifier, content).
            (element_tag, element_attribute) = key.split('-', 1)
            if element_tag not in untl_form_dict:
                untl_form_dict[element_tag] = ()
            # Add the value list to the dictionary.
            untl_form_dict[element_tag] += (element_attribute, value_list),

    for element_tag, attribute_tuple in untl_form_dict.items():
        # Get the count of attributes/content in the element tuple.
        attribute_count = len(attribute_tuple)
        # Get the count of the first attribute's values.
        value_count = len(attribute_tuple[0][1])
        # Check to see that all attribute/content values align numerically.
        for i in range(0, attribute_count):
            if not len(attribute_tuple[i][1]) == value_count:
                raise PyuntlException('Field values did not match up '
                                      'numerically for %s' % (element_tag))
        # Create a value loop to get all values from the tuple.
        for i in range(0, value_count):
            untl_element = None
            content = ''
            qualifier = ''
            child_list = []
            # Loop through the attributes.
            # attribute_tuple[j][0] represents the attribute/content name.
            # attribute_tuple[j][1][i] represents the
            # current attribute/content value.
            for j in range(0, attribute_count):
                if attribute_tuple[j][0] == 'content':
                    content = unicode(attribute_tuple[j][1][i])
                elif attribute_tuple[j][0] == 'qualifier':
                    qualifier = attribute_tuple[j][1][i]
                # Create a child UNTL element from the data.
                else:
                    # If the child has content, append it to the child list.
                    if attribute_tuple[j][1][i] != '':
                        child_tag = attribute_tuple[j][0]
                        # Check if the child is the attribute of the element.
                        if child_tag in PARENT_FORM:
                            qualifier = attribute_tuple[j][1][i]
                        # Else, the child is a normal child of the element.
                        else:
                            child_list.append(
                                PYUNTL_DISPATCH[attribute_tuple[j][0]](
                                    content=attribute_tuple[j][1][i]
                                )
                            )
            # Create the UNTL element.
            if content != '' and qualifier != '':
                untl_element = PYUNTL_DISPATCH[element_tag](content=content,
                                                            qualifier=qualifier)
            elif content != '':
                untl_element = PYUNTL_DISPATCH[element_tag](content=content)
            elif qualifier != '':
                untl_element = PYUNTL_DISPATCH[element_tag](qualifier=qualifier)
            # This element only has children elements.
            elif len(child_list) > 0:
                untl_element = PYUNTL_DISPATCH[element_tag]()
            # If the element has children, add them.
            if len(child_list) > 0 and untl_element is not None:
                for child in child_list:
                    untl_element.add_child(child)
            # Add the UNTL element to the root element.
            if untl_element is not None:
                root_element.add_child(untl_element)
    return root_element.create_element_dict()