-
Notifications
You must be signed in to change notification settings - Fork 37
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
fix: added support for custom file extension with multiple parts #710
Conversation
Ignore the benchmark failure, it's a permissions issue. I'll try take a look at this PR in the next couple days. Rather than loop through stems, I feel like there should be some sort of "basename without user supplied extension" function in the python stdlib. |
I don't like the loop either. I looked for this but couldn't find it😀 if I can find some time tomorrow, I'll check the stem implementation and get some inspiration from that 😅 |
from pathlib import Path | ||
|
||
|
||
def test_multiple_file_extensions(testdir): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't make your test fail on main, so I've replaced it with more of an integration test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you couldn't trigger the test because of a typo:
class DotInFileExtension(SingleFileSnapshotExtension):
_file_extension = "{file_extension}"
The f
was missing before the f-string :) That was fixed when you moved it into an integration test setup.
Anyways, thank you for the merge!
@all-contributors add @tolgaeren for bug |
I've put up a pull request to add @tolgaeren! 🎉 |
## [4.0.1](v4.0.0...v4.0.1) (2023-02-21) ### Bug Fixes * **serializer:** handling of multi-part file extensions in SingleFileExtension ([#710](#710)) ([efe687e](efe687e))
🎉 This PR is included in version 4.0.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Description
This PR modifies the
single_file.py
to add support for multiple extension parts. An example is setting"tar.gz"
as the custom_file_extention
string:Previously this was causing some unexpected behavior as described in #703 . I've found the problematic part in
SingleFileSnapshotExtension._read_snapshot_collection
insingle_file.py
:.stem
only removes the last extension not all the extensions as documented. We would like to remove as many extensions as there are in the_file_extension
string.There are a few ways to fix it:
.stem
as many times as number of extensions..with_suffix("")
as many times as the number of extensions.self._file_extension
at the end ofsnapsot_location
with""
.I tried option 3 first, it seemed to break a lot of other tests. Then I picked option 1 as it seemed it was the closest to original implementation. Let me know if you think of a better way to do it.
Added a test under
test_single_file.py
as it seemed like the right location for it.Related Issues
Checklist
Additional Comments
No additional comments.