Skip to content

Commit e33ed34

Browse files
Merge pull request #897 from annie-xd-wang/double-check-loaded-yaml-file-before-use
double-check the loaded yaml files
2 parents 163ec12 + 3b9304a commit e33ed34

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

src/navigate/controller/sub_controllers/plugins_controller.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,11 @@ def load_plugins(self):
9595
plugins_config_path = os.path.join(
9696
get_navigate_path(), "config", "plugins_config.yml"
9797
)
98-
if not os.path.exists(plugins_config_path):
98+
plugins_config = load_yaml_file(plugins_config_path)
99+
if plugins_config is None:
100+
plugins_config = {}
99101
save_yaml_file(get_navigate_path(), {}, "plugins_config.yml")
100102
else:
101-
plugins_config = load_yaml_file(plugins_config_path)
102103
for plugin_name, plugin_path in plugins_config.items():
103104
if plugin_path and os.path.exists(plugin_path):
104105
installed_plugins[plugin_name] = plugin_path

src/navigate/model/model.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,11 +1424,9 @@ def load_feature_records(self):
14241424
os.makedirs(feature_lists_path)
14251425
return
14261426
# get __sequence.yml
1427-
if not os.path.exists(f"{feature_lists_path}/__sequence.yml"):
1427+
feature_records = load_yaml_file(f"{feature_lists_path}/__sequence.yml")
1428+
if feature_records is None:
14281429
feature_records = []
1429-
else:
1430-
feature_records = load_yaml_file(f"{feature_lists_path}/__sequence.yml")
1431-
14321430
# add non added feature lists
14331431
feature_list_files = [
14341432
temp
@@ -1440,6 +1438,8 @@ def load_feature_records(self):
14401438
if item == "__sequence.yml":
14411439
continue
14421440
temp = load_yaml_file(f"{feature_lists_path}/{item}")
1441+
if temp is None:
1442+
continue
14431443
add_flag = True
14441444
for feature in feature_records:
14451445
if feature["feature_list_name"] == temp["feature_list_name"]:
@@ -1460,6 +1460,9 @@ def load_feature_records(self):
14601460
del feature_records[i]
14611461
continue
14621462
item = load_yaml_file(f"{feature_lists_path}/{temp['yaml_file_name']}")
1463+
if item is None:
1464+
i += 1
1465+
continue
14631466

14641467
if item["module_name"]:
14651468
try:

src/navigate/model/plugins_model.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,13 @@ def load_plugins(self):
8181
plugins_config_path = os.path.join(
8282
get_navigate_path(), "config", "plugins_config.yml"
8383
)
84-
if not os.path.exists(plugins_config_path):
84+
plugins_config = load_yaml_file(plugins_config_path)
85+
if plugins_config is None:
86+
plugins_config = {}
8587
save_yaml_file(
8688
os.path.join(get_navigate_path(), "config"), {}, "plugins_config.yml"
8789
)
8890
else:
89-
plugins_config = load_yaml_file(plugins_config_path)
9091
verified_plugins_config = {}
9192
for plugin_name, plugin_path in plugins_config.items():
9293
if not plugin_path:

0 commit comments

Comments
 (0)