diff --git a/src/packageurl/contrib/purl2url.py b/src/packageurl/contrib/purl2url.py index 7d0bd52..ffd4968 100644 --- a/src/packageurl/contrib/purl2url.py +++ b/src/packageurl/contrib/purl2url.py @@ -21,9 +21,6 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# Visit https://github.com/package-url/packageurl-python for support and -# download. - from packageurl import PackageURL from packageurl.contrib.route import NoRouteAvailable @@ -76,12 +73,7 @@ def get_download_url(purl): return download_url # Fallback on the `download_url` qualifier when available. - purl_data = None - try: - purl_data = PackageURL.from_string(purl) - except Exception as e: - print(f"An error occurred in get_download_url(): {e}") - return + purl_data = PackageURL.from_string(purl) return purl_data.qualifiers.get("download_url", None) @@ -315,18 +307,9 @@ def build_cocoapods_repo_url(purl): """ Return a CocoaPods repo URL from the `purl` string. """ - purl_data = None - name = None - try: - purl_data = PackageURL.from_string(purl) - name = purl_data.name - except Exception as e: - print(f"An error occurred in build_cocoapods_repo_url(): {e}") - return - - if not name: - return - return f"https://cocoapods.org/pods/{name}" + purl_data = PackageURL.from_string(purl) + name = purl_data.name + return name and f"https://cocoapods.org/pods/{name}" # Download URLs: diff --git a/tests/contrib/test_purl2url.py b/tests/contrib/test_purl2url.py index bd78ee1..a549a41 100644 --- a/tests/contrib/test_purl2url.py +++ b/tests/contrib/test_purl2url.py @@ -21,8 +21,6 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# Visit https://github.com/package-url/packageurl-python for support and -# download. import pytest @@ -66,7 +64,6 @@ def test_purl2url_get_repo_url(): "pkg:golang/gopkg.in/ldap.v3@v3.1.0": "https://pkg.go.dev/gopkg.in/ldap.v3@v3.1.0", "pkg:cocoapods/AFNetworking@4.0.1": "https://cocoapods.org/pods/AFNetworking", "pkg:cocoapods/MapsIndoors@3.24.0": "https://cocoapods.org/pods/MapsIndoors", - "pkg:cocoapods/": None, } for purl, url in purls_url.items(): @@ -141,7 +138,6 @@ def test_purl2url_get_inferred_urls(): "https://pypi.org/project/sortedcontainers/2.4.0/" ], "pkg:cocoapods/AFNetworking@4.0.1": ["https://cocoapods.org/pods/AFNetworking"], - "pkg:cocoapods/": [], "pkg:composer/psr/log@1.1.3": ["https://packagist.org/packages/psr/log#1.1.3"], "pkg:rubygems/package-name": ["https://rubygems.org/gems/package-name"], "pkg:bitbucket/birkenfeld": [],