'Parse the capsule manifest and return a list of dictionaries containing information about
each exported repository archive contained within the capsule.'

def get_repository_info_from_manifest(self, manifest_file_path):

    repository_info_dicts = []
    (manifest_tree, error_message) = xml_util.parse_xml(manifest_file_path)
    if error_message:
        return (repository_info_dicts, error_message)
    manifest_root = manifest_tree.getroot()
    for elem in manifest_root:
        if (elem.tag != 'repository'):
            error_message = 'All    level    one    sub-elements    in    the    manifest.xml    file    must    be    <repository>    tag    sets.        '
            error_message += ('The    tag    <b><%s></b>    is    invalid.' % str(elem.tag))
            return ([], error_message)
        name = elem.get('name', None)
        owner = elem.get('username', None)
        type = elem.get('type', None)
        if ((name is None) or (owner is None) or (type is None)):
            error_message = ('Missing    required    name,    type,    owner    attributes    from    the    tag    %s' % str(elem.tag))
            return ([], error_message)
        repository_info_dict = dict(name=name, owner=owner, type=type)
        for repository_elem in elem:
            if (repository_elem.tag == 'archive'):
                archive_file_name = repository_elem.text
                repository_info_dict['archive_file_name'] = archive_file_name
                items = archive_file_name.split('-')
                changeset_revision = items[1].rstrip('.tar.gz')
                repository_info_dict['changeset_revision'] = changeset_revision
            elif (repository_elem.tag == 'categories'):
                category_names = []
                for category_elem in repository_elem:
                    if (category_elem.tag == 'category'):
                        category_names.append(category_elem.text)
                repository_info_dict['category_names'] = category_names
            elif (repository_elem.tag == 'description'):
                repository_info_dict['description'] = repository_elem.text
            elif (repository_elem.tag == 'long_description'):
                repository_info_dict['long_description'] = repository_elem.text
        repository_info_dicts.append(repository_info_dict)
    return (repository_info_dicts, error_message)
