Skip to content

Commit bccc03d

Browse files
committed
refactor(kpms_reader): path functions
1 parent 471d105 commit bccc03d

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

element_moseq/readers/kpms_reader.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,11 @@ def _pose_estimation_config_path(kpset_dir: Union[str, os.PathLike]) -> str:
2525
Path to pose estimation config file (config.yml or config.yaml)
2626
"""
2727
kpset_path = Path(kpset_dir)
28-
# Check for config.yml first (preferred)
29-
config_yml = kpset_path / CONFIG_FILENAMES[0]
30-
if config_yml.exists():
31-
return str(config_yml)
32-
# Fall back to config.yaml
33-
config_yaml = kpset_path / CONFIG_FILENAMES[1]
34-
if config_yaml.exists():
35-
return str(config_yaml)
36-
# If neither exists, return the default (config.yml)
37-
return str(config_yml)
28+
for filename in CONFIG_FILENAMES:
29+
config_path = kpset_path / filename
30+
if config_path.exists():
31+
return str(config_path)
32+
return str(kpset_path / CONFIG_FILENAMES[0])
3833

3934

4035
def _kpms_base_config_path(kpms_project_dir: Union[str, os.PathLike]) -> str:
@@ -48,16 +43,11 @@ def _kpms_base_config_path(kpms_project_dir: Union[str, os.PathLike]) -> str:
4843
Path to KPMS base config file (config.yml or config.yaml)
4944
"""
5045
project_path = Path(kpms_project_dir)
51-
# Check for config.yml first (preferred)
52-
config_yml = project_path / CONFIG_FILENAMES[0]
53-
if config_yml.exists():
54-
return str(config_yml)
55-
# Fall back to config.yaml
56-
config_yaml = project_path / CONFIG_FILENAMES[1]
57-
if config_yaml.exists():
58-
return str(config_yaml)
59-
# If neither exists, return the default (config.yml)
60-
return str(config_yml)
46+
for filename in CONFIG_FILENAMES:
47+
config_path = project_path / filename
48+
if config_path.exists():
49+
return str(config_path)
50+
return str(project_path / CONFIG_FILENAMES[0])
6151

6252

6353
def _kpms_dj_config_path(kpms_project_dir: Union[str, os.PathLike]) -> str:

0 commit comments

Comments
 (0)