Closed davidlatwe closed 6 years ago
Sham on me, wasn't think this right.
If changes to use os.path.join
for composing default plugin path, then will need to have os.path.normpath
to do path normalize, for someone already using backslash for default path's register/deregister (which is working but will not after this PR).
Now I think it's "Yes" for sure, both /
and \
could work as file path separator on Windows, so it did need normpath
to make sure that these two file path strings
path_1 = "server/plugins"
path_2 = r"server\plugins"
are the same workable path.
But on Linux, only /
could use as file path separator, \
could be part of the file or folder name, so those two file path strings above won't be recognized as same workable path. First one is a folder path for sure, but the second one could be a file name or else, so it's already a false input when on Linux.
Or at least a similar backslash such that you can register/deregister without thinking about it.
I think this did solve for Windows, but wasn't needed for Linux.
Then, in the Doctest, maybe there won't need two platform type of tests ? Since we won't need to test this r"server\plugins"
on a Linux machine, because it's not a file path for Linux at all.
So I changed as follow
"""
>>> import os
>>> my_plugins = os.path.join("server", "plugins")
>>> register_plugin_path(my_plugins) == os.path.normpath(my_plugins)
True
"""
Does this make sense ?
Then, in the Doctest, maybe there won't need two platform type of tests ? Since we won't need to test this r"server\plugins" on a Linux machine, because it's not a file path for Linux at all.
Yes, I think you're right. When you register these, you should register them using the slash of the active platform, e.g. via os.path.join()
. In which case this will work just fine.
I think this is good, it's definitely an improvement. Happy to merge this, if you could bump this to 1.5.6 in version.py then I'd be happy to merge this!
Thanks ! Right away :)
Thank you. :)
Change to
os.path.join
for cross-platform.