Skip to content

Commit

Permalink
global: Add support for new SWHID qualifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
anlambert authored and lnielsen committed Jun 19, 2020
1 parent 0dd010b commit d5b4e84
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
5 changes: 3 additions & 2 deletions idutils/__init__.py
Expand Up @@ -243,8 +243,9 @@
"""ASCL regular expression."""

swh_regexp = re.compile(
"swh:1:(cnt|dir|rel|rev|snp):[0-9a-f]{40}(;origin=\S+)?$"
)
"swh:1:(cnt|dir|rel|rev|snp):[0-9a-f]{40}"
"(;(origin|visit|anchor|path|lines)=\S+)*$"
)
"""Matches Software Heritage identifiers."""

ror_regexp = re.compile(
Expand Down
32 changes: 32 additions & 0 deletions tests/test_idutils.py
Expand Up @@ -205,6 +205,38 @@
'swh:1:dir:d198bc9d7a6bcf6db04f476d29314f157507d505'
';origin=https://github.com/user/repo')),
('03yrm5c26', ['ror'], '03yrm5c26', 'http://ror.org/03yrm5c26'),
(('swh:1:cnt:78e48f800c950530e36d3712d9e2e89673f23562'
';origin=https://github.com/python/cpython'
';visit=swh:1:snp:cd510e99a42139ed36f15a5774301c113c3e494b'
';anchor=swh:1:rel:ae1f6af15f3e4110616801e235873e47fd7d1977'
';path=/Programs/python.c;lines=12-16'), ['swh', ],
('swh:1:cnt:78e48f800c950530e36d3712d9e2e89673f23562'
';origin=https://github.com/python/cpython'
';visit=swh:1:snp:cd510e99a42139ed36f15a5774301c113c3e494b'
';anchor=swh:1:rel:ae1f6af15f3e4110616801e235873e47fd7d1977'
';path=/Programs/python.c;lines=12-16'),
('http://archive.softwareheritage.org/'
'swh:1:cnt:78e48f800c950530e36d3712d9e2e89673f23562'
';origin=https://github.com/python/cpython'
';visit=swh:1:snp:cd510e99a42139ed36f15a5774301c113c3e494b'
';anchor=swh:1:rel:ae1f6af15f3e4110616801e235873e47fd7d1977'
';path=/Programs/python.c;lines=12-16')),
(('swh:1:cnt:78e48f800c950530e36d3712d9e2e89673f23562'
';anchor=swh:1:rel:ae1f6af15f3e4110616801e235873e47fd7d1977'
';visit=swh:1:snp:cd510e99a42139ed36f15a5774301c113c3e494b'
';path=/Programs/python.c;lines=12-16'
';origin=https://github.com/python/cpython'), ['swh', ],
('swh:1:cnt:78e48f800c950530e36d3712d9e2e89673f23562'
';anchor=swh:1:rel:ae1f6af15f3e4110616801e235873e47fd7d1977'
';visit=swh:1:snp:cd510e99a42139ed36f15a5774301c113c3e494b'
';path=/Programs/python.c;lines=12-16'
';origin=https://github.com/python/cpython'),
('http://archive.softwareheritage.org/'
'swh:1:cnt:78e48f800c950530e36d3712d9e2e89673f23562'
';anchor=swh:1:rel:ae1f6af15f3e4110616801e235873e47fd7d1977'
';visit=swh:1:snp:cd510e99a42139ed36f15a5774301c113c3e494b'
';path=/Programs/python.c;lines=12-16'
';origin=https://github.com/python/cpython'))
]


Expand Down

0 comments on commit d5b4e84

Please sign in to comment.