refactor: handle missing position file gracefully (#6513)

This commit is contained in:
Benjamin 2024-07-22 13:24:32 +08:00 committed by GitHub
parent 5b89b6fe2d
commit a67831773f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -14,6 +14,9 @@ def get_position_map(folder_path: str, *, file_name: str = "_position.yaml") ->
:return: a dict with name as key and index as value
"""
position_file_name = os.path.join(folder_path, file_name)
if not position_file_name or not os.path.exists(position_file_name):
return {}
positions = load_yaml_file(position_file_name, ignore_error=True)
position_map = {}
index = 0