absolute.py 415 B

123456789101112131415
  1. """Whether a path is spelled absolutely on any platform, not just the one this runs on."""
  2. from __future__ import annotations
  3. import ntpath
  4. import os
  5. def spelled(path: str) -> bool:
  6. """True for a rooted, drive-qualified or UNC path, whichever platform reads it."""
  7. return (
  8. os.path.isabs(path)
  9. or path.replace("\\", "/").startswith("/")
  10. or bool(ntpath.splitdrive(path)[0])
  11. )