the-siesta-group / edfio

Read and write EDF/EDF+ files.
Apache License 2.0
25 stars 5 forks source link

Consider expanding `~` in a file path #22

Closed cbrnr closed 7 months ago

cbrnr commented 7 months ago

If the path provided to edfio.read_edf() contains a ~, I get a FileNotFoundError. The reason is that the tilde is not expanded to the user's home directory. I think it would be useful if the function expanded paths internally.

hofaflo commented 7 months ago

I like the idea! Not sure how to best test this though :thinking:

cbrnr commented 7 months ago

Hm, good question. But it is so simple that maybe there's no need for a test?

hofaflo commented 7 months ago

We can assume that it works, yes. I'd prefer to have a test to avoid inadvertently breaking the behavior in the future though.

cbrnr commented 7 months ago

I agree. If tilde resolves to a directory on the test runners that we can use, we can write a test.

PS: I'd also throw in .resolve() to resolve symlinks, WDYT?

cbrnr commented 7 months ago

Maybe we can use the error message in a test. If it still contains a ~, it didn't get expanded. If it doesn't contain a ~, expansion worked.