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

Merge pull request #1818 from sfromm/issue1815

Update path_dwim() to return absolute path
This commit is contained in:
Stephen Fromm 2013-01-02 22:04:16 -08:00
commit e93ed2c167

View file

@ -168,14 +168,17 @@ def prepare_writeable_dir(tree):
exit("Cannot write to path %s" % tree)
def path_dwim(basedir, given):
''' make relative paths work like folks expect '''
'''
make relative paths work like folks expect.
if a relative path is provided, convert it to an absolute path.
'''
if given.startswith("/"):
return given
elif given.startswith("~/"):
return os.path.expanduser(given)
else:
return os.path.join(basedir, given)
return os.path.abspath(os.path.join(basedir, given))
def json_loads(data):
''' parse a JSON string and return a data structure '''