befeleme / pyp2spec

Generate Fedora RPM spec files for Python packages
MIT License
11 stars 4 forks source link

Don't fail on missing project URL #17

Closed befeleme closed 2 years ago

befeleme commented 2 years ago

If there's no project URL, for the purposes of automatic rebuild, fill in the tag with some dummy value to indicate it has to be filled ("..." maybe?)

Traceback (most recent call last):
  File "/usr/bin/pyp2spec", line 8, in <module>
    sys.exit(main())
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/pyp2spec/pyp2spec.py", line 58, in main
    config_file = create_config(options)
  File "/usr/lib/python3.10/site-packages/pyp2spec/pyp2conf.py", line 268, in create_config
    contents = create_config_contents(
  File "/usr/lib/python3.10/site-packages/pyp2spec/pyp2conf.py", line 243, in create_config_contents
    contents["url"] = pkg.project_url()
  File "/usr/lib/python3.10/site-packages/pyp2spec/pyp2conf.py", line 101, in project_url
    return self.package_data["info"]["project_urls"]["Homepage"]
TypeError: 'NoneType' object is not subscriptable
befeleme commented 2 years ago

PyPI data always fall back to package_data["info"]["package_url"] which is in fact a PyPI package URL. Catching TypeError and letting the evaluation to fall back to the most basic address should be just enough.