@@ -198,14 +198,27 @@ def get_clearlydefined_license_and_copyright_in_batches(
198198 """
199199 # Create connections between purl <-> coordinates
200200 # It might happen that a coordinate describes more than one purl (e.g. SHAs for GitHub tags)
201- purls_coordinates = {purl : purl2clearlydefined (purl ) for purl in purls }
201+ purls_coordinates : dict [str , str ] = {}
202+ for purl in purls :
203+ try :
204+ coordinates = purl2clearlydefined (purl )
205+ except (ValueError , SystemExit ):
206+ coordinates = None
207+ if coordinates is None :
208+ logging .warning (
209+ "Could not convert purl %s to ClearlyDefined coordinates, skipping" , purl
210+ )
211+ else :
212+ purls_coordinates [purl ] = coordinates
213+ # Include skipped purls with empty data
214+ skipped_purls = set (purls ) - set (purls_coordinates )
202215 # Request the CD API for the coordinates
203216 api_return = _cdapi_call (
204217 path = "" , method = "POST" , json_dict = list (purls_coordinates .values ()), expand = "-files"
205218 )
206219
207220 if api_return :
208- result : dict [str , tuple [str , str ]] = {}
221+ result : dict [str , tuple [str , str ]] = dict . fromkeys ( skipped_purls , ( "" , "" ))
209222 for pkg_coordinates , cd_data in api_return .items ():
210223 # Extract license and copyright data from the CD API return
211224 declared_license , copyrights = _extract_license_copyright (cd_data )
0 commit comments