优化文件路径处理逻辑,确保输入路径为目录

This commit is contained in:
marques
2025-05-20 15:44:39 +08:00
parent 7928848ca0
commit f00a98ce77

View File

@ -926,15 +926,18 @@ class Data:
self.relate_point = None self.relate_point = None
def open_file(self): def open_file(self):
if Path(Config["Path"]["Input_orgBcg"]).is_file():
Config["Path"]["Input_orgBcg"] = str(Path(Config["Path"]["Input_orgBcg"]).parent)
if not Path(Config["Path"]["Input_orgBcg"]).exists(): if not Path(Config["Path"]["Input_orgBcg"]).exists():
return Result().failure( return Result().failure(
info=Constants.INPUT_FAILURE + "orgBcg: " + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[ info=Constants.INPUT_FAILURE + "orgBcg: " + Config["Path"]["Input_orgBcg"] + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
"Data_Path_Not_Exist"]) "Data_Path_Not_Exist"])
temp_orgBcg_path = list( temp_orgBcg_path = list(
Path(Config["Path"]["Input_orgBcg"]).glob(f"{ConfigParams.APPROXIMATELY_ALIGN_INPUT_ORGBCG_FILENAME}*")) Path(Config["Path"]["Input_orgBcg"]).glob(f"{ConfigParams.APPROXIMATELY_ALIGN_INPUT_ORGBCG_FILENAME}*"))
if len(temp_orgBcg_path) == 0: if len(temp_orgBcg_path) == 0:
return Result().failure( return Result().failure(
info=Constants.INPUT_FAILURE + "orgBcg: " + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[ info=Constants.INPUT_FAILURE + "orgBcg: " + Config["Path"]["Input_orgBcg"] + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
"Data_File_Not_Exist"]) "Data_File_Not_Exist"])
elif len(temp_orgBcg_path) > 1: elif len(temp_orgBcg_path) > 1:
return Result().failure( return Result().failure(
@ -950,6 +953,8 @@ class Data:
info=Constants.INPUT_FAILURE + "orgBcg: " + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[ info=Constants.INPUT_FAILURE + "orgBcg: " + Constants.APPROXIMATELY_ALIGN_FAILURE_REASON[
"Data_Frequency_Not_In_Filename"]) "Data_Frequency_Not_In_Filename"])
Config["InputConfig"]["orgBcgFreq"] = int(orgBcg_freq) Config["InputConfig"]["orgBcgFreq"] = int(orgBcg_freq)
if Path(Config["Path"]["Input_Tho"]).is_file():
Config["Path"]["Input_Tho"] = str(Path(Config["Path"]["Input_Tho"]).parent)
if not Path(Config["Path"]["Input_Tho"]).exists(): if not Path(Config["Path"]["Input_Tho"]).exists():
return Result().failure( return Result().failure(
@ -976,6 +981,8 @@ class Data:
"Data_Frequency_Not_In_Filename"]) "Data_Frequency_Not_In_Filename"])
Config["InputConfig"]["ThoFreq"] = int(tho_freq) Config["InputConfig"]["ThoFreq"] = int(tho_freq)
if Path(Config["Path"]["Input_Abd"]).is_file():
Config["Path"]["Input_Abd"] = str(Path(Config["Path"]["Input_Abd"]).parent)
if not Path(Config["Path"]["Input_Abd"]).exists(): if not Path(Config["Path"]["Input_Abd"]).exists():
return Result().failure( return Result().failure(