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

Function prepare_text

src/licensedcode/match_spdx_lid.py:343–355  ·  view source on GitHub ↗

Return a 2-tuple of (`prefix`, `expression_text`) built from `text` where the `expression_text` is prepared to be suitable for SPDX license identifier detection stripped from leading and trailing punctuations, normalized for spaces and separateed from an SPDX-License-Identifier `pre

(text)

Source from the content-addressed store, hash-verified

341
342
343def prepare_text(text):
344 """
345 Return a 2-tuple of (`prefix`, `expression_text`) built from `text` where
346 the `expression_text` is prepared to be suitable for SPDX license identifier
347 detection stripped from leading and trailing punctuations, normalized for
348 spaces and separateed from an SPDX-License-Identifier `prefix`.
349 """
350 if is_markup_text(text):
351 text = demarkup_text(text)
352
353 prefix, expression = split_spdx_lid(text)
354 prefix = prefix.strip() if prefix is not None else prefix
355 return prefix, clean_text(expression)
356
357
358def clean_text(text):

Callers 5

test_prepare_textMethod · 0.90
get_expressionFunction · 0.85

Calls 4

is_markup_textFunction · 0.90
demarkup_textFunction · 0.90
split_spdx_lidFunction · 0.85
clean_textFunction · 0.70

Tested by 4

test_prepare_textMethod · 0.72