Skip to content

Modernize _parse_ext to handle multi-extension filenames#1536

Open
scott-huberty wants to merge 1 commit intomne-tools:mainfrom
scott-huberty:parse_ext
Open

Modernize _parse_ext to handle multi-extension filenames#1536
scott-huberty wants to merge 1 commit intomne-tools:mainfrom
scott-huberty:parse_ext

Conversation

@scott-huberty
Copy link
Copy Markdown
Collaborator

@scott-huberty scott-huberty commented Mar 12, 2026

Related to #1528

_parse_ext splits a filename into its stem and extension. It already contained a special case for .nii.gz files. here I refactor it to generally handle multi-extension filenames (EDIT: because I need _parse_ext to handle .tsv.gz files).

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.98%. Comparing base (8e52e3e) to head (8332acb).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1536      +/-   ##
==========================================
- Coverage   97.00%   96.98%   -0.02%     
==========================================
  Files          43       43              
  Lines       10692    10697       +5     
==========================================
+ Hits        10372    10375       +3     
- Misses        320      322       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

data_path = testing_path / "EEGLAB"
raw_fname = data_path / fname
new_name = bids_root / f"CONVERTED_{fname}.set"
new_name = bids_root / f"CONVERTED_{fname}"
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's why I think this test was weird and why I think it warrants a change.

copyfile_eeglab will throw an error if dest contains a different extension than src.

On main, fname == "test_raw.set" and new_name == "/CONVERTED_test_raw.set.set")

So on L231, we do copyfile_eeglab(raw_fname, new_name)

and inside copyfile_eeglab, we do _parse_ext("/CONVERTED_test_raw.set.set") which returns ('/CONVERTED_test_raw.set', '.set') ..

I think this just happened to work because now the files end up with the same extension even though _parse_ext didn't really do its job, and even though the caller passed a dest with a different extension than src.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant