Commit e93ed2c1 by Stephen Fromm

Merge pull request #1818 from sfromm/issue1815

Update path_dwim() to return absolute path
parents b54bb2df 2100a356
...@@ -168,14 +168,17 @@ def prepare_writeable_dir(tree): ...@@ -168,14 +168,17 @@ def prepare_writeable_dir(tree):
exit("Cannot write to path %s" % tree) exit("Cannot write to path %s" % tree)
def path_dwim(basedir, given): 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("/"): if given.startswith("/"):
return given return given
elif given.startswith("~/"): elif given.startswith("~/"):
return os.path.expanduser(given) return os.path.expanduser(given)
else: else:
return os.path.join(basedir, given) return os.path.abspath(os.path.join(basedir, given))
def json_loads(data): def json_loads(data):
''' parse a JSON string and return a data structure ''' ''' parse a JSON string and return a data structure '''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment