33# purldb is a trademark of nexB Inc.
44# SPDX-License-Identifier: Apache-2.0
55# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
6- # See https://github.com/nexB /purldb for support or download.
6+ # See https://github.com/aboutcode-org /purldb for support or download.
77# See https://aboutcode.org for more information about nexB OSS projects.
88#
99
@@ -118,8 +118,10 @@ def handle(self, *args, **options):
118118 logger .info ('Graceful exit of the map loop.' )
119119 break
120120
121- mappable_definitions = CDitem .objects .mappable_definitions ()[:MAP_BATCH_SIZE ]
122- mappable_scancode_harvests = CDitem .objects .mappable_scancode_harvests ()[:MAP_BATCH_SIZE ]
121+ mappable_definitions = CDitem .objects .mappable_definitions ()[
122+ :MAP_BATCH_SIZE ]
123+ mappable_scancode_harvests = CDitem .objects .mappable_scancode_harvests ()[
124+ :MAP_BATCH_SIZE ]
123125
124126 try :
125127 if not mappable_definitions and not mappable_scancode_harvests :
@@ -187,7 +189,7 @@ def get_coords_des_and_lic_from_def(definition):
187189 return definition .get ('coordinates' , {}), definition .get ('described' , {}), definition .get ('licensed' , {})
188190
189191
190- #CD_TYPES_WITH_SOURCE = ('debsrc', 'npm', 'sourcearchive',)
192+ # CD_TYPES_WITH_SOURCE = ('debsrc', 'npm', 'sourcearchive',)
191193
192194
193195def get_or_create_package_from_cditem_definition (cditem ):
@@ -197,7 +199,8 @@ def get_or_create_package_from_cditem_definition(cditem):
197199 definition = cditem .data
198200 if not definition :
199201 raise Exception ('No data available for this definition' )
200- coordinates , described , licensed = get_coords_des_and_lic_from_def (definition )
202+ coordinates , described , licensed = get_coords_des_and_lic_from_def (
203+ definition )
201204
202205 download_url = described .get ('urls' , {}).get ('download' , '' )
203206 if not download_url :
@@ -219,15 +222,17 @@ def get_or_create_package_from_cditem_definition(cditem):
219222 name = coordinates .get ('name' )
220223 version = coordinates .get ('revision' )
221224 package_type = coordinates .get ('type' )
222- converted_package_type = PACKAGE_TYPES_BY_CD_TYPE .get (package_type ) or package_type
225+ converted_package_type = PACKAGE_TYPES_BY_CD_TYPE .get (
226+ package_type ) or package_type
223227 # TODO: Source packages need to be updated for clearlydefined, link source packages to binary packages
224228 hashes = described .get ('hashes' , {})
225229 sha1 = hashes .get ('sha1' )
226230 sha256 = hashes .get ('sha256' )
227231 homepage_url = described .get ('projectWebsite' )
228232 release_date = described .get ('releaseDate' )
229233 declared_license = licensed .get ('declared' )
230- normalized_license_expression = licensing .get_normalized_expression (declared_license )
234+ normalized_license_expression = licensing .get_normalized_expression (
235+ declared_license )
231236 copyrights = get_parties_from_licensed (licensed )
232237 copyrights = '\n ' .join (copyrights )
233238 definition_mining_level = 0
@@ -257,7 +262,8 @@ def get_or_create_package_from_cditem_definition(cditem):
257262 )
258263 # log history if package was created
259264 if created :
260- package .append_to_history ('Created package from CDitem definition: {}' .format (cditem .path ))
265+ package .append_to_history (
266+ 'Created package from CDitem definition: {}' .format (cditem .path ))
261267
262268 else :
263269 # TODO: This is temporary until we fold clearindex into minecode mapping
@@ -283,7 +289,8 @@ def get_or_create_package_from_cditem_definition(cditem):
283289 replace = True
284290 )
285291 package = existing_package
286- package .append_to_history ('Updated package from CDitem definition: {}' .format (cditem .path ))
292+ package .append_to_history (
293+ 'Updated package from CDitem definition: {}' .format (cditem .path ))
287294
288295 return package
289296
@@ -303,7 +310,8 @@ def create_download_url_from_coords(coord):
303310
304311 package_type = PACKAGE_TYPES_BY_CD_TYPE .get (ptype )
305312 if not package_type :
306- raise Exception ('Unsupported ClearlyDefined package type: {}' .format (ptype ))
313+ raise Exception (
314+ 'Unsupported ClearlyDefined package type: {}' .format (ptype ))
307315
308316 get_urls = PACKAGE_TYPES_WITH_GET_URLS .get (package_type )
309317 if get_urls :
0 commit comments