MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / apply_expressions_mapping

Function apply_expressions_mapping

src/packagedcode/alpine.py:1723–1742  ·  view source on GitHub ↗

Return a new license expression string from an ``expression`` string replacing subexpressions using the DECLARED_TO_SPDX_SUBS expression subsitution table.

(expression)

Source from the content-addressed store, hash-verified

1721
1722
1723def apply_expressions_mapping(expression):
1724 """
1725 Return a new license expression string from an ``expression`` string
1726 replacing subexpressions using the DECLARED_TO_SPDX_SUBS expression
1727 subsitution table.
1728 """
1729 licensing = Licensing()
1730
1731 global DECLARED_TO_SPDX_SUBS
1732 if not DECLARED_TO_SPDX_SUBS:
1733 DECLARED_TO_SPDX_SUBS = {
1734 licensing.parse(src, simple=True): licensing.parse(tgt, simple=True)
1735 for src, tgt in DECLARED_TO_SPDX.items()
1736 }
1737
1738 try:
1739 expression = licensing.parse(expression, simple=True)
1740 except:
1741 raise Exception(expression)
1742 return str(expression.subs(DECLARED_TO_SPDX_SUBS))
1743
1744
1745def apkbuild_options_handler(value, **kwargs):

Callers 1

Calls 1

parseMethod · 0.45

Tested by

no test coverage detected