Skip to content

win.file_ext should return a set of strings? #271

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

Closed
rntz opened this issue Mar 16, 2021 · 3 comments
Closed

win.file_ext should return a set of strings? #271

rntz opened this issue Mar 16, 2021 · 3 comments

Comments

@rntz
Copy link

rntz commented Mar 16, 2021

Currently the default implementation of win.file_ext fails on files whose name contains a period or dot; for example, Section 2.5 Metatheory.tex is incorrectly regarded as having an extension of .5 Metatheory.tex. A simple "fix" would be to take the segment after the last dot in the file path (this is what I am currently doing). Unfortunately this would fail for files with multiple extensions, for example project.tar.gz would have an extension of .gz but not of .tar.gz. In reality, both of those are correct. This suggests that win.file_ext should return a set of strings rather than a single string.

@lunixbochs
Copy link

Hmm, I'm conflicted on this. Can you think of any alternate solutions?

@rntz
Copy link
Author

rntz commented Mar 16, 2021

I can't think of any use cases at the moment that need the full extension in the case of a compound extension like .tar.gz, because (1) the only use of win.file_ext that I know of is for language mode detection, and (2) I don't know any programming languages that use a compound extension for their source files. So I think the simplest fix would be to return the segment after the last dot rather than after the first. But I could be wrong about either (1) or (2).

@lunixbochs
Copy link

changed to str | set[str]

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

No branches or pull requests

2 participants