paths.py 349 B

12345678910111213
  1. from .compat import Path
  2. from os.path import expanduser, expandvars, isabs
  3. def resolve_from_str(input, root):
  4. assert not isinstance(input, Path), "would break on py2"
  5. root = Path(root)
  6. input = expanduser(input)
  7. input = expandvars(input)
  8. if isabs(input):
  9. return Path(input)
  10. else:
  11. return root.joinpath(input)