hdx-python-api 6.6.5__tar.gz → 6.6.6__tar.gz
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_python_api-6.6.5 → hdx_python_api-6.6.6}/PKG-INFO +3 -3
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/pyproject.toml +2 -2
- hdx_python_api-6.6.6/src/hdx/api/_version.py +24 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/data/dataset.py +29 -372
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/data/resource.py +0 -22
- hdx_python_api-6.6.6/tests/fixtures/config/hdx_resource_view_static.yaml +3 -0
- hdx_python_api-6.6.6/tests/fixtures/update_dataset_resources/expected_resources_to_update.json +85 -0
- hdx_python_api-6.6.6/tests/fixtures/update_dataset_resources/unesco_dataset.json +1 -0
- hdx_python_api-6.6.6/tests/fixtures/update_dataset_resources/unesco_update_dataset.json +1 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/api/test_ckan.py +2 -2
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/data/test_dataset_core.py +6 -6
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/data/test_dataset_noncore.py +3 -3
- hdx_python_api-6.6.6/tests/hdx/data/test_dataset_resource_generation.py +518 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/data/test_resource.py +2 -2
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/data/test_resource_view.py +15 -20
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/data/test_update_dataset_resources.py +0 -1
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/data/test_update_logic.py +3 -12
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/data/test_vocabulary.py +0 -6
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/uv.lock +8 -87
- hdx_python_api-6.6.5/src/hdx/api/_version.py +0 -34
- hdx_python_api-6.6.5/src/hdx/data/hdx_datasource_topline.yaml +0 -30
- hdx_python_api-6.6.5/src/hdx/data/indicator_resource_view_template.yaml +0 -4
- hdx_python_api-6.6.5/tests/fixtures/config/hdx_resource_view_static.yaml +0 -4
- hdx_python_api-6.6.5/tests/fixtures/update_dataset_resources/expected_resources_to_update.json +0 -85
- hdx_python_api-6.6.5/tests/fixtures/update_dataset_resources/unesco_dataset.json +0 -1
- hdx_python_api-6.6.5/tests/fixtures/update_dataset_resources/unesco_update_dataset.json +0 -1
- hdx_python_api-6.6.5/tests/hdx/data/test_dataset_resource_generation.py +0 -1088
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/.github/workflows/publish.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/.github/workflows/run-python-tests.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/.gitignore +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/.pre-commit-config.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/LICENSE +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/README.md +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/documentation/.readthedocs.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/documentation/index.md +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/documentation/mkdocs.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/api/__init__.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/api/configuration.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/api/hdx_base_configuration.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/api/locations.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/api/remotehdx.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/api/utilities/__init__.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/api/utilities/date_helper.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/api/utilities/filestore_helper.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/api/utilities/hdx_error_handler.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/api/utilities/hdx_state.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/api/utilities/url_utils.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/data/__init__.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/data/hdxobject.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/data/organization.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/data/resource_matcher.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/data/resource_view.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/data/showcase.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/data/user.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/data/vocabulary.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/facades/__init__.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/facades/infer_arguments.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/facades/keyword_arguments.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/src/hdx/facades/simple.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/__init__.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/Accepted_Tags.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/CKAN/hdx_dataset_static.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/Tag_Mapping.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/Tag_Mapping_ChainRuleError.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/empty.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/hdx_base_config.json +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/hdx_base_config.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/hdx_config.json +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/hdx_config.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/hdx_dataset_static.json +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/hdx_dataset_static.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/hdx_datasource_topline.json +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/hdx_datasource_topline.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/hdx_email_configuration.json +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/hdx_email_configuration.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/hdx_missing_site_config.json +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/hdx_organization_static.json +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/hdx_organization_static.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/hdx_resource_static.json +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/hdx_resource_static.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/hdx_resource_view_static.json +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/hdx_showcase_static.json +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/hdx_showcase_static.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/hdx_user_static.json +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/hdx_user_static.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/hdx_vocabulary_static.json +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/hdx_vocabulary_static.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/project_configuration.json +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/project_configuration.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/user_agent_config.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/user_agent_config2.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/user_agent_config3.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/config/user_agent_config_wrong.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/dataset_search_results.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/download_gen_resource/conflict_data_alg.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/download_gen_resource/min_qc_conflict_data_alg.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/download_gen_resource/qc_conflict_data_alg.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/download_gen_resource/test_data_no_data.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/download_gen_resource/test_data_no_years.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/empty.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/gen_resource/conflict_data_alg.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/gen_resource/min_qc_conflict_data_alg.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/gen_resource/qc_conflict_data_alg.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/gen_resource/test_data_no_data.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/gen_resource/test_data_no_years.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/organization_show_results.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/qc_from_rows/qc_conflict_data_alg.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/qc_from_rows/qc_conflict_data_alg_one_col.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/resource_formats.json +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/showcase_all_search_results.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/size_hash/ACLED-All-Africa-File_20170101-to-20170708.xlsx +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/state/analysis_dates.txt +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/state/last_build_date.txt +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/test_data.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/test_data.zip +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/update_dataset_resources/dem_data_zwe.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/update_dataset_resources/dem_indicatorlist_zwe.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/update_dataset_resources/opri_data_zwe.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/update_dataset_resources/opri_indicatorlist_zwe.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/update_dataset_resources/opri_metadata_zwe.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/update_dataset_resources/qc_sdg_data_zwe.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/update_dataset_resources/sdg_data_zwe.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/update_dataset_resources/sdg_indicatorlist_zwe.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/update_dataset_resources/sdg_metadata_zwe.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/update_logic/update_logic_resources.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/fixtures/update_logic/update_logic_resources_new.yaml +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/__init__.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/api/__init__.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/api/test_configuration.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/api/test_locations.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/api/utilities/__init__.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/api/utilities/test_filestore_helper.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/api/utilities/test_hdx_error_handler.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/api/utilities/test_hdx_state.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/api/utilities/test_url_utils.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/conftest.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/data/__init__.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/data/test_dataset_add_hapi_error.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/data/test_organization.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/data/test_showcase.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/data/test_user.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/facades/__init__.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/facades/test_infer_arguments.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/facades/test_keyword_arguments.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/tests/hdx/facades/test_simple.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/workingexample/my_code.py +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/workingexample/my_resource.csv +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/workingexample/my_resource.xlsx +0 -0
- {hdx_python_api-6.6.5 → hdx_python_api-6.6.6}/workingexample/run.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hdx-python-api
|
|
3
|
-
Version: 6.6.
|
|
3
|
+
Version: 6.6.6
|
|
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
|
|
@@ -28,8 +28,8 @@ Requires-Python: >=3.10
|
|
|
28
28
|
Requires-Dist: ckanapi>=4.8
|
|
29
29
|
Requires-Dist: defopt>=7.0.0
|
|
30
30
|
Requires-Dist: email-validator
|
|
31
|
-
Requires-Dist: hdx-python-country>=4.
|
|
32
|
-
Requires-Dist: hdx-python-utilities>=4.0.
|
|
31
|
+
Requires-Dist: hdx-python-country>=4.1.1
|
|
32
|
+
Requires-Dist: hdx-python-utilities>=4.0.8
|
|
33
33
|
Requires-Dist: makefun
|
|
34
34
|
Requires-Dist: requests
|
|
35
35
|
Provides-Extra: docs
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# file generated by vcs-versioning
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"__version__",
|
|
7
|
+
"__version_tuple__",
|
|
8
|
+
"version",
|
|
9
|
+
"version_tuple",
|
|
10
|
+
"__commit_id__",
|
|
11
|
+
"commit_id",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
version: str
|
|
15
|
+
__version__: str
|
|
16
|
+
__version_tuple__: tuple[int | str, ...]
|
|
17
|
+
version_tuple: tuple[int | str, ...]
|
|
18
|
+
commit_id: str | None
|
|
19
|
+
__commit_id__: str | None
|
|
20
|
+
|
|
21
|
+
__version__ = version = '6.6.6'
|
|
22
|
+
__version_tuple__ = version_tuple = (6, 6, 6)
|
|
23
|
+
|
|
24
|
+
__commit_id__ = commit_id = None
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
import json
|
|
4
4
|
import logging
|
|
5
5
|
import sys
|
|
6
|
-
import
|
|
7
|
-
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
|
|
6
|
+
from collections.abc import Callable, Iterable, Mapping, Sequence
|
|
8
7
|
from copy import deepcopy
|
|
9
8
|
from datetime import datetime
|
|
10
9
|
from pathlib import Path
|
|
@@ -26,7 +25,6 @@ from hdx.utilities.dateparse import (
|
|
|
26
25
|
parse_date_range,
|
|
27
26
|
)
|
|
28
27
|
from hdx.utilities.dictandlist import merge_two_dictionaries
|
|
29
|
-
from hdx.utilities.downloader import Download
|
|
30
28
|
from hdx.utilities.loader import load_json
|
|
31
29
|
from hdx.utilities.saver import save_iterable, save_json
|
|
32
30
|
from hdx.utilities.uuid import is_valid_uuid
|
|
@@ -202,7 +200,7 @@ class Dataset(HDXObject):
|
|
|
202
200
|
session: Session | None = None,
|
|
203
201
|
) -> None:
|
|
204
202
|
"""Save dataset to JSON. If follow_urls is True, resource urls that point to
|
|
205
|
-
datasets
|
|
203
|
+
datasets are followed to retrieve final urls.
|
|
206
204
|
|
|
207
205
|
Args:
|
|
208
206
|
path: Path to save dataset
|
|
@@ -396,35 +394,6 @@ class Dataset(HDXObject):
|
|
|
396
394
|
"""
|
|
397
395
|
return len(self._resources)
|
|
398
396
|
|
|
399
|
-
def reorder_resources(
|
|
400
|
-
self, resource_ids: Sequence[str], hxl_update: bool = True
|
|
401
|
-
) -> None:
|
|
402
|
-
"""Reorder resources in dataset according to provided list. Resources are
|
|
403
|
-
updated in the dataset object to match new order. However, the dataset is not
|
|
404
|
-
refreshed by rereading from HDX. If only some resource ids are supplied then
|
|
405
|
-
these are assumed to be first and the other resources will stay in their
|
|
406
|
-
original order.
|
|
407
|
-
|
|
408
|
-
Args:
|
|
409
|
-
resource_ids: List of resource ids
|
|
410
|
-
|
|
411
|
-
Returns:
|
|
412
|
-
None
|
|
413
|
-
"""
|
|
414
|
-
dataset_id = self.data.get("id")
|
|
415
|
-
if not dataset_id:
|
|
416
|
-
raise HDXError(
|
|
417
|
-
"Dataset has no id! It must be read, created or updated first."
|
|
418
|
-
)
|
|
419
|
-
data = {"id": dataset_id, "order": resource_ids}
|
|
420
|
-
results = self._write_to_hdx("reorder", data)
|
|
421
|
-
ordered_ids = results["order"]
|
|
422
|
-
reordered_resources = []
|
|
423
|
-
for resource_id in ordered_ids:
|
|
424
|
-
resource = next(x for x in self._resources if x["id"] == resource_id)
|
|
425
|
-
reordered_resources.append(resource)
|
|
426
|
-
self._resources = reordered_resources
|
|
427
|
-
|
|
428
397
|
def move_resource(
|
|
429
398
|
self,
|
|
430
399
|
resource_name: str,
|
|
@@ -518,6 +487,33 @@ class Dataset(HDXObject):
|
|
|
518
487
|
self.init_resources()
|
|
519
488
|
self.separate_resources()
|
|
520
489
|
|
|
490
|
+
def reorder_resources(self, resource_ids: Sequence[str]) -> None:
|
|
491
|
+
"""Reorder resources in dataset according to provided list. Resources are
|
|
492
|
+
updated in the dataset object to match new order. However, the dataset is not
|
|
493
|
+
refreshed by rereading from HDX. If only some resource ids are supplied then
|
|
494
|
+
these are assumed to be first and the other resources will stay in their
|
|
495
|
+
original order.
|
|
496
|
+
|
|
497
|
+
Args:
|
|
498
|
+
resource_ids: List of resource ids
|
|
499
|
+
|
|
500
|
+
Returns:
|
|
501
|
+
None
|
|
502
|
+
"""
|
|
503
|
+
dataset_id = self.data.get("id")
|
|
504
|
+
if not dataset_id:
|
|
505
|
+
raise HDXError(
|
|
506
|
+
"Dataset has no id! It must be read, created or updated first."
|
|
507
|
+
)
|
|
508
|
+
data = {"id": dataset_id, "order": resource_ids}
|
|
509
|
+
results = self._write_to_hdx("reorder", data)
|
|
510
|
+
ordered_ids = results["order"]
|
|
511
|
+
reordered_resources = []
|
|
512
|
+
for resource_id in ordered_ids:
|
|
513
|
+
resource = next(x for x in self._resources if x["id"] == resource_id)
|
|
514
|
+
reordered_resources.append(resource)
|
|
515
|
+
self._resources = reordered_resources
|
|
516
|
+
|
|
521
517
|
def _dataset_load_from_hdx(self, id_or_name: str) -> bool:
|
|
522
518
|
"""Loads the dataset given by either id or name from HDX
|
|
523
519
|
|
|
@@ -1079,7 +1075,6 @@ class Dataset(HDXObject):
|
|
|
1079
1075
|
remove_additional_resources: bool = False,
|
|
1080
1076
|
match_resource_order: bool = False,
|
|
1081
1077
|
create_default_views: bool = True,
|
|
1082
|
-
hxl_update: bool = True,
|
|
1083
1078
|
**kwargs: Any,
|
|
1084
1079
|
) -> dict:
|
|
1085
1080
|
"""Check if dataset exists in HDX and if so, update it. match_resources_by_metadata uses ids if they are
|
|
@@ -1145,7 +1140,6 @@ class Dataset(HDXObject):
|
|
|
1145
1140
|
remove_additional_resources: bool = False,
|
|
1146
1141
|
match_resource_order: bool = False,
|
|
1147
1142
|
create_default_views: bool = True,
|
|
1148
|
-
hxl_update: bool = True,
|
|
1149
1143
|
**kwargs: Any,
|
|
1150
1144
|
) -> dict:
|
|
1151
1145
|
"""Check if dataset exists in HDX and if so, update it, otherwise create it. match_resources_by_metadata uses
|
|
@@ -1474,17 +1468,6 @@ class Dataset(HDXObject):
|
|
|
1474
1468
|
self.data.get("dataset_date"), date_format, today
|
|
1475
1469
|
)
|
|
1476
1470
|
|
|
1477
|
-
def get_reference_period(
|
|
1478
|
-
self,
|
|
1479
|
-
date_format: str | None = None,
|
|
1480
|
-
today: datetime = now_utc(),
|
|
1481
|
-
) -> dict:
|
|
1482
|
-
warnings.warn(
|
|
1483
|
-
"get_reference_period() is deprecated, use get_time_period() instead",
|
|
1484
|
-
DeprecationWarning,
|
|
1485
|
-
)
|
|
1486
|
-
return self.get_time_period(date_format, today)
|
|
1487
|
-
|
|
1488
1471
|
def set_time_period(
|
|
1489
1472
|
self,
|
|
1490
1473
|
startdate: datetime | str,
|
|
@@ -1511,19 +1494,6 @@ class Dataset(HDXObject):
|
|
|
1511
1494
|
startdate, enddate, ongoing, ignore_timeinfo
|
|
1512
1495
|
)
|
|
1513
1496
|
|
|
1514
|
-
def set_reference_period(
|
|
1515
|
-
self,
|
|
1516
|
-
startdate: datetime | str,
|
|
1517
|
-
enddate: datetime | str | None = None,
|
|
1518
|
-
ongoing: bool = False,
|
|
1519
|
-
ignore_timeinfo: bool = True,
|
|
1520
|
-
) -> None:
|
|
1521
|
-
warnings.warn(
|
|
1522
|
-
"set_reference_period() is deprecated, use set_time_period() instead",
|
|
1523
|
-
DeprecationWarning,
|
|
1524
|
-
)
|
|
1525
|
-
self.set_time_period(startdate, enddate, ongoing, ignore_timeinfo)
|
|
1526
|
-
|
|
1527
1497
|
def set_time_period_year_range(
|
|
1528
1498
|
self,
|
|
1529
1499
|
dataset_year: str | int | Iterable,
|
|
@@ -1544,17 +1514,6 @@ class Dataset(HDXObject):
|
|
|
1544
1514
|
) = DateHelper.get_hdx_time_period_from_years(dataset_year, dataset_end_year)
|
|
1545
1515
|
return retval
|
|
1546
1516
|
|
|
1547
|
-
def set_reference_period_year_range(
|
|
1548
|
-
self,
|
|
1549
|
-
dataset_year: str | int | Iterable,
|
|
1550
|
-
dataset_end_year: str | int | None = None,
|
|
1551
|
-
) -> list[int]:
|
|
1552
|
-
warnings.warn(
|
|
1553
|
-
"set_reference_period_year_range() is deprecated, use set_time_period_year_range() instead",
|
|
1554
|
-
DeprecationWarning,
|
|
1555
|
-
)
|
|
1556
|
-
return self.set_time_period_year_range(dataset_year, dataset_end_year)
|
|
1557
|
-
|
|
1558
1517
|
@classmethod
|
|
1559
1518
|
def list_valid_update_frequencies(cls) -> list[str]:
|
|
1560
1519
|
"""List of valid update frequency values
|
|
@@ -2265,15 +2224,6 @@ class Dataset(HDXObject):
|
|
|
2265
2224
|
dataset_resource.disable_dataset_preview()
|
|
2266
2225
|
return preview_resource
|
|
2267
2226
|
|
|
2268
|
-
def set_quickchart_resource(
|
|
2269
|
-
self, resource: Union["Resource", dict, str, int]
|
|
2270
|
-
) -> "Resource":
|
|
2271
|
-
warnings.warn(
|
|
2272
|
-
"set_quickchart_resource() is deprecated, use set_preview_resource() instead",
|
|
2273
|
-
DeprecationWarning,
|
|
2274
|
-
)
|
|
2275
|
-
return self.set_preview_resource(resource)
|
|
2276
|
-
|
|
2277
2227
|
def create_default_views(self, create_datastore_views: bool = False) -> None:
|
|
2278
2228
|
"""Create default resource views for all resources in dataset
|
|
2279
2229
|
|
|
@@ -2304,28 +2254,6 @@ class Dataset(HDXObject):
|
|
|
2304
2254
|
self._preview_resourceview = None
|
|
2305
2255
|
break
|
|
2306
2256
|
|
|
2307
|
-
def generate_quickcharts(
|
|
2308
|
-
self,
|
|
2309
|
-
resource: Union["Resource", dict, str, int] = 0,
|
|
2310
|
-
path: Path | str | None = None,
|
|
2311
|
-
bites_disabled: Sequence[bool] | None = None,
|
|
2312
|
-
indicators: Sequence[dict] | None = None,
|
|
2313
|
-
findreplace: dict | None = None,
|
|
2314
|
-
) -> None:
|
|
2315
|
-
"""To be removed
|
|
2316
|
-
|
|
2317
|
-
Args:
|
|
2318
|
-
resource: Either resource id or name, resource metadata from a Resource object or a dictionary or position. Defaults to 0.
|
|
2319
|
-
path: Path to YAML resource view metadata. Defaults to None (config/hdx_resource_view_static.yaml or internal template).
|
|
2320
|
-
bites_disabled: Which QC bites should be disabled. Defaults to None (all bites enabled).
|
|
2321
|
-
indicators: Indicator codes, QC titles and units for resource view template. Defaults to None (don't use template).
|
|
2322
|
-
findreplace: Replacements for anything else in resource view. Defaults to None.
|
|
2323
|
-
|
|
2324
|
-
Returns:
|
|
2325
|
-
None
|
|
2326
|
-
"""
|
|
2327
|
-
return None
|
|
2328
|
-
|
|
2329
2257
|
def get_name_or_id(self, prefer_name: bool = True) -> str | None:
|
|
2330
2258
|
"""Get dataset name or id eg. for use in urls. If prefer_name is True,
|
|
2331
2259
|
name is preferred over id if available, otherwise id is preferred over
|
|
@@ -2513,193 +2441,6 @@ class Dataset(HDXObject):
|
|
|
2513
2441
|
retdict["rows"] = rows
|
|
2514
2442
|
return True, retdict
|
|
2515
2443
|
|
|
2516
|
-
def generate_resource_from_rows(
|
|
2517
|
-
self,
|
|
2518
|
-
folder: Path | str,
|
|
2519
|
-
filename: str,
|
|
2520
|
-
rows: Iterable[Sequence | Mapping],
|
|
2521
|
-
resourcedata: dict,
|
|
2522
|
-
headers: Sequence[str] | None = None,
|
|
2523
|
-
encoding: str | None = None,
|
|
2524
|
-
) -> Optional["Resource"]:
|
|
2525
|
-
"""Write rows to csv and create resource, adding it to the dataset.
|
|
2526
|
-
The headers argument is either a row number (rows start counting at
|
|
2527
|
-
1), or the actual headers defined as a list of strings. If not set, all
|
|
2528
|
-
rows will be treated as containing values.
|
|
2529
|
-
|
|
2530
|
-
Args:
|
|
2531
|
-
folder: Folder to which to write file containing rows
|
|
2532
|
-
filename: Filename of file to write rows
|
|
2533
|
-
rows: List of rows in dict or list form
|
|
2534
|
-
resourcedata: Resource data
|
|
2535
|
-
headers: List of headers. Defaults to None.
|
|
2536
|
-
encoding: Encoding to use. Defaults to None (infer encoding).
|
|
2537
|
-
|
|
2538
|
-
Returns:
|
|
2539
|
-
The created resource or None if not created
|
|
2540
|
-
"""
|
|
2541
|
-
warnings.warn(
|
|
2542
|
-
"generate_resource_from_rows() is deprecated, use generate_resource() instead",
|
|
2543
|
-
DeprecationWarning,
|
|
2544
|
-
)
|
|
2545
|
-
res, retdict = self.generate_resource(
|
|
2546
|
-
folder, filename, rows, resourcedata, headers, headers, "csv", encoding
|
|
2547
|
-
)
|
|
2548
|
-
return retdict["resource"] if res else None
|
|
2549
|
-
|
|
2550
|
-
def generate_resource_from_iterable(
|
|
2551
|
-
self,
|
|
2552
|
-
headers: Sequence[str],
|
|
2553
|
-
iterable: Iterable[Sequence | dict],
|
|
2554
|
-
hxltags: dict[str, str],
|
|
2555
|
-
folder: Path | str,
|
|
2556
|
-
filename: str,
|
|
2557
|
-
resourcedata: dict,
|
|
2558
|
-
datecol: int | str | None = None,
|
|
2559
|
-
yearcol: int | str | None = None,
|
|
2560
|
-
date_function: Callable[[dict], dict | None] | None = None,
|
|
2561
|
-
quickcharts: dict | None = None,
|
|
2562
|
-
encoding: str | None = None,
|
|
2563
|
-
) -> tuple[bool, dict]:
|
|
2564
|
-
"""Given headers and an iterable, write rows to csv and create
|
|
2565
|
-
resource, adding to it the dataset. The returned dictionary will
|
|
2566
|
-
contain the resource in the key resource, headers in the key headers
|
|
2567
|
-
and list of rows in the key rows.
|
|
2568
|
-
|
|
2569
|
-
The time period can optionally be set by supplying a column in
|
|
2570
|
-
which the date or year is to be looked up. Note that any timezone
|
|
2571
|
-
information is ignored and UTC assumed. Alternatively, a function can
|
|
2572
|
-
be supplied to handle any dates in a row. It should accept a row and
|
|
2573
|
-
should return None to ignore the row or a dictionary which can either
|
|
2574
|
-
be empty if there are no dates in the row or can be populated with
|
|
2575
|
-
keys startdate and/or enddate which are of type timezone-aware
|
|
2576
|
-
datetime. The lowest start date and highest end date are used to set
|
|
2577
|
-
the time period and are returned in the results dictionary in keys
|
|
2578
|
-
startdate and enddate.
|
|
2579
|
-
|
|
2580
|
-
Args:
|
|
2581
|
-
headers: Headers
|
|
2582
|
-
iterable: Iterable returning rows
|
|
2583
|
-
hxltags: Header to HXL hashtag mapping
|
|
2584
|
-
folder: Folder to which to write file containing rows
|
|
2585
|
-
filename: Filename of file to write rows
|
|
2586
|
-
resourcedata: Resource data
|
|
2587
|
-
datecol: Date column for setting time period. Defaults to None (don't set).
|
|
2588
|
-
yearcol: Year column for setting dataset year range. Defaults to None (don't set).
|
|
2589
|
-
date_function: Date function to call for each row. Defaults to None.
|
|
2590
|
-
encoding: Encoding to use. Defaults to None (infer encoding).
|
|
2591
|
-
|
|
2592
|
-
Returns:
|
|
2593
|
-
(True if resource added, dictionary of results)
|
|
2594
|
-
"""
|
|
2595
|
-
warnings.warn(
|
|
2596
|
-
"generate_resource_from_iterable() is deprecated, use generate_resource() instead",
|
|
2597
|
-
DeprecationWarning,
|
|
2598
|
-
)
|
|
2599
|
-
if [datecol, yearcol, date_function].count(None) < 2:
|
|
2600
|
-
raise HDXError("Supply one of datecol, yearcol or date_function!")
|
|
2601
|
-
retdict = {}
|
|
2602
|
-
if headers is None:
|
|
2603
|
-
return False, retdict
|
|
2604
|
-
rows = [Download.hxl_row(headers, hxltags, dict_form=True)]
|
|
2605
|
-
dates = [default_enddate, default_date]
|
|
2606
|
-
if yearcol is not None:
|
|
2607
|
-
|
|
2608
|
-
def yearcol_function(row):
|
|
2609
|
-
result = {}
|
|
2610
|
-
year = row[yearcol]
|
|
2611
|
-
if year:
|
|
2612
|
-
result["startdate"], result["enddate"] = parse_date_range(
|
|
2613
|
-
year,
|
|
2614
|
-
zero_time=True,
|
|
2615
|
-
max_endtime=True,
|
|
2616
|
-
)
|
|
2617
|
-
return result
|
|
2618
|
-
|
|
2619
|
-
date_function = yearcol_function
|
|
2620
|
-
elif datecol is not None:
|
|
2621
|
-
|
|
2622
|
-
def datecol_function(row):
|
|
2623
|
-
result = {}
|
|
2624
|
-
date = row[datecol]
|
|
2625
|
-
if date:
|
|
2626
|
-
date = parse_date(date)
|
|
2627
|
-
result["startdate"] = date
|
|
2628
|
-
result["enddate"] = date
|
|
2629
|
-
return result
|
|
2630
|
-
|
|
2631
|
-
date_function = datecol_function
|
|
2632
|
-
|
|
2633
|
-
for row in iterable:
|
|
2634
|
-
if date_function is not None:
|
|
2635
|
-
result = date_function(row)
|
|
2636
|
-
if result is None:
|
|
2637
|
-
continue
|
|
2638
|
-
startdate = result.get("startdate")
|
|
2639
|
-
if startdate is not None:
|
|
2640
|
-
if startdate < dates[0]:
|
|
2641
|
-
dates[0] = startdate
|
|
2642
|
-
enddate = result.get("enddate")
|
|
2643
|
-
if enddate is not None:
|
|
2644
|
-
if enddate > dates[1]:
|
|
2645
|
-
dates[1] = enddate
|
|
2646
|
-
rows.append(row)
|
|
2647
|
-
if len(rows) == 1:
|
|
2648
|
-
logger.error(f"No data rows in {filename}!")
|
|
2649
|
-
return False, retdict
|
|
2650
|
-
if yearcol is not None or date_function is not None:
|
|
2651
|
-
if dates[0] == default_enddate or dates[1] == default_date:
|
|
2652
|
-
logger.error(f"No dates in {filename}!")
|
|
2653
|
-
return False, retdict
|
|
2654
|
-
else:
|
|
2655
|
-
retdict["startdate"] = dates[0]
|
|
2656
|
-
retdict["enddate"] = dates[1]
|
|
2657
|
-
self.set_time_period(dates[0], dates[1])
|
|
2658
|
-
resource = self.generate_resource_from_rows(
|
|
2659
|
-
folder,
|
|
2660
|
-
filename,
|
|
2661
|
-
rows,
|
|
2662
|
-
resourcedata,
|
|
2663
|
-
headers=headers,
|
|
2664
|
-
encoding=encoding,
|
|
2665
|
-
)
|
|
2666
|
-
retdict["resource"] = resource
|
|
2667
|
-
retdict["headers"] = headers
|
|
2668
|
-
retdict["rows"] = rows
|
|
2669
|
-
return True, retdict
|
|
2670
|
-
|
|
2671
|
-
def generate_resource_from_iterator(
|
|
2672
|
-
self,
|
|
2673
|
-
headers: Sequence[str],
|
|
2674
|
-
iterator: Iterator[Sequence | dict],
|
|
2675
|
-
hxltags: dict[str, str],
|
|
2676
|
-
folder: Path | str,
|
|
2677
|
-
filename: str,
|
|
2678
|
-
resourcedata: dict,
|
|
2679
|
-
datecol: int | str | None = None,
|
|
2680
|
-
yearcol: int | str | None = None,
|
|
2681
|
-
date_function: Callable[[dict], dict | None] | None = None,
|
|
2682
|
-
quickcharts: dict | None = None,
|
|
2683
|
-
encoding: str | None = None,
|
|
2684
|
-
) -> tuple[bool, dict]:
|
|
2685
|
-
warnings.warn(
|
|
2686
|
-
"generate_resource_from_iterator() is deprecated, use generate_resource() instead",
|
|
2687
|
-
DeprecationWarning,
|
|
2688
|
-
)
|
|
2689
|
-
return self.generate_resource_from_iterable(
|
|
2690
|
-
headers,
|
|
2691
|
-
iterator,
|
|
2692
|
-
hxltags,
|
|
2693
|
-
folder,
|
|
2694
|
-
filename,
|
|
2695
|
-
resourcedata,
|
|
2696
|
-
datecol,
|
|
2697
|
-
yearcol,
|
|
2698
|
-
date_function,
|
|
2699
|
-
quickcharts,
|
|
2700
|
-
encoding,
|
|
2701
|
-
)
|
|
2702
|
-
|
|
2703
2444
|
def download_generate_resource(
|
|
2704
2445
|
self,
|
|
2705
2446
|
downloader: BaseDownload,
|
|
@@ -2745,7 +2486,6 @@ class Dataset(HDXObject):
|
|
|
2745
2486
|
Args:
|
|
2746
2487
|
downloader: A Download or Retrieve object
|
|
2747
2488
|
url: URL to download
|
|
2748
|
-
hxltags: Header to HXL hashtag mapping
|
|
2749
2489
|
folder: Folder to which to write file containing rows
|
|
2750
2490
|
filename: Filename of file to write rows
|
|
2751
2491
|
resourcedata: Resource data
|
|
@@ -2786,89 +2526,6 @@ class Dataset(HDXObject):
|
|
|
2786
2526
|
no_empty=no_empty,
|
|
2787
2527
|
)
|
|
2788
2528
|
|
|
2789
|
-
def download_and_generate_resource(
|
|
2790
|
-
self,
|
|
2791
|
-
downloader: BaseDownload,
|
|
2792
|
-
url: str,
|
|
2793
|
-
hxltags: dict[str, str],
|
|
2794
|
-
folder: Path | str,
|
|
2795
|
-
filename: str,
|
|
2796
|
-
resourcedata: dict,
|
|
2797
|
-
header_insertions: Sequence[tuple[int, str]] | None = None,
|
|
2798
|
-
row_function: Callable[[list[str], dict], dict] | None = None,
|
|
2799
|
-
datecol: str | None = None,
|
|
2800
|
-
yearcol: str | None = None,
|
|
2801
|
-
date_function: Callable[[dict], dict | None] | None = None,
|
|
2802
|
-
quickcharts: dict | None = None,
|
|
2803
|
-
**kwargs: Any,
|
|
2804
|
-
) -> tuple[bool, dict]:
|
|
2805
|
-
"""Download url, write rows to csv and create resource, adding to it
|
|
2806
|
-
the dataset. The returned dictionary will contain the resource in the
|
|
2807
|
-
key resource, headers in the key headers and list of rows in the key
|
|
2808
|
-
rows.
|
|
2809
|
-
|
|
2810
|
-
Optionally, headers can be inserted at specific positions. This is
|
|
2811
|
-
achieved using the header_insertions argument. If supplied, it is a
|
|
2812
|
-
list of tuples of the form (position, header) to be inserted. A
|
|
2813
|
-
function is called for each row. If supplied, it takes as arguments:
|
|
2814
|
-
headers (prior to any insertions) and row (which will be in dict or
|
|
2815
|
-
list form depending upon the dict_rows argument) and outputs a modified
|
|
2816
|
-
row.
|
|
2817
|
-
|
|
2818
|
-
The time period can optionally be set by supplying a column in
|
|
2819
|
-
which the date or year is to be looked up. Note that any timezone
|
|
2820
|
-
information is ignored and UTC assumed. Alternatively, a function can
|
|
2821
|
-
be supplied to handle any dates in a row. It should accept a row and
|
|
2822
|
-
should return None to ignore the row or a dictionary which can either
|
|
2823
|
-
be empty if there are no dates in the row or can be populated with
|
|
2824
|
-
keys startdate and/or enddate which are of type timezone-aware
|
|
2825
|
-
datetime. The lowest start date and highest end date are used to set
|
|
2826
|
-
the time period and are returned in the results dictionary in keys
|
|
2827
|
-
startdate and enddate.
|
|
2828
|
-
|
|
2829
|
-
Args:
|
|
2830
|
-
downloader: A Download or Retrieve object
|
|
2831
|
-
url: URL to download
|
|
2832
|
-
hxltags: Header to HXL hashtag mapping
|
|
2833
|
-
folder: Folder to which to write file containing rows
|
|
2834
|
-
filename: Filename of file to write rows
|
|
2835
|
-
resourcedata: Resource data
|
|
2836
|
-
header_insertions: List of (position, header) to insert. Defaults to None.
|
|
2837
|
-
row_function: Function to call for each row. Defaults to None.
|
|
2838
|
-
datecol: Date column for setting time period. Defaults to None (don't set).
|
|
2839
|
-
yearcol: Year column for setting dataset year range. Defaults to None (don't set).
|
|
2840
|
-
date_function: Date function to call for each row. Defaults to None.
|
|
2841
|
-
**kwargs: Any additional args to pass to downloader.get_tabular_rows
|
|
2842
|
-
|
|
2843
|
-
Returns:
|
|
2844
|
-
(True if resource added, dictionary of results)
|
|
2845
|
-
"""
|
|
2846
|
-
warnings.warn(
|
|
2847
|
-
"download_and_generate_resource() is deprecated, use download_generate_resource() instead",
|
|
2848
|
-
DeprecationWarning,
|
|
2849
|
-
)
|
|
2850
|
-
headers, iterator = downloader.get_tabular_rows(
|
|
2851
|
-
url,
|
|
2852
|
-
dict_form=True,
|
|
2853
|
-
header_insertions=header_insertions,
|
|
2854
|
-
row_function=row_function,
|
|
2855
|
-
format="csv",
|
|
2856
|
-
**kwargs,
|
|
2857
|
-
)
|
|
2858
|
-
return self.generate_resource_from_iterable(
|
|
2859
|
-
headers,
|
|
2860
|
-
iterator,
|
|
2861
|
-
hxltags,
|
|
2862
|
-
folder,
|
|
2863
|
-
filename,
|
|
2864
|
-
resourcedata,
|
|
2865
|
-
datecol=datecol,
|
|
2866
|
-
yearcol=yearcol,
|
|
2867
|
-
date_function=date_function,
|
|
2868
|
-
quickcharts=quickcharts,
|
|
2869
|
-
encoding=kwargs.get("encoding", None),
|
|
2870
|
-
)
|
|
2871
|
-
|
|
2872
2529
|
def add_hapi_error(
|
|
2873
2530
|
self,
|
|
2874
2531
|
error_message: str,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"""Resource class containing all logic for creating, checking, and updating resources."""
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
|
-
import warnings
|
|
5
4
|
from collections.abc import Sequence
|
|
6
5
|
from datetime import datetime
|
|
7
6
|
from pathlib import Path
|
|
@@ -244,13 +243,6 @@ class Resource(HDXObject):
|
|
|
244
243
|
file_format = file_format.lower()
|
|
245
244
|
return file_format
|
|
246
245
|
|
|
247
|
-
def get_file_type(self) -> str | None:
|
|
248
|
-
warnings.warn(
|
|
249
|
-
"get_file_type() is deprecated, use get_format() instead",
|
|
250
|
-
DeprecationWarning,
|
|
251
|
-
)
|
|
252
|
-
return self.get_format()
|
|
253
|
-
|
|
254
246
|
def set_format(self, format: str) -> str:
|
|
255
247
|
"""Set the resource's file type
|
|
256
248
|
|
|
@@ -268,13 +260,6 @@ class Resource(HDXObject):
|
|
|
268
260
|
self.data["format"] = file_format
|
|
269
261
|
return file_format
|
|
270
262
|
|
|
271
|
-
def set_file_type(self, file_type: str) -> str:
|
|
272
|
-
warnings.warn(
|
|
273
|
-
"set_file_type() is deprecated, use set_format() instead",
|
|
274
|
-
DeprecationWarning,
|
|
275
|
-
)
|
|
276
|
-
return self.set_format(file_type)
|
|
277
|
-
|
|
278
263
|
def clean_format(self) -> str:
|
|
279
264
|
"""Clean the resource's format, setting it to None if it is invalid and
|
|
280
265
|
cannot be mapped
|
|
@@ -284,13 +269,6 @@ class Resource(HDXObject):
|
|
|
284
269
|
"""
|
|
285
270
|
return self.set_format(self.data.get("format"))
|
|
286
271
|
|
|
287
|
-
def clean_file_type(self) -> str:
|
|
288
|
-
warnings.warn(
|
|
289
|
-
"clean_file_type() is deprecated, use clean_format() instead",
|
|
290
|
-
DeprecationWarning,
|
|
291
|
-
)
|
|
292
|
-
return self.set_format(self.data.get("format"))
|
|
293
|
-
|
|
294
272
|
def get_file_to_upload(self) -> str | None:
|
|
295
273
|
"""Get the file uploaded
|
|
296
274
|
|