Skip to content

Commit c0c9935

Browse files
committed
cleanup long settings if statements
1 parent 0c4440b commit c0c9935

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

src/spyglass/settings.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,14 @@ def load_config(
187187
Path(self._moseq_base).mkdir(exist_ok=True)
188188

189189
config_dirs = {"SPYGLASS_BASE_DIR": str(resolved_base)}
190+
source_config_lookup = {
191+
"dlc": dj_dlc,
192+
"moseq": dj_moseq,
193+
"kachery": dj_kachery,
194+
}
195+
base_lookup = {"dlc": self._dlc_base, "moseq": self._moseq_base}
190196
for prefix, dirs in self.relative_dirs.items():
191-
this_base = (
192-
self._dlc_base
193-
if prefix == "dlc"
194-
else (self._moseq_base if prefix == "moseq" else resolved_base)
195-
)
197+
this_base = base_lookup.get(prefix, resolved_base)
196198
for dir, dir_str in dirs.items():
197199
dir_env_fmt = self.dir_to_var(dir=dir, dir_type=prefix)
198200

@@ -201,14 +203,7 @@ def load_config(
201203
if not self.supplied_base_dir
202204
else None
203205
)
204-
if prefix == "dlc":
205-
source_config = dj_dlc
206-
elif prefix == "moseq":
207-
source_config = dj_moseq
208-
elif prefix == "kachery":
209-
source_config = dj_kachery
210-
else:
211-
source_config = dj_spyglass
206+
source_config = source_config_lookup.get(prefix, dj_spyglass)
212207
dir_location = (
213208
source_config.get(dir)
214209
or env_loc

0 commit comments

Comments
 (0)