def getItemDetail(name, cataloglist, vers=''):
    def compare_version_keys(a, b):
        """Internal comparison function for use in sorting"""
        return cmp(munkicommon.MunkiLooseVersion(b),
                   munkicommon.MunkiLooseVersion(a))

    if vers == 'apple_update_metadata':
        vers = 'latest'
    else:
        (name, includedversion) = nameAndVersion(name)
        if vers == '':
            if includedversion:
                vers = includedversion
        if vers:
            vers = trimVersionString(vers)
        else:
            vers = 'latest'

    munkicommon.display_debug1(
        'Looking for detail for: %s, version %s...', name, vers)
    rejected_items = []
    for catalogname in cataloglist:
        if not catalogname in CATALOG.keys():
            # in case the list refers to a non-existent catalog
            continue

        # is name in the catalog?
        if name in CATALOG[catalogname]['named']:
            itemsmatchingname = CATALOG[catalogname]['named'][name]
            indexlist = []
            if vers == 'latest':
                # order all our items, latest first
                versionlist = itemsmatchingname.keys()
                versionlist.sort(compare_version_keys)
                for versionkey in versionlist:
                    indexlist.extend(itemsmatchingname[versionkey])

            elif vers in itemsmatchingname:
                # get the specific requested version
                indexlist = itemsmatchingname[vers]

            munkicommon.display_debug1(
                'Considering %s items with name %s from catalog %s' %
                (len(indexlist), name, catalogname))
            for index in indexlist:
                item = CATALOG[catalogname]['items'][index]
                # we have an item whose name and version matches the request.
                if item.get('minimum_munki_version'):
                    min_munki_vers = item['minimum_munki_version']
                    munkicommon.display_debug1(
                        'Considering item %s, version %s '
                        'with minimum Munki version required %s',
                        item['name'], item['version'], min_munki_vers)
                    munkicommon.display_debug1(
                        'Our Munki version is %s', MACHINE['munki_version'])
                    if (munkicommon.MunkiLooseVersion(MACHINE['munki_version'])
                            < munkicommon.MunkiLooseVersion(min_munki_vers)):
                        # skip this one, go to the next
                        reason = ('Rejected item %s, version %s '
                                  'with minimum Munki version required %s. '
                                  'Our Munki version is %s.'
                                  % (item['name'], item['version'],
                                     item['minimum_munki_version'],
                                     MACHINE['munki_version']))
                        rejected_items.append(reason)
                        continue

                # now check to see if it meets os and cpu requirements
                if item.get('minimum_os_version', ''):
                    min_os_vers = item['minimum_os_version']
                    munkicommon.display_debug1(
                        'Considering item %s, version %s '
                        'with minimum os version required %s',
                        item['name'], item['version'], min_os_vers)
                    munkicommon.display_debug1(
                        'Our OS version is %s', MACHINE['os_vers'])
                    if (munkicommon.MunkiLooseVersion(MACHINE['os_vers']) <
                            munkicommon.MunkiLooseVersion(min_os_vers)):
                        # skip this one, go to the next
                        reason = ('Rejected item %s, version %s '
                                  'with minimum os version required %s. '
                                  "Our OS version is %s."
                                  % (item['name'], item['version'],
                                     item['minimum_os_version'],
                                     MACHINE['os_vers']))
                        rejected_items.append(reason)
                        continue

                if item.get('maximum_os_version', ''):
                    max_os_vers = item['maximum_os_version']
                    munkicommon.display_debug1(
                        'Considering item %s, version %s '
                        'with maximum os version supported %s',
                        item['name'], item['version'], max_os_vers)
                    munkicommon.display_debug1(
                        'Our OS version is %s', MACHINE['os_vers'])
                    if (munkicommon.MunkiLooseVersion(MACHINE['os_vers']) >
                            munkicommon.MunkiLooseVersion(max_os_vers)):
                        # skip this one, go to the next
                        reason = ('Rejected item %s, version %s '
                                  'with maximum os version required %s. '
                                  'Our OS version is %s.'
                                  % (item['name'], item['version'],
                                     item['maximum_os_version'],
                                     MACHINE['os_vers']))
                        rejected_items.append(reason)
                        continue

                if 'supported_architectures' in item:
                    supported_arch_found = False
                    munkicommon.display_debug1(
                        'Considering item %s, version %s '
                        'with supported architectures: %s',
                        item['name'], item['version'],
                        item['supported_architectures'])
                    munkicommon.display_debug1(
                        'Our architecture is %s', MACHINE['arch'])
                    for arch in item['supported_architectures']:
                        if arch == MACHINE['arch']:
                            # we found a supported architecture that matches
                            # this machine, so we can use it
                            supported_arch_found = True
                            break
                    if (not supported_arch_found and
                            len(item['supported_architectures']) == 1 and
                            item['supported_architectures'][0] == 'x86_64' and
                            MACHINE['arch'] == 'i386' and
                            MACHINE['x86_64_capable'] == True):
                        supported_arch_found = True

                    if not supported_arch_found:
                        # we didn't find a supported architecture that
                        # matches this machine
                        reason = ('Rejected item %s, version %s '
                                  'with supported architectures: %s. '
                                  'Our architecture is %s.'
                                  % (item['name'], item['version'],
                                     item['supported_architectures'],
                                     MACHINE['arch']))
                        rejected_items.append(reason)
                        continue

                if item.get('installable_condition'):
                    pkginfo_predicate = item['installable_condition']
                    if not predicateEvaluatesAsTrue(pkginfo_predicate):
                        reason = ('Rejected item %s, version %s '
                                  'with installable_condition: %s.'
                                  % (item['name'], item['version'],
                                     item['installable_condition']))
                        rejected_items.append(reason)
                        continue

                # item name, version, minimum_os_version, and
                # supported_architecture are all OK
                munkicommon.display_debug1(
                    'Found %s, version %s in catalog %s',
                    item['name'], item['version'], catalogname)
                return item

    # if we got this far, we didn't find it.
    munkicommon.display_debug1('Not found')
    if rejected_items:
        for reason in rejected_items:
            munkicommon.display_warning(reason)

    return None
Searches the catalogs in list for an item matching the given name.
dataset/ETHPy150Open munki/munki/code/client/munkilib/updatecheck.py/getItemDetail