Update path_dwim() to return absolute path
If path_dwim() is provided a relative path to a file, it will now return an absolute path of the playbook directory + the relative file path.
This commit is contained in:
parent
b54bb2dfed
commit
2100a35663
1 changed files with 5 additions and 2 deletions
|
@ -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 '''
|
||||
|
|
Loading…
Reference in a new issue