Skip to content

Commit 9bda762

Browse files
committed
Apply f-string format
1 parent 3dd04eb commit 9bda762

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/fosslight_scanner/common.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def run_analysis(path_to_run, params, func, str_run_start, output, exe_path):
2525
return_value = ""
2626
try:
2727
if path_to_run != "":
28-
logger.info("|--- Path to analyze :" + path_to_run)
28+
logger.info(f"|--- Path to analyze : {path_to_run}")
2929
os.chdir(output)
3030
sys.argv = params
3131
return_value = func()
@@ -35,26 +35,26 @@ def run_analysis(path_to_run, params, func, str_run_start, output, exe_path):
3535
except SystemExit:
3636
pass
3737
except Exception as ex:
38-
logger.error(str_run_start + ":" + str(ex))
38+
logger.error(f"{str_run_start}:{ex}")
3939
return return_value
4040

4141

4242
def call_analysis_api(path_to_run, str_run_start, return_idx, func, *args):
4343
# return_idx == -1 : Raw return value itself
44-
logger.info("## Start to run " + str_run_start)
44+
logger.info(f"## Start to run {str_run_start}")
4545
success = True
4646
result = []
4747
try:
4848
if path_to_run != "":
49-
logger.info("|--- Path to analyze :"+path_to_run)
49+
logger.info(f"|--- Path to analyze : {path_to_run}")
5050
result = func(*args)
5151
else:
5252
logger.info("Analyzing path is missing...")
5353
except SystemExit:
5454
success = False
5555
except Exception as ex:
5656
success = False
57-
logger.error(str_run_start + ":" + str(ex))
57+
logger.error(f"{str_run_start}:{ex}")
5858
try:
5959
if success:
6060
if result and return_idx >= 0:

src/fosslight_scanner/fosslight_scanner.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def run_dependency(path_to_analyze, output_file_with_path, params=""):
6666
elif param == "-t":
6767
github_token = value
6868
except Exception as ex:
69-
logger.warning("Set dependency Param:" + str(ex))
69+
logger.warning(f"Set dependency Param: {ex}")
7070

7171
try:
7272
success, result = call_analysis_api(path_to_analyze, "Dependency Analysis",
@@ -80,7 +80,7 @@ def run_dependency(path_to_analyze, output_file_with_path, params=""):
8080
if success:
8181
result_list = result.get('SRC_FL_Dependency')
8282
except Exception as ex:
83-
logger.warning("Run dependency:"+str(ex))
83+
logger.warning(f"Run dependency: {ex}")
8484

8585
if not result_list:
8686
result_list = []
@@ -135,7 +135,7 @@ def run_scanner(src_path, dep_arguments, output_path, keep_raw_data=False,
135135
sheet_list["SRC_FL_Source"] = [scan_item.get_row_to_print() for scan_item in result[2]]
136136
create_report_file(0, result[2], result[3], 'all', True, _output_dir, output_files["SRC"], "")
137137
except Exception as ex:
138-
logger.warning(f"Failed to run source analysis:{ex}")
138+
logger.warning(f"Failed to run source analysis: {ex}")
139139

140140
if run_bin:
141141
success, _ = call_analysis_api(src_path, "Binary Analysis",
@@ -152,7 +152,7 @@ def run_scanner(src_path, dep_arguments, output_path, keep_raw_data=False,
152152
return
153153

154154
except Exception as ex:
155-
logger.error(f"Scanning:{ex}")
155+
logger.error(f"Scanning: {ex}")
156156

157157
try:
158158
output_file_without_ext = os.path.join(final_excel_dir, output_file)
@@ -162,12 +162,12 @@ def run_scanner(src_path, dep_arguments, output_path, keep_raw_data=False,
162162
if success and output_files:
163163
result_log["Output File"] = output_files.split(",")
164164
else:
165-
logger.error(f"Fail to generate a result file. :{output_files}")
165+
logger.error(f"Fail to generate a result file. : {output_files}")
166166

167167
_str_final_result_log = yaml.safe_dump(result_log, allow_unicode=True, sort_keys=True)
168168
logger.info(_str_final_result_log)
169169
except Exception as ex:
170-
logger.warning(f"Error to write final report:{ex}")
170+
logger.warning(f"Error to write final report: {ex}")
171171

172172
try:
173173
if not keep_raw_data:
@@ -189,18 +189,18 @@ def download_source(link, out_dir):
189189
temp_src_dir = os.path.join(
190190
_output_dir, SRC_DIR_FROM_LINK_PREFIX+start_time)
191191

192-
logger.info(f"Link to download :{link}")
192+
logger.info(f"Link to download: {link}")
193193
success, msg = cli_download_and_extract(
194194
link, temp_src_dir, _output_dir)
195195

196196
if success:
197-
logger.info(f"Downloaded Dir:{temp_src_dir}")
197+
logger.info(f"Downloaded Dir: {temp_src_dir}")
198198
else:
199199
temp_src_dir = ""
200-
logger.error(f"Download failed:{msg}")
200+
logger.error(f"Download failed: {msg}")
201201
except Exception as ex:
202202
success = False
203-
logger.error(f"Failed to analyze from link:{ex}")
203+
logger.error(f"Failed to analyze from link: {ex}")
204204
return success, temp_src_dir
205205

206206

@@ -222,7 +222,7 @@ def init(output_path=""):
222222
_output_dir = os.path.abspath(_output_dir)
223223

224224
log_dir = os.path.join(output_root_dir, "fosslight_log")
225-
logger, result_log = init_log(os.path.join(log_dir, _log_file + _start_time + ".txt"),
225+
logger, result_log = init_log(os.path.join(log_dir, f"{_log_file}{_start_time}.txt"),
226226
True, logging.INFO, logging.DEBUG, PKG_NAME)
227227

228228
return os.path.isdir(_output_dir), output_root_dir, result_log

0 commit comments

Comments
 (0)