-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Refactor purl2url into get_repo_url and get_download_url #42 Signed-off-by: Thomas Druez <[email protected]> * Add support for nuget in purl2url.get_download_url #42 Signed-off-by: Thomas Druez <[email protected]> * Add get_inferred_urls function to return all inferred URLs #42 Signed-off-by: Thomas Druez <[email protected]> * Include the `version_prefix` as a qualifier to infer valid URLs #42 Signed-off-by: Thomas Druez <[email protected]> * Fix formatting with black #42 Signed-off-by: Thomas Druez <[email protected]> * Add support for qualifiers in purl_from_pattern #42 Qualifier `download_url` is now supported in build_github_download_url Signed-off-by: Thomas Druez <[email protected]> * Return the download_url qualifier when available in get_download_url #42 Signed-off-by: Thomas Druez <[email protected]> * Add changelog entry #42 Signed-off-by: Thomas Druez <[email protected]>
- Loading branch information
Showing
6 changed files
with
455 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ Join the discussion at https://gitter.im/package-url/Lobby or enter a ticket for | |
|
||
License: MIT | ||
|
||
|
||
Tests and build status | ||
====================== | ||
|
||
|
@@ -19,46 +18,79 @@ Tests and build status | |
| |ci-tests| | | ||
+----------------------+ | ||
|
||
Install | ||
======= | ||
:: | ||
|
||
pip install packageurl-python | ||
|
||
Usage | ||
===== | ||
|
||
:: | ||
|
||
>>> from packageurl import PackageURL | ||
|
||
>>> purl = PackageURL.from_string("pkg:maven/org.apache.commons/[email protected]") | ||
>>> print(purl.to_dict()) | ||
{'type': 'maven', 'namespace': 'org.apache.commons', 'name': 'io', 'version': '1.3.4', 'qualifiers': None, 'subpath': None} | ||
|
||
>>> print(purl.to_string()) | ||
pkg:maven/org.apache.commons/[email protected] | ||
|
||
>>> print(str(purl)) | ||
pkg:maven/org.apache.commons/[email protected] | ||
|
||
>>> print(repr(purl)) | ||
PackageURL(type='maven', namespace='org.apache.commons', name='io', version='1.3.4', qualifiers={}, subpath=None) | ||
|
||
Utilities | ||
========= | ||
|
||
Other utilities: | ||
Django models | ||
^^^^^^^^^^^^^ | ||
|
||
- packageurl.contrib.django_models.PackageURLMixin is a Django abstract model mixin to use Package URLs in Django. | ||
- packageurl.contrib.purl2url.get_url(purl) returns the download URL inferred from a Package URL. | ||
- packageurl.contrib.url2purl.get_purl(url) returns a Package URL inferred from URL. | ||
`packageurl.contrib.django_models.PackageURLMixin` is a Django abstract model mixin to use Package URLs in Django. | ||
|
||
URL to PURL | ||
^^^^^^^^^^^ | ||
|
||
`packageurl.contrib.url2purl.get_purl(url)` returns a Package URL inferred from an URL. | ||
|
||
Install | ||
======= | ||
:: | ||
|
||
pip install packageurl-python | ||
>>> from packageurl.contrib import url2purl | ||
>>> url2purl.get_purl("https://github.com/package-url/packageurl-python") | ||
PackageURL(type='github', namespace='package-url', name='packageurl-python', version=None, qualifiers={}, subpath=None) | ||
|
||
PURL to URL | ||
^^^^^^^^^^^ | ||
|
||
- `packageurl.contrib.purl2url.get_repo_url(purl)` returns a repository URL inferred from a Package URL. | ||
- `packageurl.contrib.purl2url.get_download_url(purl)` returns a download URL inferred from a Package URL. | ||
- `packageurl.contrib.purl2url.get_inferred_urls(purl)` return all inferred URLs (repository, download) from a Package URL. | ||
|
||
:: | ||
|
||
>>> from packageurl.contrib import purl2url | ||
|
||
>>> purl2url.get_repo_url("pkg:rubygems/[email protected]") | ||
"https://rubygems.org/gems/bundler/versions/2.3.23" | ||
|
||
>>> purl2url.get_download_url("pkg:rubygems/[email protected]") | ||
"https://rubygems.org/downloads/bundler-2.3.23.gem" | ||
|
||
>>> purl2url.get_inferred_urls("pkg:rubygems/[email protected]") | ||
["https://rubygems.org/gems/bundler/versions/2.3.23", "https://rubygems.org/downloads/bundler-2.3.23.gem",] | ||
|
||
Run tests | ||
========= | ||
|
||
install:: | ||
Install test dependencies:: | ||
|
||
python3 thirdparty/virtualenv.pyz --never-download --no-periodic-update . | ||
bin/pip install -e ."[test]" | ||
|
||
run tests:: | ||
Run tests:: | ||
|
||
bin/py.test tests | ||
|
||
|
@@ -91,7 +123,6 @@ Make a new release | |
bin/twine upload dist/* | ||
|
||
|
||
|
||
.. |ci-tests| image:: https://github.com/package-url/packageurl-python/actions/workflows/ci.yml/badge.svg?branch=main | ||
:target: https://github.com/package-url/packageurl-python/actions/workflows/ci.yml | ||
:alt: CI Tests and build status |
Oops, something went wrong.