hdx-python-api 6.7.5__py3-none-any.whl → 6.7.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hdx/api/_version.py +2 -2
- hdx/api/utilities/date_helper.py +5 -5
- hdx/data/resource.py +30 -2
- {hdx_python_api-6.7.5.dist-info → hdx_python_api-6.7.7.dist-info}/METADATA +4 -5
- {hdx_python_api-6.7.5.dist-info → hdx_python_api-6.7.7.dist-info}/RECORD +7 -7
- {hdx_python_api-6.7.5.dist-info → hdx_python_api-6.7.7.dist-info}/WHEEL +0 -0
- {hdx_python_api-6.7.5.dist-info → hdx_python_api-6.7.7.dist-info}/licenses/LICENSE +0 -0
hdx/api/_version.py
CHANGED
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '6.7.
|
|
22
|
-
__version_tuple__ = version_tuple = (6, 7,
|
|
21
|
+
__version__ = version = '6.7.7'
|
|
22
|
+
__version_tuple__ = version_tuple = (6, 7, 7)
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
hdx/api/utilities/date_helper.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Helper to the Dataset and Resource classes for handling HDX dates."""
|
|
2
2
|
|
|
3
3
|
from collections.abc import Iterable
|
|
4
|
-
from datetime import
|
|
4
|
+
from datetime import UTC, datetime
|
|
5
5
|
|
|
6
6
|
from hdx.utilities.dateparse import now_utc, parse_date
|
|
7
7
|
|
|
@@ -52,7 +52,7 @@ class DateHelper:
|
|
|
52
52
|
microsecond=0,
|
|
53
53
|
)
|
|
54
54
|
else:
|
|
55
|
-
date = date.astimezone(
|
|
55
|
+
date = date.astimezone(UTC)
|
|
56
56
|
if include_microseconds:
|
|
57
57
|
timespec = "microseconds"
|
|
58
58
|
else:
|
|
@@ -92,7 +92,7 @@ class DateHelper:
|
|
|
92
92
|
hour=23,
|
|
93
93
|
minute=59,
|
|
94
94
|
second=59,
|
|
95
|
-
tzinfo=
|
|
95
|
+
tzinfo=UTC,
|
|
96
96
|
)
|
|
97
97
|
ongoing = True
|
|
98
98
|
else:
|
|
@@ -179,8 +179,8 @@ class DateHelper:
|
|
|
179
179
|
retval = sorted(int(x) for x in list(startyear))
|
|
180
180
|
startyear = retval[0]
|
|
181
181
|
endyear = retval[-1]
|
|
182
|
-
startdate = datetime(startyear, 1, 1, tzinfo=
|
|
183
|
-
enddate = datetime(endyear, 12, 31, 23, 59, 59, tzinfo=
|
|
182
|
+
startdate = datetime(startyear, 1, 1, tzinfo=UTC)
|
|
183
|
+
enddate = datetime(endyear, 12, 31, 23, 59, 59, tzinfo=UTC)
|
|
184
184
|
return (
|
|
185
185
|
cls.get_hdx_time_period(startdate, enddate, ignore_timeinfo=False),
|
|
186
186
|
retval,
|
hdx/data/resource.py
CHANGED
|
@@ -4,13 +4,15 @@ import json
|
|
|
4
4
|
import logging
|
|
5
5
|
from collections.abc import Iterator, Sequence
|
|
6
6
|
from datetime import datetime
|
|
7
|
-
from pathlib import Path
|
|
7
|
+
from pathlib import Path, PureWindowsPath
|
|
8
8
|
from typing import Any, Optional
|
|
9
|
+
from urllib.parse import urlsplit
|
|
9
10
|
|
|
10
11
|
from hdx.utilities.dateparse import now_utc, now_utc_notz, parse_date
|
|
11
12
|
from hdx.utilities.downloader import Download
|
|
12
13
|
from hdx.utilities.file_hashing import get_size_and_hash
|
|
13
14
|
from hdx.utilities.retriever import Retrieve
|
|
15
|
+
from hdx.utilities.session import get_session
|
|
14
16
|
from hdx.utilities.uuid import is_valid_uuid
|
|
15
17
|
|
|
16
18
|
import hdx.api.utilities.url_utils
|
|
@@ -755,6 +757,22 @@ class Resource(HDXObject):
|
|
|
755
757
|
logger.debug(result)
|
|
756
758
|
return resources
|
|
757
759
|
|
|
760
|
+
@staticmethod
|
|
761
|
+
def _get_safe_filename(filename: str) -> str:
|
|
762
|
+
"""Strip any directory components (/ or \\) from a filename built from
|
|
763
|
+
resource metadata so downloads cannot be written outside the folder
|
|
764
|
+
|
|
765
|
+
Args:
|
|
766
|
+
filename: Filename to make safe
|
|
767
|
+
|
|
768
|
+
Returns:
|
|
769
|
+
Filename without directory components
|
|
770
|
+
"""
|
|
771
|
+
safe_filename = PureWindowsPath(filename).name
|
|
772
|
+
if safe_filename in ("", ".", ".."):
|
|
773
|
+
raise HDXError(f"Invalid filename {filename} for download!")
|
|
774
|
+
return safe_filename
|
|
775
|
+
|
|
758
776
|
def _download_file(
|
|
759
777
|
self,
|
|
760
778
|
url: str,
|
|
@@ -773,7 +791,17 @@ class Resource(HDXObject):
|
|
|
773
791
|
Returns:
|
|
774
792
|
Path to downloaded file
|
|
775
793
|
"""
|
|
776
|
-
|
|
794
|
+
# Only send the HDX API key to the HDX site, not to external resource URLs
|
|
795
|
+
hdx_site_url = self.configuration.get_hdx_site_url()
|
|
796
|
+
if urlsplit(url)[:2] == urlsplit(hdx_site_url)[:2]:
|
|
797
|
+
session = hdx.api.utilities.url_utils.get_ckan_ready_session(
|
|
798
|
+
self.configuration
|
|
799
|
+
)
|
|
800
|
+
else:
|
|
801
|
+
session = get_session(
|
|
802
|
+
full_agent=self.configuration.get_user_agent(), use_env=False
|
|
803
|
+
)
|
|
804
|
+
filename = self._get_safe_filename(filename)
|
|
777
805
|
with Download(session=session) as downloader:
|
|
778
806
|
if retriever:
|
|
779
807
|
downloader = retriever.clone(downloader)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: hdx-python-api
|
|
3
|
-
Version: 6.7.
|
|
3
|
+
Version: 6.7.7
|
|
4
4
|
Summary: HDX Python API for interacting with the Humanitarian Data Exchange
|
|
5
5
|
Project-URL: Homepage, https://github.com/OCHA-DAP/hdx-python-api
|
|
6
6
|
Author: Michael Rans
|
|
@@ -18,18 +18,17 @@ Classifier: Operating System :: Unix
|
|
|
18
18
|
Classifier: Programming Language :: Python
|
|
19
19
|
Classifier: Programming Language :: Python :: 3
|
|
20
20
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
22
21
|
Classifier: Programming Language :: Python :: 3.11
|
|
23
22
|
Classifier: Programming Language :: Python :: 3.12
|
|
24
23
|
Classifier: Programming Language :: Python :: 3.13
|
|
25
24
|
Classifier: Programming Language :: Python :: 3.14
|
|
26
25
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
|
-
Requires-Python: >=3.
|
|
26
|
+
Requires-Python: >=3.11
|
|
28
27
|
Requires-Dist: ckanapi>=4.11
|
|
29
28
|
Requires-Dist: defopt>=7.0.0
|
|
30
29
|
Requires-Dist: email-validator
|
|
31
|
-
Requires-Dist: hdx-python-country>=4.2.
|
|
32
|
-
Requires-Dist: hdx-python-utilities>=4.2.
|
|
30
|
+
Requires-Dist: hdx-python-country>=4.2.6
|
|
31
|
+
Requires-Dist: hdx-python-utilities>=4.2.5
|
|
33
32
|
Requires-Dist: makefun
|
|
34
33
|
Requires-Dist: requests
|
|
35
34
|
Provides-Extra: docs
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
hdx/api/__init__.py,sha256=11ozJKiUsqDCZ3_mcAHhGYUyGK_Unl54djVSBBExFB4,59
|
|
2
|
-
hdx/api/_version.py,sha256=
|
|
2
|
+
hdx/api/_version.py,sha256=vmqSkLqNCymV_Igs64SsTf8xbvuIFzv8XLWjCoHHoKw,520
|
|
3
3
|
hdx/api/configuration.py,sha256=9WvuVI-3th2Dv70_t_4VoyrlJwB_9qUSN5_zUKbp4sQ,23805
|
|
4
4
|
hdx/api/hdx_base_configuration.yaml,sha256=jj2t5b7NnI499rHVwOjj3Q5BAjE8i7NDGVKnWZ5P5-4,2222
|
|
5
5
|
hdx/api/locations.py,sha256=bFl_cKz_AEQzkE_xWOkrRlUQ0GT2LMPSk-G_LsbV-Ns,4099
|
|
6
6
|
hdx/api/remotehdx.py,sha256=IjKwP3jutlkrjvWCJPP7YM-xzg3pP_QVmiJfblllBY0,2079
|
|
7
7
|
hdx/api/utilities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
hdx/api/utilities/date_helper.py,sha256=
|
|
8
|
+
hdx/api/utilities/date_helper.py,sha256=KZE2sG0LM4gRa8ubNMaPFOoQl6giYoJUd7QNWQQf798,6355
|
|
9
9
|
hdx/api/utilities/filestore_helper.py,sha256=0FcUpGHpYlAzlNDpDxdXbSqV6VHFfGCLakCmK37hieU,6917
|
|
10
10
|
hdx/api/utilities/hdx_error_handler.py,sha256=x1rb2qBO0C6CJjqToSFj_XB1F3pf3nHpA8otxXfTFzA,8711
|
|
11
11
|
hdx/api/utilities/hdx_state.py,sha256=KzrK0A-H5R6cRPqwF4d23_S_zfIa1ow4K5u46FesGmY,2442
|
|
@@ -17,7 +17,7 @@ hdx/data/dataset.py,sha256=-GQO08PK8u19O0qRWttg3AuPskPCwjffcE2mPq-7dQE,105903
|
|
|
17
17
|
hdx/data/hdxobject.py,sha256=EG5KkVpi-yF6m6HVF79EqDneq1W7mo5M-bPJHG79T0I,28383
|
|
18
18
|
hdx/data/location.py,sha256=UJPGKc8euAYFJsUFkdQtViLUwqNWYOWwaLELApAMHk4,11168
|
|
19
19
|
hdx/data/organization.py,sha256=IRen2F2NsXLC8r-PVTS9eQp7LTn_44OcDUa1S7SCKiQ,13140
|
|
20
|
-
hdx/data/resource.py,sha256=
|
|
20
|
+
hdx/data/resource.py,sha256=XgYDGD5mYc89uaiRi0oamVJ5FTFSOV6QO_Nx-9_rjpo,57601
|
|
21
21
|
hdx/data/resource_matcher.py,sha256=Yzk9pWa4zk1p09m6zcZMj0XZf5Y16Pa3KToOdUt7rP8,4247
|
|
22
22
|
hdx/data/resource_view.py,sha256=GcYkh0iDAe6_m2ErY_A6i3Z7ZFX949eGt1TLnLZv_8s,7346
|
|
23
23
|
hdx/data/showcase.py,sha256=vnRZ45xd9Ct65eFQkWZtMIJPFifZfKOrH4obO5D5Pvc,14062
|
|
@@ -27,7 +27,7 @@ hdx/facades/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
27
27
|
hdx/facades/infer_arguments.py,sha256=DvyDuozfOPmoaV7HjhQySojGIrMWW9nos31auQBVVl8,4032
|
|
28
28
|
hdx/facades/keyword_arguments.py,sha256=aVapHCfqBO6H7xxBgTdK9ISdgrBFsNypPDWihfQ3edU,1125
|
|
29
29
|
hdx/facades/simple.py,sha256=QWsBkaHG_UM6X3Zu2u3LWVOQzeR24q-EUClrfsL_mkM,1064
|
|
30
|
-
hdx_python_api-6.7.
|
|
31
|
-
hdx_python_api-6.7.
|
|
32
|
-
hdx_python_api-6.7.
|
|
33
|
-
hdx_python_api-6.7.
|
|
30
|
+
hdx_python_api-6.7.7.dist-info/METADATA,sha256=aCpCaXGb8JL15Aw2wnOZkEMEflXwdQGXe7IY7RzL0y4,4895
|
|
31
|
+
hdx_python_api-6.7.7.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
32
|
+
hdx_python_api-6.7.7.dist-info/licenses/LICENSE,sha256=wc-4GpMn-ODs-U_bTe1YCiPVgvcjzrpYOx2wPuyAeII,1079
|
|
33
|
+
hdx_python_api-6.7.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|