forked from PMBio/limix
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
146 additions
and
47 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
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 |
---|---|---|
@@ -1,8 +1,6 @@ | ||
from ._extract import extract | ||
from ._file import remove | ||
from ._dir import makedirs | ||
from ._hash import filehash | ||
from ._url import download | ||
from ._user_dir import user_cache_dir | ||
|
||
__all__ = ["filehash", "download", "extract", "remove", "user_cache_dir", "makedirs"] | ||
__all__ = ["filehash", "download", "extract", "remove"] |
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 |
---|---|---|
@@ -1,4 +1,12 @@ | ||
def remove(filepath): | ||
""" | ||
Remove file. | ||
Parameters | ||
---------- | ||
filepath : str | ||
File path. | ||
""" | ||
import os | ||
|
||
return os.remove(filepath) |
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 |
---|---|---|
@@ -1,36 +1,42 @@ | ||
import sys | ||
|
||
from .._display import session_line | ||
|
||
PY2 = sys.version_info < (3,) | ||
|
||
|
||
def download(url, dest=None, verbose=True): | ||
""" | ||
Download file. | ||
Parameters | ||
---------- | ||
url : str | ||
Url to the file. | ||
dest : str, optional | ||
File destination. The current working directory is used if ``None`` is passed. | ||
Defaults to ``None``. | ||
verbose : bool, optional | ||
``True`` for displaying progress. Defaults to ``True``. | ||
Returns | ||
------- | ||
filepath : str | ||
File path to the downloaded file. | ||
""" | ||
import os | ||
|
||
if PY2: | ||
from urllib import urlretrieve | ||
else: | ||
from urllib.request import urlretrieve | ||
from urllib.request import urlretrieve | ||
|
||
if dest is None: | ||
dest = os.getcwd() | ||
|
||
filepath = os.path.join(dest, _filename(url)) | ||
|
||
with session_line("Downloading {}... ".format(url), disable=not verbose): | ||
with session_line(f"Downloading {url}... ", disable=not verbose): | ||
urlretrieve(url, filepath) | ||
|
||
return filepath | ||
|
||
|
||
def _filename(url): | ||
import os | ||
|
||
if PY2: | ||
from urlparse import urlparse | ||
else: | ||
from urllib.parse import urlparse | ||
from urllib.parse import urlparse | ||
|
||
a = urlparse(url) | ||
return os.path.basename(a.path) |