Modernize _parse_ext to handle multi-extension filenames#1536
Modernize _parse_ext to handle multi-extension filenames#1536scott-huberty wants to merge 1 commit intomne-tools:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
| 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}" |
There was a problem hiding this comment.
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.
Related to #1528
_parse_extsplits a filename into its stem and extension. It already contained a special case for.nii.gzfiles. here I refactor it to generally handle multi-extension filenames (EDIT: because I need_parse_extto handle.tsv.gzfiles).