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

Function get_ignorables

src/licensedcode/models.py:2909–2956  ·  view source on GitHub ↗

Return a mapping of ignorable clues lists found in a ``text`` for copyrights, holders, authors, urls, emails. Do not include items with empty values. Display progress messages if ``verbose`` is True.

(text, verbose=False)

Source from the content-addressed store, hash-verified

2907
2908
2909def get_ignorables(text, verbose=False):
2910 """
2911 Return a mapping of ignorable clues lists found in a ``text`` for
2912 copyrights, holders, authors, urls, emails. Do not include items with empty values.
2913
2914 Display progress messages if ``verbose`` is True.
2915 """
2916 from cluecode.copyrights import detect_copyrights_from_lines
2917 from cluecode.copyrights import Detection
2918
2919 from cluecode.finder import find_urls
2920 from cluecode.finder import find_emails
2921
2922 text_lines = text.splitlines()
2923
2924 # Redundant clues found in a license or rule text can be ignored.
2925 # Therefdore we collect and set ignorable copyrights, holders and authors
2926 detections = detect_copyrights_from_lines(numbered_lines=enumerate(text.splitlines(), 1))
2927 copyrights, holders, authors = Detection.split_values(detections)
2928
2929 if verbose:
2930 for detection in (copyrights + holders + authors):
2931 print(f' Found ignorable: {detection}')
2932
2933 copyrights = set(copyrights)
2934 holders = set(holders)
2935 authors = set(authors)
2936
2937 # collect and set ignorable emails and urls
2938 urls = set(u for (u, _ln) in find_urls(location=text_lines) if u)
2939 if verbose:
2940 print(f' Found urls: {urls}')
2941
2942 emails = set(e for (e, _ln) in find_emails(text_lines) if e)
2943 if verbose:
2944 print(f' Found emails: {emails}')
2945
2946 ignorables = build_ignorables_mapping(
2947 copyrights=copyrights,
2948 holders=holders,
2949 authors=authors,
2950 urls=urls,
2951 emails=emails,
2952 )
2953
2954 if verbose:
2955 print(f' Found ignorables: {ignorables}')
2956 return ignorables
2957
2958
2959def get_normalized_ignorables(licensish):

Callers 3

has_ignorable_changesFunction · 0.90
_ignorable_clue_errorFunction · 0.85
update_ignorablesFunction · 0.85

Calls 5

find_urlsFunction · 0.90
find_emailsFunction · 0.90
build_ignorables_mappingFunction · 0.85
split_valuesMethod · 0.80

Tested by

no test coverage detected