pypurl
Releasing the support for PURLs from Ruby Gem repository
type
지원:각 구성 요소에 대한 정의는 다음과 같습니다.
this is the URL scheme with the constant value of "pkg". One of the
primary reason for this single scheme is to facilitate the future official
registration of the "pkg" scheme for package URLs. Required.
the package "type" or package "protocol" such as github, bitbucket,
maven, npm, nuget, gem, pypi, etc.
some name prefix such as a Maven groupid, a Docker image owner, a GitHub user
or organization. Optional and type-specific.
the name of the package.
the version of the package.
extra qualifying data for a package such as an OS, architecture, a distro, etc.
Type-specific.
extra subpath within a package, relative to the package root.
# install the package
$ cd pypurl /
$ pip install -e .
# enter interpreter mode
$ python
# import main module
>>> from pypurl .purl import Purl
>>> p = Purl()
# parse the Download URL to dictionary
>>> p.durl_to_dict('https://github.com/vBarbaros/pypurl/archive/refs/heads/main.zip')
{'scheme': 'pkg', 'type': 'github', 'namespace': 'vBarbaros', 'name': ' pypurl '}
# obtain the PURL from the Download URL only
>>> durl = 'https://github.com/vBarbaros/pypurl/archive/refs/heads/main.zip'
>>> p.durl_to_purl(durl)
'pkg:github/vBarbaros/ pypurl '
# obtain the PURL from the Download URL + version number/hash-commit
>>> durl = 'https://github.com/vBarbaros/pypurl/archive/refs/heads/main.zip'
>>> p.durl_to_purl(durl, '244fd47e07d1004f0aed9c')
'pkg:github/vBarbaros/ pypurl @244fd47e07d1004f0aed9c'
# obtain the PURL from the Download URL + version number/hash-commit + qualifiers
>>> p.durl_to_purl(durl, '244fd47e07d1004f0aed9c', 'param1=one¶m2=two¶m3=three')
'pkg:github/vBarbaros/ pypurl @244fd47e07d1004f0aed9c?param1=one¶m2=two¶m3=three'
# obtain the PURL from the Download URL + version number/hash-commit + qualifiers + subpath
>>> p.durl_to_purl(durl, '244fd47e07d1004f0aed9c', 'param1=one¶m2=two¶m3=three', 'some/dummy/path')
'pkg:github/vBarbaros/ pypurl @244fd47e07d1004f0aed9c?param1=one¶m2=two¶m3=three#some/dummy/path'
# parse the PURL containing main fields (+ version) to dictionary
>>> purl = 'pkg:github/vBarbaros/ pypurl @244fd47e07d1004f0aed9c'
>>> p.purl_to_dict(purl)
{'scheme': 'pkg', 'type': 'github', 'namespace': 'vBarbaros', 'name': ' pypurl ', 'version': '244fd47e07d1004f0aed9c'}
# parse the PURL containing all possible fields, to dictionary
>>> purl = 'pkg:github/vBarbaros/ pypurl @244fd47e07d1004f0aed9c?param1=one¶m2=two¶m3=three#some/dummy/path'
>>> p.purl_to_dict(purl)
{'scheme': 'pkg', 'type': 'github', 'namespace': 'vBarbaros', 'name': ' pypurl ', 'version': '244fd47e07d1004f0aed9c', 'qualifiers': 'param1=one¶m2=two¶m3=three', 'subpath': 'some/dummy/path'}
$ cd pypurl
$ pip install -e .
$ python -m unittest tests/*.py
# Expected output
...
Ran 163 tests in 0.006s
OK
이 모듈은 PURL을 사용하여 작업할 때 사람들이 겪었던 몇 가지 어려움을 기반으로 한 간단한 연습을 나타내지만, purl-specs 페이지는 이 모듈의 로드맵을 정의하는 데 도움이 되었습니다.
MIT © 빅터 바바로스, 2021