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

Function clean_licenses

src/packagedcode/maven.py:1385–1411  ·  view source on GitHub ↗

Return a modified, cleaned ``licenses`` list of POM license data cleaned from unwanted data (some fields, empty entries, etc). Each item in the list has this shape: [ {"license": {"name": "Apache-2.0", "url": "https://www... ", "comments": "..."} }, {"li

(licenses)

Source from the content-addressed store, hash-verified

1383
1384
1385def clean_licenses(licenses):
1386 """
1387 Return a modified, cleaned ``licenses`` list of POM license data cleaned from unwanted data
1388 (some fields, empty entries, etc).
1389 Each item in the list has this shape:
1390 [
1391 {"license": {"name": "Apache-2.0", "url": "https://www... ", "comments": "..."} },
1392 {"license": {other fields} },
1393 ]
1394 """
1395 for licitem in (licenses or []):
1396 if not isinstance(licitem, dict):
1397 continue
1398
1399 license_attributes = licitem.get("license")
1400 if not license_attributes or not len(licitem) == 1:
1401 continue
1402
1403 license_attributes.pop("distribution", None)
1404 if not license_attributes.get("name"):
1405 license_attributes.pop("name", None)
1406 if not license_attributes.get("url"):
1407 license_attributes.pop("url", None)
1408 if not license_attributes.get("comments"):
1409 license_attributes.pop("comments", None)
1410
1411 return licenses
1412
1413
1414def is_standard_maven_license_data_structure(licenses):

Calls 2

getMethod · 0.65
popMethod · 0.45

Tested by

no test coverage detected