def spawn_package(**custom_args: Any) -> PackageDataDetailed: args: Dict[str, Any] = { 'repo': 'dummyrepo', 'family': 'dummyfamily', 'subrepo': None, 'name': 'dummyname', 'srcname': None, 'binname': None, 'visiblename': 'dummyname', 'trackname': None, 'effname': 'dummyname', 'version': '0', 'origversion': '0', 'rawversion': '0', 'maintainers': [], 'category': None, 'comment': None, 'licenses': [], 'links': [], 'versionclass': 0, 'flags': 0, } args.update(custom_args) return PackageDataDetailed(**args)
def project_versions(name: str) -> Any: metapackage = get_db().get_metapackage(name) if not metapackage or metapackage['num_repos'] == 0: return handle_nonexisting_project(name, metapackage) packages = [ PackageDataDetailed(**item) for item in get_db().get_metapackage_packages(name, detailed=True) ] packages_by_repo: Dict[str, List[PackageDataDetailed]] = defaultdict(list) for package in packages: packages_by_repo[package.repo].append(package) for repo, repo_packages in packages_by_repo.items(): packages_by_repo[repo] = packageset_sort_by_version(repo_packages) return flask.render_template( 'project-versions.html', name=name, metapackage=metapackage, packages=packages, packages_by_repo=packages_by_repo, reponames_absent=[ reponame for reponame in repometadata.active_names() if reponame not in packages_by_repo ])
def api_v1_project(name: str) -> Any: return (dump_json( list( api_v1_package_to_json(PackageDataDetailed(**item)) for item in get_db().get_metapackage_packages(name, detailed=True))), { 'Content-type': 'application/json' })
def project_information(name: str) -> Any: metapackage = get_db().get_metapackage(name) if not metapackage or metapackage['num_repos'] == 0: return handle_nonexisting_project(name, metapackage) packages = sorted( (PackageDataDetailed(**item) for item in get_db().get_metapackage_packages(name, detailed=True)), key=lambda package: package.repo + package.visiblename + package. version) information: Dict[str, Any] = {} def append_info(infokey: str, infoval: str, package: PackageDataDetailed) -> None: if infokey not in information: information[infokey] = {} if infoval not in information[infokey]: information[infokey][infoval] = set() information[infokey][infoval].add(package.family) for package in packages: append_info('names', package.visiblename, package) append_info('versions', package.version, package) append_info('repos', package.repo, package) if package.comment: append_info('summaries', package.comment, package) for maintainer in package.maintainers: append_info('maintainers', maintainer, package) if package.category: append_info('categories', package.category, package) if package.homepage: append_info('homepages', package.homepage, package) for download in package.downloads: append_info('downloads', download, package) for license_ in package.licenses: append_info('licenses', license_, package) if 'repos' in information: # preserve repos order information['repos'] = [(reponame, information['repos'][reponame]) for reponame in repometadata.active_names() if reponame in information['repos']] versions = packageset_aggregate_by_version( packages, {PackageStatus.LEGACY: PackageStatus.OUTDATED}) return flask.render_template( 'project-information.html', name=name, metapackage=metapackage, information=information, versions=versions, link_statuses=get_db().get_metapackage_link_statuses(name))
def api_v1_projects(bound: Optional[str] = None) -> Any: filterinfo = MetapackagesFilterInfo() filterinfo.parse_flask_args() request = filterinfo.get_request() request.set_bound(bound) metapackages = get_db().query_metapackages( **request.__dict__, limit=config['METAPACKAGES_PER_PAGE']) metapackages = packages_to_metapackages( PackageDataDetailed(**item) for item in get_db().get_metapackages_packages( list(metapackages.keys()), detailed=True)) metapackages = { metapackage_name: [api_v1_package_to_json(package) for package in packageset] for metapackage_name, packageset in metapackages.items() } return (dump_json(metapackages), {'Content-type': 'application/json'})
def project_packages(name: str) -> Response: metapackage = get_db().get_metapackage(name) if not metapackage or metapackage['num_repos'] == 0: return handle_nonexisting_project(name, metapackage) packages_by_repo: Dict[str, List[PackageDataDetailed]] = defaultdict(list) for package in (PackageDataDetailed(**item) for item in get_db().get_metapackage_packages(name, detailed=True)): packages_by_repo[package.repo].append(package) packages: List[PackageDataDetailed] = [] for repo in repometadata.active_names(): if repo in packages_by_repo: packages.extend( packageset_sort_by_name_version(packages_by_repo[repo])) return flask.render_template('project-packages.html', name=name, metapackage=metapackage, packages=packages, links=get_db().get_project_links(name))
def project_information(name: str) -> Response: metapackage = get_db().get_metapackage(name) if not metapackage or metapackage['num_repos'] == 0: return handle_nonexisting_project(name, metapackage) packages = sorted( (PackageDataDetailed(**item) for item in get_db().get_metapackage_packages(name, detailed=True)), key=lambda package: (package.repo, package.visiblename, package.version)) information: Dict[str, Any] = {} def append_info(infokey: str, infoval: Any, package: PackageDataDetailed) -> None: if infokey not in information: information[infokey] = {} if infoval not in information[infokey]: information[infokey][infoval] = set() information[infokey][infoval].add(package.family) for package in packages: append_info('names', package.projectname_seed, package) append_info('versions', package.version, package) append_info('repos', package.repo, package) if package.comment: append_info('summaries', package.comment, package) if package.maintainers is not None: for maintainer in package.maintainers: append_info('maintainers', maintainer, package) if package.category: append_info('categories', package.category, package) if package.licenses is not None: for license_ in package.licenses: append_info('licenses', license_, package) if package.links is not None: maybe_raw_links = defaultdict(list) for link_type, link_id in package.links: if link_type in [ LinkType.UPSTREAM_HOMEPAGE, LinkType.PROJECT_HOMEPAGE ]: append_info('homepages', link_id, package) elif link_type in [ LinkType.UPSTREAM_DOWNLOAD, LinkType.PROJECT_DOWNLOAD ]: append_info('downloads', link_id, package) elif link_type == LinkType.UPSTREAM_ISSUE_TRACKER: append_info('issues', link_id, package) elif link_type == LinkType.UPSTREAM_REPOSITORY: append_info('repositories', link_id, package) elif link_type == LinkType.UPSTREAM_DOCUMENTATION: append_info('documentation', link_id, package) elif link_type == LinkType.PACKAGE_HOMEPAGE: append_info('packages', link_id, package) elif link_type == LinkType.PACKAGE_RECIPE: maybe_raw_links['recipes'].append(link_id) elif link_type == LinkType.PACKAGE_RECIPE_RAW: maybe_raw_links['recipes_raw'].append(link_id) elif link_type == LinkType.PACKAGE_PATCH: maybe_raw_links['patches'].append(link_id) elif link_type == LinkType.PACKAGE_PATCH_RAW: maybe_raw_links['patches_raw'].append(link_id) elif link_type == LinkType.PACKAGE_BUILD_LOG: maybe_raw_links['buildlogs'].append(link_id) elif link_type == LinkType.PACKAGE_BUILD_LOG_RAW: maybe_raw_links['buildlogs_raw'].append(link_id) # for links which may have both human-readlabe and raw flavors, we # prefer human-readable ones here for key in ['recipes', 'patches', 'buildlogs']: if key in maybe_raw_links: for link_id in maybe_raw_links[key]: append_info(key, link_id, package) elif key + '_raw' in maybe_raw_links: for link_id in maybe_raw_links[key + '_raw']: append_info(key, link_id, package) if 'repos' in information: # preserve repos order information['repos'] = [(reponame, information['repos'][reponame]) for reponame in repometadata.active_names() if reponame in information['repos']] versions = packageset_aggregate_by_version( packages, {PackageStatus.LEGACY: PackageStatus.OUTDATED}) links = get_db().get_project_links(name) for key in [ 'homepages', 'downloads', 'issues', 'repositories', 'patches', 'buildlogs', 'documentation', 'recipes' ]: if key in information: information[key] = sorted( information[key].items(), key=lambda l: links[l[0]]['url'].lower() # type: ignore ) return flask.render_template('project-information.html', name=name, metapackage=metapackage, information=information, versions=versions, links=links)