def make_catalog_db(catalogitems):
    'Takes an array of catalog items and builds some indexes so we can\n    get our common data faster. Returns a dict we can use like a database'
    name_table = {}
    pkgid_table = {}
    itemindex = (- 1)
    for item in catalogitems:
        itemindex = (itemindex + 1)
        name = item.get('name', 'NO NAME')
        vers = item.get('version', 'NO VERSION')
        if ((name == 'NO NAME') or (vers == 'NO VERSION')):
            display.display_warning('Bad pkginfo: %s', item)
        vers = pkgutils.trim_version_string(vers)
        if (not (name in name_table)):
            name_table[name] = {}
        if (not (vers in name_table[name])):
            name_table[name][vers] = []
        name_table[name][vers].append(itemindex)
        for receipt in item.get('receipts', []):
            if (('packageid' in receipt) and ('version' in receipt)):
                pkg_id = receipt['packageid']
                version = receipt['version']
                if (not (pkg_id in pkgid_table)):
                    pkgid_table[pkg_id] = {}
                if (not (version in pkgid_table[pkg_id])):
                    pkgid_table[pkg_id][version] = []
                pkgid_table[pkg_id][version].append(itemindex)
    updaters = [item for item in catalogitems if item.get('update_for')]
    for update in updaters:
        if is_a_string(update['update_for']):
            update['update_for'] = [update['update_for']]
    autoremoveitems = [item.get('name') for item in catalogitems if item.get('autoremove')]
    autoremoveitems = list(set(autoremoveitems))
    pkgdb = {}
    pkgdb['named'] = name_table
    pkgdb['receipts'] = pkgid_table
    pkgdb['updaters'] = updaters
    pkgdb['autoremoveitems'] = autoremoveitems
    pkgdb['items'] = catalogitems
    return pkgdb
Takes an array of catalog items and builds some indexes so we can
get our common data faster. Returns a dict we can use like a database
def make_catalog_db(catalogitems):
    'Takes an array of catalog items and builds some indexes so we can\n    get our common data faster. Returns a dict we can use like a database'
    name_table = {}
    pkgid_table = {}
    itemindex = (- 1)
    for item in catalogitems:
        itemindex = (itemindex + 1)
        name = item.get('name', 'NO NAME')
        vers = item.get('version', 'NO VERSION')
        if ((name == 'NO NAME') or (vers == 'NO VERSION')):
            display.display_warning('Bad pkginfo: %s', item)
        vers = pkgutils.trim_version_string(vers)
        if (not (name in name_table)):
            name_table[name] = {}
        if (not (vers in name_table[name])):
            name_table[name][vers] = []
        name_table[name][vers].append(itemindex)
        for receipt in item.get('receipts', []):
            if (('packageid' in receipt) and ('version' in receipt)):
                pkg_id = receipt['packageid']
                version = receipt['version']
                if (not (pkg_id in pkgid_table)):
                    pkgid_table[pkg_id] = {}
                if (not (version in pkgid_table[pkg_id])):
                    pkgid_table[pkg_id][version] = []
                pkgid_table[pkg_id][version].append(itemindex)
    updaters = [item for item in catalogitems if item.get('update_for')]
    for update in updaters:
        if is_a_string(update['update_for']):
            update['update_for'] = [update['update_for']]
    autoremoveitems = [item.get('name') for item in catalogitems if item.get('autoremove')]
    autoremoveitems = list(set(autoremoveitems))
    pkgdb = {}
    pkgdb['named'] = name_table
    pkgdb['receipts'] = pkgid_table
    pkgdb['updaters'] = updaters
    pkgdb['autoremoveitems'] = autoremoveitems
    pkgdb['items'] = catalogitems
    return pkgdb