open files by drag&drop
This commit is contained in:
14
urlutils.py
Normal file
14
urlutils.py
Normal 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
|
||||
Reference in New Issue
Block a user