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)
| 1383 | |
| 1384 | |
| 1385 | def 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 | |
| 1414 | def is_standard_maven_license_data_structure(licenses): |
no test coverage detected