open files by drag&drop

This commit is contained in:
2021-10-29 11:02:38 +02:00
parent 6653f2ae89
commit 5b9db22f39
3 changed files with 34 additions and 42 deletions

14
urlutils.py Normal file
View File

@@ -0,0 +1,14 @@
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