Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion encexp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
7 changes: 6 additions & 1 deletion encexp/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,24 @@

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))
return tweet_iterator(output)
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)
Expand Down
13 changes: 11 additions & 2 deletions encexp/tests/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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)
Loading