Skip to content

Commit

Permalink
Add resource download function
Browse files Browse the repository at this point in the history
  • Loading branch information
mcarans committed Oct 25, 2016
1 parent cd5b884 commit 962dc0b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions hdx/data/hdxobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def update_from_json(self, path: str):

def _read_from_hdx(self, object_type: str, value: str, fieldname: Optional[str] = 'id',
action: Optional[str] = None,
**kwargs) -> Union[Tuple[bool, dict], Tuple[bool, str]]:
**kwargs) -> Tuple[bool, Union[dict, str]]:
"""Makes a read call to HDX passing in given parameter.
Args:
Expand All @@ -95,7 +95,7 @@ def _read_from_hdx(self, object_type: str, value: str, fieldname: Optional[str]
**kwargs: Other fields to pass to CKAN.
Returns:
(bool, dict/str): (True/False, HDX object metadata/Error)
Tuple[bool, Union[dict, str]]: (True/False, HDX object metadata/Error)
"""
if not value:
raise HDXError("Empty %s value!" % object_type)
Expand Down
8 changes: 4 additions & 4 deletions hdx/data/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import logging
import os
from os.path import join
from typing import Optional, List
from typing import Optional, List, Tuple

from hdx.configuration import Configuration
from hdx.utilities.downloader import download_file
Expand Down Expand Up @@ -160,14 +160,14 @@ def delete_datastore(self) -> None:
if not success:
logger.debug(result)

def download(self, path: Optional[str] = None) -> (str, str):
"""Download resource store in provided path or named temporary file if no path given
def download(self, path: Optional[str] = None) -> Tuple[str, str]:
"""Download resource store to provided path or named temporary file if no path given
Args:
path (str): Path to download resource to. Defaults to None.
Returns:
(str, str): (URL downloaded, Path of downloaded file)
Tuple[str, str]: (URL downloaded, Path to downloaded file)
"""
# Download the resource
Expand Down

0 comments on commit 962dc0b

Please sign in to comment.