Files
krowlog/urlutils.py
2021-10-29 11:02:38 +02:00

15 lines
317 B
Python

import os
from urllib.parse import urlparse
def url_to_path(url: str) -> str:
p = urlparse(url)
return os.path.abspath(os.path.join(p.netloc, p.path))
def url_is_file(url: str) -> bool:
if url.startswith("file://"):
path = url_to_path(url)
return os.path.isfile(path)
return False