diff --git a/encexp/__init__.py b/encexp/__init__.py index 8df4d85..0499652 100644 --- a/encexp/__init__.py +++ b/encexp/__init__.py @@ -17,4 +17,4 @@ if not '-m' in sys.argv: from encexp.text_repr import EncExpT, SeqTM, TextModel -__version__ = "0.1.7" +__version__ = "0.1.8" diff --git a/encexp/download.py b/encexp/download.py index 893ed95..13d951e 100644 --- a/encexp/download.py +++ b/encexp/download.py @@ -19,12 +19,15 @@ def download(identifier: str, first: bool=True, base_url: str=EncExp_URL, - outputdir: str=MODELS): + outputdir: str=MODELS, + return_path: bool=False): """download""" if not isdir(outputdir): os.mkdir(outputdir) output = join(outputdir, f'{identifier}.json.gz') if isfile(output): + if return_path: + return output try: if first: return next(tweet_iterator(output)) @@ -32,6 +35,8 @@ def download(identifier: str, first: bool=True, except Exception: os.unlink(output) Download(base_url + f'/{identifier}.json.gz', output) + if return_path: + return output if first: return next(tweet_iterator(output)) return tweet_iterator(output) diff --git a/encexp/tests/test_download.py b/encexp/tests/test_download.py index 9607cb2..4dafabe 100644 --- a/encexp/tests/test_download.py +++ b/encexp/tests/test_download.py @@ -15,11 +15,20 @@ from os.path import isfile import os import numpy as np -from encexp.download import download_TextModel +from encexp.download import download_TextModel, download def test_download_TextModel(): """Test download TextModel""" from encexp import TextModel tm = TextModel(lang='es') - download_TextModel(tm.identifier) \ No newline at end of file + download_TextModel(tm.identifier) + + +def test_download_path(): + """Test download path""" + + path = download('es_info', return_path=True) + assert isfile(path) + path = download('es_info', return_path=True) + assert isfile(path) \ No newline at end of file