Return a matched license expression string or None by matching the ``text`` as an SPDX license expression. Use the ``expression_symbols`` mapping of {lowered key: LicenseSymbol} if provided. Otherwise use the standard SPDX license symbols. This is used to handle cases of mixed
(text, expression_symbols=None)
| 120 | |
| 121 | |
| 122 | def get_spdx_expression(text, expression_symbols=None): |
| 123 | """ |
| 124 | Return a matched license expression string or None by matching the |
| 125 | ``text`` as an SPDX license expression. |
| 126 | |
| 127 | Use the ``expression_symbols`` mapping of {lowered key: LicenseSymbol} if |
| 128 | provided. Otherwise use the standard SPDX license symbols. |
| 129 | |
| 130 | This is used to handle cases of mixed standard SPDX and non-standard SPDX- |
| 131 | like symbols used for instance in some package manifests. |
| 132 | """ |
| 133 | from licensedcode.cache import get_spdx_symbols |
| 134 | from licensedcode.cache import get_unknown_spdx_symbol |
| 135 | |
| 136 | licensing = Licensing() |
| 137 | if not expression_symbols: |
| 138 | expression_symbols = get_spdx_symbols() |
| 139 | |
| 140 | unknown_symbol = get_unknown_spdx_symbol() |
| 141 | # _prefix, exp_text = prepare_text(text) |
| 142 | |
| 143 | expression = get_expression( |
| 144 | text=text, |
| 145 | licensing=licensing, |
| 146 | expression_symbols=expression_symbols, |
| 147 | unknown_symbol=unknown_symbol, |
| 148 | ) |
| 149 | if expression is None: |
| 150 | return |
| 151 | return expression.render() |
| 152 | |
| 153 | |
| 154 | def get_expression(text, licensing, expression_symbols, unknown_symbol): |
no test coverage detected