1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

normalize path components to unicode before combining or operating on them

Note that this will break if we deal with non-utf8 paths.  Fixing this
way because converting everythig to byte strings instead is a very
invasive task so it should be done as a specific feature to provide
support for non-utf8 paths at some point in the future (if needed).
This commit is contained in:
Toshio Kuratomi 2016-02-26 10:26:49 -08:00
parent ef8bec18bf
commit 1f2595306a

View file

@ -199,13 +199,15 @@ class DataLoader():
'''
given = unquote(given)
given = to_unicode(given, errors='strict')
if given.startswith("/"):
if given.startswith(u"/"):
return os.path.abspath(given)
elif given.startswith("~"):
elif given.startswith(u"~"):
return os.path.abspath(os.path.expanduser(given))
else:
return os.path.abspath(os.path.join(self._basedir, given))
basedir = to_unicode(self._basedir, errors='strict')
return os.path.abspath(os.path.join(basedir, given))
def path_dwim_relative(self, path, dirname, source):
'''