Closed djhoese closed 6 years ago
Perhaps using the Pathlib module which was introduced with Python 3 can help here. https://docs.python.org/3/library/pathlib.html
For example if i use it with a 'posix' Path on a Windows machine, it automatically converts to a pathlib.WindowsPath
object.
from pathlib import Path
p = Path('some/posix/path')
print(str(p))
Results in:
some\posix\path
I suspect it also works the other way around when on Linux.
In my limited experience with the Pathlib module i find it very convenient. Also for joining paths, checking if they exists etc. The only downside is that you have to use str(Path) when you want to pass it on to something which expects a string instead of a Path object. Which makes sense of course, but it requires some changes in the code. For example
gdal.Open(path) # where path is a string
Would become:
gdal.Open(str(path)) # where path is a Path object
For now we still have to support python 2.7, but pathlib would be nice. For this simple issue I'm hoping we can just do os.path.join(base_dir, *file_pattern.split("/"))
for now since we have to do the join for the base directory anyone (if I recall correctly).
I think that's fixed now
I believe commit 2dbb18685d33e09fbc37313d9968b6acc52ee7dc fixed this. @RutgerK, would you be able to test this ?
@mraspaud I don't see how it would have fixed it. It doesn't seem to address the wrong slashes being used in the file patterns.
my bad, it is commit 7d1942502a3079fe8af60d0873a2646ea190428b
Problem description
It was brought up on the mailing list that a Windows user had to modify the file patterns in the OLCI reader to not use "/" but use "\" instead. I would have thought that python would have handled this fine and found the files, but it didn't work for this user. It might be as simple as splitting on '/' and then using
os.path.join
to make the actual pathname to search for.@adybbroe Do you know if this is something you handle specially in pyspectral (with LUT paths, etc)?