def get_package_versions(self, name): """ Return the package canonical name for a given package `name`. name : str Name of the package """ package_data = self._packages.get(name) versions = [] if package_data: versions = sort_versions(list(package_data.get('versions', []))) return versions
def _load_repodata(repodata, metadata=None, python_version=None): """ Load all the available package information. See load_repadata for full documentation. """ metadata = metadata if metadata else {} # python_version = '.'.join(python_version.split('.')[:2]) all_packages = {} for channel_url, data in repodata.items(): packages = data.get('packages', {}) for canonical_name in packages: data = packages[canonical_name] # Do not filter based on python version # if (python_version and not is_dependency_met( # data['depends'], python_version, 'python')): # continue name, version, b = tuple(canonical_name.rsplit('-', 2)) if name not in all_packages: all_packages[name] = { 'versions': set(), 'size': {}, 'type': {}, 'app_entry': {}, 'app_type': {}, } elif name in metadata: temp_data = all_packages[name] temp_data['home'] = metadata[name].get('home', '') temp_data['license'] = metadata[name].get('license', '') temp_data['summary'] = metadata[name].get('summary', '') temp_data['latest_version'] = metadata[name].get('version') all_packages[name] = temp_data all_packages[name]['versions'].add(version) all_packages[name]['size'][version] = data.get('size', '') # Only the latest builds will have the correct metadata for # apps, so only store apps that have the app metadata if data.get('type'): all_packages[name]['type'][version] = data.get('type') all_packages[name]['app_entry'][version] = data.get( 'app_entry') all_packages[name]['app_type'][version] = data.get( 'app_type') all_apps = {} for name in all_packages: versions = sort_versions(list(all_packages[name]['versions'])) all_packages[name]['versions'] = versions[:] for version in versions: has_type = all_packages[name].get('type') # Has type in this case implies being an app if has_type: all_apps[name] = all_packages[name].copy() # Remove all versions that are not apps! versions = all_apps[name]['versions'][:] types = all_apps[name]['type'] app_versions = [v for v in versions if v in types] all_apps[name]['versions'] = app_versions return all_packages, all_apps