Skip to content

Commit 896c50b

Browse files
author
Mike
committed
Update HDX Python Country
1 parent 0300613 commit 896c50b

3 files changed

Lines changed: 21 additions & 17 deletions

File tree

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ckanapi==4.7
22
defopt==6.3.0
33
email_validator==1.2.1
4-
hdx-python-country==3.2.7
4+
hdx-python-country==3.2.8
55
ndg-httpsclient==0.5.1
66
pyasn1==0.4.8
77
pyOpenSSL==22.0.0

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ install_requires =
4545
ckanapi >= 4.7
4646
defopt
4747
email_validator
48-
hdx-python-country>=3.2.7
48+
hdx-python-country>=3.2.8
4949
ndg-httpsclient
5050
pyasn1
5151
pyOpenSSL

src/hdx/data/resource.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020

2121
class Resource(HDXObject):
22-
"""Resource class containing all logic for creating, checking, and updating resources.
22+
"""Resource class containing all logic for creating, checking, and updating
23+
resources.
2324
2425
Args:
2526
initial_data (Optional[Dict]): Initial resource metadata dictionary. Defaults to None.
@@ -106,10 +107,11 @@ def get_date_of_resource(
106107
date_format: Optional[str] = None,
107108
today: datetime.date = datetime.date.today(),
108109
) -> Dict:
109-
"""Get resource date as datetimes and strings in specified format. If no format is supplied, the ISO 8601
110-
format is used. Returns a dictionary containing keys startdate (start date as datetime), enddate (end
111-
date as datetime), startdate_str (start date as string), enddate_str (end date as string) and ongoing
112-
(whether the end date is a rolls forward every day).
110+
"""Get resource date as datetimes and strings in specified format. If no format
111+
is supplied, the ISO 8601 format is used. Returns a dictionary containing keys
112+
startdate (start date as datetime), enddate (end date as datetime),
113+
startdate_str (start date as string), enddate_str (end date as string) and
114+
ongoing (whether the end date is a rolls forward every day).
113115
114116
Args:
115117
date_format (Optional[str]): Date format. None is taken to be ISO 8601. Defaults to None.
@@ -201,10 +203,10 @@ def get_mapped_format(
201203
Returns:
202204
Optional[str]: Mapped format or None if no mapping found
203205
"""
204-
if configuration is None:
205-
configuration = Configuration.read()
206206
if not file_type:
207207
return None
208+
if configuration is None:
209+
configuration = Configuration.read()
208210
file_type = file_type.lower()
209211
mappings = cls.read_formats_mappings(configuration=configuration)
210212
format = mappings.get(file_type)
@@ -232,7 +234,6 @@ def set_file_type(self, file_type: str) -> str:
232234
233235
Args:
234236
file_type (str): File type to set on resource
235-
log_none (bool): Whether to log an informational message about the file type being None. Defaults to True.
236237
237238
Returns:
238239
str: Format that was set
@@ -248,7 +249,8 @@ def set_file_type(self, file_type: str) -> str:
248249
return format
249250

250251
def clean_file_type(self) -> str:
251-
"""Clean the resource's file type, setting it to None if it is invalid and cannot be mapped
252+
"""Clean the resource's file type, setting it to None if it is invalid and
253+
cannot be mapped
252254
253255
Returns:
254256
str: Format that was set
@@ -270,7 +272,7 @@ def set_file_to_upload(
270272
271273
Args:
272274
file_to_upload (str): Local path to file to upload
273-
guess_format_from_suffix (bool): Whether to try to set format based on file suffix. Defaults to False.
275+
guess_format_from_suffix (bool): Set format from file suffix. Defaults to False.
274276
275277
Returns:
276278
Optional[str]: The format that was guessed or None if no format was set
@@ -284,8 +286,8 @@ def set_file_to_upload(
284286
return format
285287

286288
def check_url_filetoupload(self) -> None:
287-
"""Check if url or file to upload provided for resource and add resource_type and url_type if not supplied.
288-
Correct the file type.
289+
"""Check if url or file to upload provided for resource and add resource_type
290+
and url_type if not supplied. Correct the file type.
289291
290292
Returns:
291293
None
@@ -318,8 +320,9 @@ def check_url_filetoupload(self) -> None:
318320
self.clean_file_type()
319321

320322
def check_required_fields(self, ignore_fields: List[str] = list()) -> None:
321-
"""Check that metadata for resource is complete. The parameter ignore_fields should be set if required to
322-
any fields that should be ignored for the particular operation.
323+
"""Check that metadata for resource is complete. The parameter ignore_fields
324+
should be set if required to any fields that should be ignored for the
325+
particular operation.
323326
324327
Args:
325328
ignore_fields (List[str]): Fields to ignore. Default is [].
@@ -431,7 +434,8 @@ def search_in_hdx(
431434
return resources
432435

433436
def download(self, folder: Optional[str] = None) -> Tuple[str, str]:
434-
"""Download resource store to provided folder or temporary folder if no folder supplied
437+
"""Download resource store to provided folder or temporary folder if no folder
438+
supplied
435439
436440
Args:
437441
folder (Optional[str]): Folder to download resource to. Defaults to None.

0 commit comments

Comments
 (0)