Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nxd-bom
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
nxd-bom
Commits
41e34a60
Commit
41e34a60
authored
Jun 12, 2023
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
351a58d2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
0 deletions
+59
-0
nxdbom/__init__.py
nxdbom/__init__.py
+36
-0
nxdbom/nxdbom_test.py
nxdbom/nxdbom_test.py
+23
-0
No files found.
nxdbom/__init__.py
View file @
41e34a60
...
...
@@ -491,6 +491,42 @@ def removesuffix(s, suffix):
s
=
s
[:
len
(
s
)
-
len
(
suffix
)]
return
s
# spdx_license_canon returns canonical SPDX license ID for license_name.
#
# it is an error is license_name cannot be recognized.
_licdb
=
{
# spdx -> variants
'Apache-2.0'
:
'Apache License 2.0 | Apache License, Version 2.0 | http://www.apache.org/licenses/LICENSE-2.0'
,
'EPL-1.0'
:
'Eclipse Public License 1.0'
,
'GPL-2.0+'
:
'GPL 2+'
,
'GPL-3.0+'
:
'GNU GPLv3+'
,
'GPL-3.0'
:
'GPLv3 | GNU General Public License Version 3'
,
'MIT'
:
''
,
'PSF'
:
'Python Software Foundation License'
,
# XXX no ver
'ZPL-2.1'
:
''
,
'GPL-3.0+-with-NXD-exception'
:
'GPLv3+ with wide exception for FOSS'
,
}
_licrevdb
=
{}
# variant -> spdx
for
lic
,
variants
in
_licdb
.
items
():
vv
=
[]
if
variants
:
vv
=
variants
.
split
(
'|'
)
vv
.
append
(
lic
)
# e.g. MIT -> MIT
licsp
=
lic
.
replace
(
'-'
,
' '
)
if
licsp
!=
lic
:
vv
.
append
(
licsp
)
# e.g. ZPL 2.1 -> ZPL-2.1
for
v
in
vv
:
v
=
v
.
strip
()
assert
v
not
in
_licrevdb
,
repr
(
v
)
_licrevdb
[
v
]
=
lic
def
spdx_license_canon
(
license_name
):
spdx
=
_licrevdb
.
get
(
license_name
)
if
spdx
is
None
:
raise
ValueError
(
'unknown license %r'
%
license_name
)
return
spdx
# ----------------------------------------
# fmt_bom formats BOM into text.
...
...
nxdbom/nxdbom_test.py
View file @
41e34a60
...
...
@@ -486,6 +486,29 @@ def test_bom_software_eexist():
with
pytest
.
raises
(
RuntimeError
,
match
=
"Cannot load '%s/.installed.cfg'"
%
ne
):
nxdbom
.
bom_software
(
ne
)
# ---- licenses ----
@
pytest
.
mark
.
parametrize
(
'license,spdxok'
,
[
# ('3-clause BSD', XXX
(
'Apache 2.0'
,
'Apache-2.0'
),
(
'Apache License 2.0'
,
'Apache-2.0'
),
(
'Apache License, Version 2.0'
,
'Apache-2.0'
),
(
'Eclipse Public License 1.0'
,
'EPL-1.0'
),
(
'GNU GPLv3+'
,
'GPL-3.0+'
),
(
'GNU General Public License Version 3'
,
'GPL-3.0'
),
(
'GPL 2+'
,
'GPL-2.0+'
),
(
'GPLv3'
,
'GPL-3.0'
),
(
'GPLv3+ with wide exception for FOSS'
,
'GPL-3.0+-with-NXD-exception'
),
(
'Python Software Foundation License'
,
'PSF'
),
# no version
(
'ZPL 2.1'
,
'ZPL-2.1'
),
(
'http://www.apache.org/licenses/LICENSE-2.0'
,
'Apache-2.0'
),
# XXX ASL 2 (roman)
# XXX New BSD License (scandir)
# XXX Modified BSD (scikit_image)
])
def
test_spdx_license_canon
(
license
,
spdxok
):
assert
nxdbom
.
spdx_license_canon
(
license
)
==
spdxok
# ---- txtar ----
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment