Skip to content

Commit

Permalink
Make list atlas function more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
adamltyson committed Oct 29, 2024
1 parent e718f4c commit 60fbb0e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions brainglobe_atlasapi/list_atlases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Some functionality to list all available and downloaded brainglobe atlases
"""

import re

from rich import print as rprint
from rich.panel import Panel
from rich.table import Table
Expand Down Expand Up @@ -43,11 +45,15 @@ def get_local_atlas_version(atlas_name):
"""

brainglobe_dir = config.get_brainglobe_dir()
return [
f.name.split("_v")[1]
for f in brainglobe_dir.glob(f"*{atlas_name}*")
if f.is_dir()
][0]
try:
return [
re.search(r"_v(\d+\.\d+)$", f.name).group(1)
for f in brainglobe_dir.glob(f"*{atlas_name}*")
if f.is_dir() and re.search(r"_v(\d+\.\d+)$", f.name)
][0]
except IndexError:
print(f"No atlas found with the name: {atlas_name}")
return None

Check warning on line 56 in brainglobe_atlasapi/list_atlases.py

View check run for this annotation

Codecov / codecov/patch

brainglobe_atlasapi/list_atlases.py#L54-L56

Added lines #L54 - L56 were not covered by tests


def get_all_atlases_lastversions():
Expand Down

0 comments on commit 60fbb0e

Please sign in to comment.