def makeCatalogDB(catalogitems):
    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':
            munkicommon.display_warning('Bad pkginfo: %s', item)

        # normalize the version number
        vers = trimVersionString(vers)

        # build indexes for items by name and version
        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)

        # build table of receipts
        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)

    # build table of update items with a list comprehension --
    # filter all items from the catalogitems that have a non-empty
    # 'update_for' list
    updaters = [item for item in catalogitems if item.get('update_for')]

    # now fix possible admin errors where 'update_for' is a string instead
    # of a list of strings
    for update in updaters:
        if isinstance(update['update_for'], basestring):
            # convert to list of strings
            update['update_for'] = [update['update_for']]

    # build table of autoremove items with a list comprehension --
    # filter all items from the catalogitems that have a non-empty
    # 'autoremove' list
    # autoremove items are automatically removed if they are not in the
    # managed_install list (either directly or indirectly via included
    # manifests)
    autoremoveitems = [item.get('name') for item in catalogitems
                       if item.get('autoremove')]
    # convert to set and back to list to get list of unique names
    autoremoveitems = list(set(autoremoveitems))

    pkgdb = {}
    pkgdb['named'] = name_table
    pkgdb['receipts'] = pkgid_table
    pkgdb['updaters'] = updaters
    pkgdb['autoremoveitems'] = autoremoveitems
    pkgdb['items'] = catalogitems

    return pkgdb
Cleans up the needed objects used throughout the test.
dataset/ETHPy150Open munki/munki/code/client/munkilib/updatecheck.py/makeCatalogDB--crossover with--dataset/ETHPy150Open log2timeline/dfvfs/tests/vfs/tsk_partition_file_entry.py/TSKPartitionFileEntryTest.tearDown