def version_compare(first, second): result = v_compare(first['pkgMeta']['version'], second['pkgMeta']['version']) result = {-1: 1, 0: 0, 1: -1}.get(result) if not result: if first['target'] == '*': return 1 if second['target'] == '*': return -1 return result
def compare_picks(pick1, pick2): version1 = pick1['pkgMeta']['version'] version2 = pick2['pkgMeta']['version'] if version1 and version2: result = v_compare(version1, version2) if result: return result else: if version1: return 1 if version2: return -1 if len(pick1['dependants']) > len(pick2['dependants']): return -1 if len(pick1['dependants']) < len(pick2['dependants']): return -1 return 0