@@ -48,7 +48,7 @@ def get_licenses_from_json():
4848 with open (file_withpath , 'r' ) as f :
4949 licenses = json .load (f )
5050 except Exception as ex :
51- print_error (' Error to get license from json file :' + str ( ex ) )
51+ print_error (f" Error to get license from json file : { ex } " )
5252
5353 return licenses
5454
@@ -61,11 +61,11 @@ def check_file_extension(file_list):
6161 try :
6262 file_extension = os .path .splitext (file )[1 ].lower ()
6363 if file_extension == "" :
64- logger .info (" No extension file(s) : " + file )
64+ logger .info (f " No extension file(s) : { file } " )
6565 if file_extension in EXTENSION_COMMENT_STYLE_MAP_LOWERCASE :
6666 files_filtered .append (file )
6767 except Exception as ex :
68- print_error ("Error - Unknown error to check file extension - " + str ( ex ) )
68+ print_error (f "Error - Unknown error to check file extension: { ex } " )
6969
7070 return files_filtered
7171
@@ -90,7 +90,7 @@ def check_license_and_copyright(path_to_find, all_files, missing_license, missin
9090
9191def convert_to_spdx_style (input_string ):
9292 input_string = input_string .replace (" " , "-" )
93- input_converted = "LicenseRef-" + input_string
93+ input_converted = f "LicenseRef-{ input_string } "
9494 return input_converted
9595
9696
@@ -103,7 +103,7 @@ def check_input_license_format(input_license):
103103
104104 licensesfromJson = get_licenses_from_json ()
105105 if licensesfromJson == "" :
106- print_error (" Error - Return Value to get license from Json is none " )
106+ print_error (" Error - Return Value to get license from Json is none" )
107107
108108 try :
109109 # Get frequetly used license from json file
@@ -161,13 +161,13 @@ def set_missing_license_copyright(missing_license_filtered, missing_copyright_fi
161161 try :
162162 main_parser = reuse_arg_parser ()
163163 except Exception as ex :
164- print_error (' Error_get_arg_parser :' + str ( ex ) )
164+ print_error (f" Error_get_arg_parser : { ex } " )
165165
166166 # Print missing License
167167 if missing_license_filtered is not None and len (missing_license_filtered ) > 0 :
168168 missing_license_list = []
169169
170- logger .info ("# Missing license File(s) " )
170+ logger .info ("# Missing license File(s)" )
171171 for lic_file in sorted (missing_license_filtered ):
172172 logger .info (f" * { lic_file } " )
173173 missing_license_list .append (lic_file )
@@ -184,7 +184,7 @@ def set_missing_license_copyright(missing_license_filtered, missing_copyright_fi
184184 try :
185185 reuse_header (parsed_args , project )
186186 except Exception as ex :
187- print_error (' Error_call_run_in_license :' + str ( ex ) )
187+ print_error (f" Error_call_run_in_license : { ex } " )
188188 else :
189189 logger .info ("# There is no missing license file\n " )
190190
@@ -203,20 +203,20 @@ def set_missing_license_copyright(missing_license_filtered, missing_copyright_fi
203203 input_copyright = copyright
204204
205205 if input_copyright != "" :
206- input_copyright = ' Copyright ' + input_copyright
206+ input_copyright = f" Copyright { input_copyright } "
207207
208208 input_ok = check_input_copyright_format (input_copyright )
209209 if input_ok is False :
210210 return
211211
212212 logger .warning (f" * Your input Copyright : { input_copyright } " )
213213 parsed_args = main_parser .parse_args (['addheader' , '--copyright' ,
214- 'SPDX-FileCopyrightText: ' + str ( input_copyright ) ,
214+ f 'SPDX-FileCopyrightText: { input_copyright } ' ,
215215 '--exclude-year' ] + missing_copyright_list )
216216 try :
217217 reuse_header (parsed_args , project )
218218 except Exception as ex :
219- print_error (' Error_call_run_in_copyright :' + str ( ex ) )
219+ print_error (f" Error_call_run_in_copyright : { ex } " )
220220 else :
221221 logger .info ("\n # There is no missing copyright file\n " )
222222
@@ -236,7 +236,7 @@ def get_allfiles_list(path):
236236 file_rel_path = os .path .relpath (file_abs_path , path )
237237 all_files .append (file_rel_path )
238238 except Exception as ex :
239- print_error (' Error_Get_AllFiles : ' + str ( ex ) )
239+ print_error (f" Error_Get_AllFiles : { ex } " )
240240
241241 return all_files
242242
@@ -246,17 +246,17 @@ def save_result_log():
246246 _str_final_result_log = safe_dump (_result_log , allow_unicode = True , sort_keys = True )
247247 logger .info (_str_final_result_log )
248248 except Exception as ex :
249- logger .warning ("Failed to print add result log. " + str ( ex ) )
249+ logger .warning (f "Failed to print add result log. : { ex } " )
250250
251251
252252def copy_to_root (input_license ):
253- lic_file = str ( input_license ) + ' .txt'
253+ lic_file = f" { input_license } .txt"
254254 try :
255255 source = os .path .join ('LICENSES' , f'{ lic_file } ' )
256256 destination = 'LICENSE'
257257 shutil .copyfile (source , destination )
258258 except Exception as ex :
259- print_error ("Error - Can't copy license file: " + str ( ex ) )
259+ print_error (f "Error - Can't copy license file: { ex } " )
260260
261261
262262def find_representative_license (path_to_find , input_license ):
@@ -284,7 +284,7 @@ def find_representative_license(path_to_find, input_license):
284284 input_license = check_input_license_format (input_license )
285285
286286 logger .info (f" Input License : { input_license } " )
287- parsed_args = main_parser .parse_args (['download' , str ( input_license ) ])
287+ parsed_args = main_parser .parse_args (['download' , f" { input_license } " ])
288288
289289 try :
290290 logger .warning (" # There is no representative license file" )
@@ -294,7 +294,7 @@ def find_representative_license(path_to_find, input_license):
294294 logger .warning (f" # Created Representative License File : { input_license } .txt" )
295295
296296 except Exception as ex :
297- print_error (' Error - download representative license text:' + str ( ex ) )
297+ print_error (f" Error - download representative license text: { ex } " )
298298
299299
300300def is_exclude_dir (dir_path ):
@@ -338,7 +338,7 @@ def download_oss_info_license(base_path, input_license=""):
338338 try :
339339 reuse_download (parsed_args , prj )
340340 except Exception as ex :
341- print_error (' Error - download license text in OSS-pkg-info.yml :' + str ( ex ) )
341+ print_error (f" Error - download license text in OSS-pkg-info.yml : { ex } " )
342342 else :
343343 logger .info (" # There is no license in the path \n " )
344344
@@ -356,7 +356,7 @@ def add_content(path_to_find="", file="", input_license="", input_copyright=""):
356356
357357 now = datetime .now ().strftime ('%Y%m%d_%H-%M-%S' )
358358 output_dir = os .getcwd ()
359- logger , _result_log = init_log (os .path .join (output_dir , "fosslight_reuse_add_log_" + now + " .txt" ),
359+ logger , _result_log = init_log (os .path .join (output_dir , f "fosslight_reuse_add_log_{ now } .txt" ),
360360 True , logging .INFO , logging .DEBUG , PKG_NAME , path_to_find )
361361
362362 if file != "" :
@@ -367,7 +367,7 @@ def add_content(path_to_find="", file="", input_license="", input_copyright=""):
367367 try :
368368 success , error_msg , licenses = get_spdx_licenses_json ()
369369 if success is False :
370- print_error (' Error to get SPDX Licesens : ' + str ( error_msg ) )
370+ print_error (f" Error to get SPDX Licesens : { error_msg } " )
371371
372372 licenseInfo = licenses .get ("licenses" )
373373 for info in licenseInfo :
@@ -376,7 +376,7 @@ def add_content(path_to_find="", file="", input_license="", input_copyright=""):
376376 if isDeprecated is False :
377377 spdx_licenses .append (shortID )
378378 except Exception as ex :
379- print_error (' Error access to get_spdx_licenses_json : ' + str ( ex ) )
379+ print_error (f" Error access to get_spdx_licenses_json : { ex } " )
380380
381381 if input_license != "" :
382382 find_representative_license (path_to_find , input_license )
@@ -396,11 +396,11 @@ def add_content(path_to_find="", file="", input_license="", input_copyright=""):
396396 if input_license != "" :
397397 converted_license = check_input_license_format (input_license )
398398 logger .warning (f" * Your input license : { converted_license } " )
399- parsed_args = main_parser .parse_args (['addheader' , '--license' , str ( converted_license ) ] + missing_license_list )
399+ parsed_args = main_parser .parse_args (['addheader' , '--license' , f" { converted_license } " ] + missing_license_list )
400400 try :
401401 reuse_header (parsed_args , project )
402402 except Exception as ex :
403- print_error (' Error_call_run_in_license_file_only :' + str ( ex ) )
403+ print_error (f" Error_call_run_in_license_file_only : { ex } " )
404404 else :
405405 logger .info ("# There is no missing license file" )
406406
@@ -409,20 +409,20 @@ def add_content(path_to_find="", file="", input_license="", input_copyright=""):
409409 input_copyright = input_copyright_while_running ()
410410
411411 if input_copyright != "" :
412- input_copyright = ' Copyright ' + input_copyright
412+ input_copyright = f" Copyright { input_copyright } "
413413
414414 input_ok = check_input_copyright_format (input_copyright )
415415 if input_ok is False :
416416 return
417417
418418 logger .warning (f" * Your input Copyright : { input_copyright } " )
419419 parsed_args = main_parser .parse_args (['addheader' , '--copyright' ,
420- ' SPDX-FileCopyrightText: ' + str ( input_copyright ) ,
420+ f" SPDX-FileCopyrightText: { input_copyright } " ,
421421 '--exclude-year' ] + missing_copyright_list )
422422 try :
423423 reuse_header (parsed_args , project )
424424 except Exception as ex :
425- print_error (' Error_call_run_in_copyright_file_only :' + str ( ex ) )
425+ print_error (f" Error_call_run_in_copyright_file_only : { ex } " )
426426 else :
427427 logger .info ("# There is no missing copyright file\n " )
428428 # Path mode (-p option)
0 commit comments