diff --git a/repology/parsers/parsers/ros.py b/repology/parsers/parsers/ros.py index 397f8cb9..2583a8b1 100644 --- a/repology/parsers/parsers/ros.py +++ b/repology/parsers/parsers/ros.py @@ -30,54 +30,54 @@ def ros_extract_recipe_url(key, /, *, url, tags, version, **kwargs): - release = tags["release"].format( + release = tags['release'].format( package=key, version=version, upstream_version=version, ) - if "github.com" in url: - return url.removesuffix(".git") + f"/blob/{release}/package.xml" - if "gitlab" in url: - return url.removesuffix(".git") + f"/-/blob/{release}/package.xml" + if 'github.com' in url: + return url.removesuffix('.git') + f'/blob/{release}/package.xml' + if 'gitlab' in url: + return url.removesuffix('.git') + f'/-/blob/{release}/package.xml' class RosYamlParser(Parser): def iter_parse(self, path: str, factory: PackageFactory) -> Iterable[PackageMaker]: with open(path) as f: data = load(f, Loader=Loader) - for key, packagedata in data["repositories"].items(): + for key, packagedata in data['repositories'].items(): with factory.begin(key) as pkg: # Some included packages are not yet released, # and only available as source - if "release" not in packagedata: - pkg.log(f"dropping {pkg}: no release", severity=Logger.ERROR) + if 'release' not in packagedata: + pkg.log(f'dropping {pkg}: no release', severity=Logger.ERROR) continue - release = packagedata["release"] + release = packagedata['release'] - if "version" not in release: - pkg.log(f"dropping {pkg}: has no version.", severity=Logger.ERROR) + if 'version' not in release: + pkg.log(f'dropping {pkg}: has no version.', severity=Logger.ERROR) continue - if "bitbucket" in release["url"]: - pkg.log(f"dropping {pkg}: RIP bitbucket", severity=Logger.ERROR) + if 'bitbucket' in release['url']: + pkg.log(f'dropping {pkg}: RIP bitbucket', severity=Logger.ERROR) continue pkg.add_name(key, NameType.ROS_NAME) - pkg.set_version(release["version"].split("-")[0]) + pkg.set_version(release['version'].split('-')[0]) if recipe_url := ros_extract_recipe_url(key, **release): pkg.add_links(LinkType.PACKAGE_RECIPE, recipe_url) else: - pkg.log(f"{pkg} has no known recipe url", severity=Logger.WARNING) + pkg.log(f'{pkg} has no known recipe url', severity=Logger.WARNING) - if source := packagedata.get("source"): - pkg.add_links(LinkType.UPSTREAM_HOMEPAGE, source["url"]) + if source := packagedata.get('source'): + pkg.add_links(LinkType.UPSTREAM_HOMEPAGE, source['url']) else: - pkg.log(f"{pkg} has no source", severity=Logger.WARNING) + pkg.log(f'{pkg} has no source', severity=Logger.WARNING) - if doc := packagedata.get("doc"): - pkg.add_links(LinkType.UPSTREAM_DOCUMENTATION, doc["url"]) + if doc := packagedata.get('doc'): + pkg.add_links(LinkType.UPSTREAM_DOCUMENTATION, doc['url']) yield pkg