Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make list atlas function more robust #417

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
"""

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
adamltyson marked this conversation as resolved.
Show resolved Hide resolved


def get_all_atlases_lastversions():
Expand Down
Loading