-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove some prints and fix if the destination is empty
- Loading branch information
Showing
3 changed files
with
41 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from pathlib import Path | ||
from typing import Union | ||
from urllib.parse import urlparse | ||
|
||
__copyright__ = 'Copyright 2022, 3Liz' | ||
__license__ = 'GPL version 3' | ||
__email__ = 'info@3liz.org' | ||
|
||
|
||
def is_url(uri: Union[Path, str]) -> bool: | ||
""" Check if the URI can be a URL. """ | ||
if isinstance(uri, Path): | ||
return False | ||
|
||
path = Path(uri) | ||
if path.exists(): | ||
return False | ||
|
||
# noinspection PyBroadException | ||
try: | ||
urlparse(uri) | ||
return True | ||
except Exception: | ||
return False |