Skip to content

Commit 8546fb6

Browse files
authored
refactor: rename spdx.is_compund_expression -> spdx.is_expression (#779)
fixes #765 --------- Signed-off-by: Jan Kowalleck <[email protected]>
1 parent cdb5698 commit 8546fb6

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

cyclonedx/factory/license.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from ..exception.factory import InvalidLicenseExpressionException, InvalidSpdxLicenseException
2121
from ..model.license import DisjunctiveLicense, LicenseExpression
22-
from ..spdx import fixup_id as spdx_fixup, is_compound_expression as is_spdx_compound_expression
22+
from ..spdx import fixup_id as spdx_fixup, is_expression as is_spdx_expression
2323

2424
if TYPE_CHECKING: # pragma: no cover
2525
from ..model import AttachedText, XsUri
@@ -57,11 +57,11 @@ def make_with_expression(self, expression: str, *,
5757
) -> LicenseExpression:
5858
"""Make a :class:`cyclonedx.model.license.LicenseExpression` with a compound expression.
5959
60-
Utilizes :func:`cyclonedx.spdx.is_compound_expression`.
60+
Utilizes :func:`cyclonedx.spdx.is_expression`.
6161
6262
:raises InvalidLicenseExpressionException: if param `value` is not known/supported license expression
6363
"""
64-
if is_spdx_compound_expression(expression):
64+
if is_spdx_expression(expression):
6565
return LicenseExpression(expression, acknowledgement=acknowledgement)
6666
raise InvalidLicenseExpressionException(expression)
6767

cyclonedx/spdx.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
__all__ = [
2020
'is_supported_id', 'fixup_id',
21-
'is_compound_expression'
21+
'is_expression'
2222
]
2323

2424
from json import load as json_load
@@ -47,26 +47,26 @@
4747

4848

4949
def is_supported_id(value: str) -> bool:
50-
"""Validate a SPDX-ID according to current spec."""
50+
"""Validate SPDX-ID according to current spec."""
5151
return value in __IDS
5252

5353

5454
def fixup_id(value: str) -> Optional[str]:
55-
"""Fixup a SPDX-ID.
55+
"""Fixup SPDX-ID.
5656
5757
:returns: repaired value string, or `None` if fixup was unable to help.
5858
"""
5959
return __IDS_LOWER_MAP.get(value.lower())
6060

6161

62-
def is_compound_expression(value: str) -> bool:
63-
"""Validate compound expression.
62+
def is_expression(value: str) -> bool:
63+
"""Validate SPDX license expression.
6464
6565
.. note::
6666
Utilizes `license-expression library`_ to
6767
validate SPDX compound expression according to `SPDX license expression spec`_.
6868
69-
.. _SPDX license expression spec: https://spdx.github.io/spdx-spec/v2.3/SPDX-license-expressions/
69+
.. _SPDX license expression spec: https://spdx.github.io/spdx-spec/v3.0.1/annexes/spdx-license-expressions/
7070
.. _license-expression library: https://github.com/nexB/license-expression
7171
"""
7272
try:

tests/test_factory_license.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test_make_from_string_with_id(self) -> None:
3333
expected = DisjunctiveLicense(id='bar', text=text, url=url, acknowledgement=acknowledgement)
3434

3535
with unittest.mock.patch('cyclonedx.factory.license.spdx_fixup', return_value='bar'), \
36-
unittest.mock.patch('cyclonedx.factory.license.is_spdx_compound_expression', return_value=True):
36+
unittest.mock.patch('cyclonedx.factory.license.is_spdx_expression', return_value=True):
3737
actual = LicenseFactory().make_from_string('foo',
3838
license_text=text,
3939
license_url=url,
@@ -48,7 +48,7 @@ def test_make_from_string_with_name(self) -> None:
4848
expected = DisjunctiveLicense(name='foo', text=text, url=url, acknowledgement=acknowledgement)
4949

5050
with unittest.mock.patch('cyclonedx.factory.license.spdx_fixup', return_value=None), \
51-
unittest.mock.patch('cyclonedx.factory.license.is_spdx_compound_expression', return_value=False):
51+
unittest.mock.patch('cyclonedx.factory.license.is_spdx_expression', return_value=False):
5252
actual = LicenseFactory().make_from_string('foo',
5353
license_text=text,
5454
license_url=url,
@@ -61,7 +61,7 @@ def test_make_from_string_with_expression(self) -> None:
6161
expected = LicenseExpression('foo', acknowledgement=acknowledgement)
6262

6363
with unittest.mock.patch('cyclonedx.factory.license.spdx_fixup', return_value=None), \
64-
unittest.mock.patch('cyclonedx.factory.license.is_spdx_compound_expression', return_value=True):
64+
unittest.mock.patch('cyclonedx.factory.license.is_spdx_expression', return_value=True):
6565
actual = LicenseFactory().make_from_string('foo',
6666
license_acknowledgement=acknowledgement)
6767

@@ -94,11 +94,11 @@ def test_make_with_name(self) -> None:
9494
def test_make_with_expression(self) -> None:
9595
acknowledgement = unittest.mock.NonCallableMock(spec=LicenseAcknowledgement)
9696
expected = LicenseExpression('foo', acknowledgement=acknowledgement)
97-
with unittest.mock.patch('cyclonedx.factory.license.is_spdx_compound_expression', return_value=True):
97+
with unittest.mock.patch('cyclonedx.factory.license.is_spdx_expression', return_value=True):
9898
actual = LicenseFactory().make_with_expression(expression='foo', acknowledgement=acknowledgement)
9999
self.assertEqual(expected, actual)
100100

101101
def test_make_with_expression_raises(self) -> None:
102102
with self.assertRaises(InvalidLicenseExpressionException, msg='foo'):
103-
with unittest.mock.patch('cyclonedx.factory.license.is_spdx_compound_expression', return_value=False):
103+
with unittest.mock.patch('cyclonedx.factory.license.is_spdx_expression', return_value=False):
104104
LicenseFactory().make_with_expression('foo')

tests/test_spdx.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class TestSpdxIsCompoundExpression(TestCase):
8282

8383
@idata(VALID_COMPOUND_EXPRESSIONS)
8484
def test_positive(self, valid_expression: str) -> None:
85-
actual = spdx.is_compound_expression(valid_expression)
85+
actual = spdx.is_expression(valid_expression)
8686
self.assertTrue(actual)
8787

8888
@data(
@@ -92,5 +92,5 @@ def test_positive(self, valid_expression: str) -> None:
9292
'Apache License, Version 2.0'
9393
)
9494
def test_negative(self, invalid_expression: str) -> None:
95-
actual = spdx.is_compound_expression(invalid_expression)
95+
actual = spdx.is_expression(invalid_expression)
9696
self.assertFalse(actual)

0 commit comments

Comments
 (0)