Skip to content

Commit

Permalink
ros.py: use single quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
nim65s committed Dec 19, 2024
1 parent 4159c3a commit 7432164
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions repology/parsers/parsers/ros.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7432164

Please sign in to comment.