Skip to content

Commit

Permalink
Make license identifiers python-safe
Browse files Browse the repository at this point in the history
Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
  • Loading branch information
AyanSinhaMahapatra committed Jul 21, 2023
1 parent cfa072b commit 03963fe
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 69 deletions.
3 changes: 2 additions & 1 deletion src/licensedcode/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,8 @@ def get_new_identifier_from_detections(initial_detection, detections_added, lice
]
identifiers.append(initial_detection["identifier"])
uuid = get_uuid_on_content(content=sorted(identifiers))
return f"{license_expression}-{uuid}"
expression = python_safe_name(s=str(license_expression))
return f"{expression}-{uuid}"


@attr.s
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"license_detections": [
{
"identifier": "apache-2.0-1c807a43-2040-70af-75aa-c343d5f2b90c",
"identifier": "apache_2_0-1c807a43-2040-70af-75aa-c343d5f2b90c",
"license_expression": "apache-2.0",
"detection_count": 1,
"detection_log": [
Expand Down Expand Up @@ -86,7 +86,7 @@
"detection_log": [
"unknown-reference-to-local-file"
],
"identifier": "apache-2.0-1c807a43-2040-70af-75aa-c343d5f2b90c"
"identifier": "apache_2_0-1c807a43-2040-70af-75aa-c343d5f2b90c"
}
],
"license_clues": [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"license_detections": [
{
"identifier": "x11-xconsortium-veillard-61f804f6-d484-92ca-09b5-26be51ac974e",
"identifier": "x11_xconsortium_veillard-61f804f6-d484-92ca-09b5-26be51ac974e",
"license_expression": "x11-xconsortium-veillard",
"detection_count": 2,
"detection_log": [
"unknown-reference-to-local-file"
]
},
{
"identifier": "x11-xconsortium-veillard-50c015bd-e4e1-c6fe-eb82-9551473dd8e1",
"identifier": "x11_xconsortium_veillard-50c015bd-e4e1-c6fe-eb82-9551473dd8e1",
"license_expression": "x11-xconsortium-veillard",
"detection_count": 1,
"detection_log": [
Expand Down Expand Up @@ -94,7 +94,7 @@
"detection_log": [
"unknown-reference-to-local-file"
],
"identifier": "x11-xconsortium-veillard-61f804f6-d484-92ca-09b5-26be51ac974e"
"identifier": "x11_xconsortium_veillard-61f804f6-d484-92ca-09b5-26be51ac974e"
}
],
"license_clues": [],
Expand Down Expand Up @@ -140,7 +140,7 @@
"detection_log": [
"unknown-reference-to-local-file"
],
"identifier": "x11-xconsortium-veillard-61f804f6-d484-92ca-09b5-26be51ac974e"
"identifier": "x11_xconsortium_veillard-61f804f6-d484-92ca-09b5-26be51ac974e"
}
],
"license_clues": [],
Expand Down Expand Up @@ -206,7 +206,7 @@
"detection_log": [
"unknown-reference-to-local-file"
],
"identifier": "x11-xconsortium-veillard-50c015bd-e4e1-c6fe-eb82-9551473dd8e1"
"identifier": "x11_xconsortium_veillard-50c015bd-e4e1-c6fe-eb82-9551473dd8e1"
}
],
"license_clues": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_89.RULE"
}
],
"identifier": "bsd-new-56110dee-5dcd-3acb-7774-ab2491cc76bf",
"identifier": "bsd_new-56110dee-5dcd-3acb-7774-ab2491cc76bf",
"detection_log": [
"package-unknown-reference-to-local-file"
]
Expand Down Expand Up @@ -142,15 +142,15 @@
"detection_log": []
},
{
"identifier": "bsd-new-56110dee-5dcd-3acb-7774-ab2491cc76bf",
"identifier": "bsd_new-56110dee-5dcd-3acb-7774-ab2491cc76bf",
"license_expression": "bsd-new",
"detection_count": 1,
"detection_log": [
"package-unknown-reference-to-local-file"
]
},
{
"identifier": "bsd-new-68720980-08c9-ffb1-f28e-24c2e067385b",
"identifier": "bsd_new-68720980-08c9-ffb1-f28e-24c2e067385b",
"license_expression": "bsd-new",
"detection_count": 1,
"detection_log": [
Expand Down Expand Up @@ -281,7 +281,7 @@
"rule_url": "https://github.com/nexB/scancode-toolkit/tree/develop/src/licensedcode/data/rules/bsd-new_89.RULE"
}
],
"identifier": "bsd-new-56110dee-5dcd-3acb-7774-ab2491cc76bf",
"identifier": "bsd_new-56110dee-5dcd-3acb-7774-ab2491cc76bf",
"detection_log": [
"package-unknown-reference-to-local-file"
]
Expand Down Expand Up @@ -351,7 +351,7 @@
"detection_log": [
"unknown-reference-to-local-file"
],
"identifier": "bsd-new-68720980-08c9-ffb1-f28e-24c2e067385b"
"identifier": "bsd_new-68720980-08c9-ffb1-f28e-24c2e067385b"
},
{
"license_expression": "bsd-new",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"matched_text": "GNU GENERAL PUBLIC LICENSE"
}
],
"identifier": "lgpl-2.0-plus AND gpl-1.0-plus-de66a0ae-df4d-ab6b-975e-8deb27c0f945",
"identifier": "lgpl_2_0_plus_and_gpl_1_0_plus-de66a0ae-df4d-ab6b-975e-8deb27c0f945",
"detection_log": [
"package-unknown-reference-to-local-file"
]
Expand Down Expand Up @@ -142,26 +142,26 @@
],
"license_detections": [
{
"identifier": "lgpl-2.0-plus AND gpl-1.0-plus-17115808-8fc8-9c98-b64d-c5013bcbde1b",
"identifier": "lgpl_2_0_plus_and_gpl_1_0_plus-17115808-8fc8-9c98-b64d-c5013bcbde1b",
"license_expression": "lgpl-2.0-plus AND gpl-1.0-plus",
"detection_count": 1,
"detection_log": [
"unknown-reference-to-local-file"
]
},
{
"identifier": "lgpl-2.0-plus AND gpl-1.0-plus-de66a0ae-df4d-ab6b-975e-8deb27c0f945",
"identifier": "lgpl_2_0_plus_and_gpl_1_0_plus-2a11c930-7038-736e-5e48-b35f872691cc",
"license_expression": "lgpl-2.0-plus AND gpl-1.0-plus",
"detection_count": 1,
"detection_log": [
"package-unknown-reference-to-local-file"
]
"detection_log": []
},
{
"identifier": "lgpl_2_0_plus_and_gpl_1_0_plus-2a11c930-7038-736e-5e48-b35f872691cc",
"identifier": "lgpl_2_0_plus_and_gpl_1_0_plus-de66a0ae-df4d-ab6b-975e-8deb27c0f945",
"license_expression": "lgpl-2.0-plus AND gpl-1.0-plus",
"detection_count": 1,
"detection_log": []
"detection_log": [
"package-unknown-reference-to-local-file"
]
}
],
"files": [
Expand Down Expand Up @@ -293,7 +293,7 @@
"matched_text": "GNU GENERAL PUBLIC LICENSE"
}
],
"identifier": "lgpl-2.0-plus AND gpl-1.0-plus-de66a0ae-df4d-ab6b-975e-8deb27c0f945",
"identifier": "lgpl_2_0_plus_and_gpl_1_0_plus-de66a0ae-df4d-ab6b-975e-8deb27c0f945",
"detection_log": [
"package-unknown-reference-to-local-file"
]
Expand Down Expand Up @@ -394,7 +394,7 @@
"detection_log": [
"unknown-reference-to-local-file"
],
"identifier": "lgpl-2.0-plus AND gpl-1.0-plus-17115808-8fc8-9c98-b64d-c5013bcbde1b"
"identifier": "lgpl_2_0_plus_and_gpl_1_0_plus-17115808-8fc8-9c98-b64d-c5013bcbde1b"
}
],
"license_clues": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"detection_log": []
},
{
"identifier": "bsd-new-af493d9f-0c66-d9f8-4538-579134812514",
"identifier": "bsd_new-af493d9f-0c66-d9f8-4538-579134812514",
"license_expression": "bsd-new",
"detection_count": 1,
"detection_log": [
Expand Down Expand Up @@ -270,7 +270,7 @@
"detection_log": [
"unknown-reference-in-file-to-package"
],
"identifier": "bsd-new-af493d9f-0c66-d9f8-4538-579134812514"
"identifier": "bsd_new-af493d9f-0c66-d9f8-4538-579134812514"
}
],
"license_clues": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,26 +196,26 @@
"detection_log": []
},
{
"identifier": "bsd-new-cdb8fe96-c13c-043d-8031-aebb4cd77653",
"identifier": "bsd_new-cdb8fe96-c13c-043d-8031-aebb4cd77653",
"license_expression": "bsd-new",
"detection_count": 5,
"detection_log": [
"unknown-reference-in-file-to-package"
]
},
{
"identifier": "bsd-new-734cc7c8-5d13-b9e1-3f7c-d04a0d9396c7",
"identifier": "bsd_new-72cae3bc-4423-3a9e-be84-ee8bb5120a4d",
"license_expression": "bsd-new",
"detection_count": 2,
"detection_log": [
"unknown-reference-in-file-to-package"
]
"detection_log": []
},
{
"identifier": "bsd_new-72cae3bc-4423-3a9e-be84-ee8bb5120a4d",
"identifier": "bsd_new-734cc7c8-5d13-b9e1-3f7c-d04a0d9396c7",
"license_expression": "bsd-new",
"detection_count": 2,
"detection_log": []
"detection_log": [
"unknown-reference-in-file-to-package"
]
}
],
"files": [
Expand Down Expand Up @@ -425,7 +425,7 @@
"detection_log": [
"unknown-reference-in-file-to-package"
],
"identifier": "bsd-new-cdb8fe96-c13c-043d-8031-aebb4cd77653"
"identifier": "bsd_new-cdb8fe96-c13c-043d-8031-aebb4cd77653"
}
],
"license_clues": [],
Expand Down Expand Up @@ -475,7 +475,7 @@
"detection_log": [
"unknown-reference-in-file-to-package"
],
"identifier": "bsd-new-cdb8fe96-c13c-043d-8031-aebb4cd77653"
"identifier": "bsd_new-cdb8fe96-c13c-043d-8031-aebb4cd77653"
}
],
"license_clues": [],
Expand Down Expand Up @@ -549,7 +549,7 @@
"detection_log": [
"unknown-reference-in-file-to-package"
],
"identifier": "bsd-new-734cc7c8-5d13-b9e1-3f7c-d04a0d9396c7"
"identifier": "bsd_new-734cc7c8-5d13-b9e1-3f7c-d04a0d9396c7"
}
],
"license_clues": [],
Expand Down Expand Up @@ -599,7 +599,7 @@
"detection_log": [
"unknown-reference-in-file-to-package"
],
"identifier": "bsd-new-734cc7c8-5d13-b9e1-3f7c-d04a0d9396c7"
"identifier": "bsd_new-734cc7c8-5d13-b9e1-3f7c-d04a0d9396c7"
}
],
"license_clues": [],
Expand Down Expand Up @@ -649,7 +649,7 @@
"detection_log": [
"unknown-reference-in-file-to-package"
],
"identifier": "bsd-new-cdb8fe96-c13c-043d-8031-aebb4cd77653"
"identifier": "bsd_new-cdb8fe96-c13c-043d-8031-aebb4cd77653"
}
],
"license_clues": [],
Expand Down Expand Up @@ -1210,7 +1210,7 @@
"detection_log": [
"unknown-reference-in-file-to-package"
],
"identifier": "bsd-new-cdb8fe96-c13c-043d-8031-aebb4cd77653"
"identifier": "bsd_new-cdb8fe96-c13c-043d-8031-aebb4cd77653"
}
],
"license_clues": [],
Expand Down Expand Up @@ -1284,7 +1284,7 @@
"detection_log": [
"unknown-reference-in-file-to-package"
],
"identifier": "bsd-new-cdb8fe96-c13c-043d-8031-aebb4cd77653"
"identifier": "bsd_new-cdb8fe96-c13c-043d-8031-aebb4cd77653"
}
],
"license_clues": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,26 +384,26 @@
],
"license_detections": [
{
"identifier": "apache-2.0-35de6d3f-8962-0454-2270-33aac504c123",
"identifier": "apache_2_0-35de6d3f-8962-0454-2270-33aac504c123",
"license_expression": "apache-2.0",
"detection_count": 2,
"detection_log": [
"unknown-reference-in-file-to-package"
]
},
{
"identifier": "apache-2.0-abb5bcc3-dac9-a935-3392-31a86beb482a",
"identifier": "apache_2_0-999670be-3d5e-ebf8-ae18-b555c26c5e80",
"license_expression": "apache-2.0",
"detection_count": 2,
"detection_log": [
"unknown-reference-to-local-file"
]
"detection_log": []
},
{
"identifier": "apache_2_0-999670be-3d5e-ebf8-ae18-b555c26c5e80",
"identifier": "apache_2_0-abb5bcc3-dac9-a935-3392-31a86beb482a",
"license_expression": "apache-2.0",
"detection_count": 2,
"detection_log": []
"detection_log": [
"unknown-reference-to-local-file"
]
},
{
"identifier": "apache_2_0-c4e30bcd-ccfd-bbc3-d2f1-196ab911e47d",
Expand Down Expand Up @@ -550,7 +550,7 @@
"detection_log": [
"unknown-reference-to-local-file"
],
"identifier": "apache-2.0-abb5bcc3-dac9-a935-3392-31a86beb482a"
"identifier": "apache_2_0-abb5bcc3-dac9-a935-3392-31a86beb482a"
}
],
"license_clues": [],
Expand Down Expand Up @@ -661,7 +661,7 @@
"detection_log": [
"unknown-reference-in-file-to-package"
],
"identifier": "apache-2.0-35de6d3f-8962-0454-2270-33aac504c123"
"identifier": "apache_2_0-35de6d3f-8962-0454-2270-33aac504c123"
}
],
"license_clues": [],
Expand Down Expand Up @@ -724,7 +724,7 @@
"detection_log": [
"unknown-reference-in-file-to-package"
],
"identifier": "apache-2.0-35de6d3f-8962-0454-2270-33aac504c123"
"identifier": "apache_2_0-35de6d3f-8962-0454-2270-33aac504c123"
}
],
"license_clues": [],
Expand Down Expand Up @@ -1075,7 +1075,7 @@
"detection_log": [
"unknown-reference-to-local-file"
],
"identifier": "apache-2.0-abb5bcc3-dac9-a935-3392-31a86beb482a"
"identifier": "apache_2_0-abb5bcc3-dac9-a935-3392-31a86beb482a"
}
],
"other_license_expression": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
"detection_log": []
},
{
"identifier": "gpl-3.0-76e8f741-ece2-d587-493c-92b0b1e4bdfe",
"identifier": "gpl_3_0-76e8f741-ece2-d587-493c-92b0b1e4bdfe",
"license_expression": "gpl-3.0",
"detection_count": 1,
"detection_log": [
"unknown-reference-in-file-to-nonexistent-package"
]
},
{
"identifier": "gpl-3.0-e907b820-6f8c-81c4-38c5-75006ae093a4",
"identifier": "gpl_3_0-e907b820-6f8c-81c4-38c5-75006ae093a4",
"license_expression": "gpl-3.0",
"detection_count": 1,
"detection_log": [
Expand Down Expand Up @@ -318,7 +318,7 @@
"detection_log": [
"unknown-reference-in-file-to-nonexistent-package"
],
"identifier": "gpl-3.0-e907b820-6f8c-81c4-38c5-75006ae093a4"
"identifier": "gpl_3_0-e907b820-6f8c-81c4-38c5-75006ae093a4"
}
],
"license_clues": [],
Expand Down Expand Up @@ -431,7 +431,7 @@
"detection_log": [
"unknown-reference-in-file-to-nonexistent-package"
],
"identifier": "gpl-3.0-76e8f741-ece2-d587-493c-92b0b1e4bdfe"
"identifier": "gpl_3_0-76e8f741-ece2-d587-493c-92b0b1e4bdfe"
}
],
"license_clues": [],
Expand Down
Loading

0 comments on commit 03963fe

Please sign in to comment.