hdx-python-api 6.6.5__tar.gz → 6.6.7__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.
Files changed (150) hide show
  1. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/PKG-INFO +3 -3
  2. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/documentation/index.md +0 -33
  3. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/pyproject.toml +2 -2
  4. hdx_python_api-6.6.7/src/hdx/api/_version.py +24 -0
  5. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/data/dataset.py +29 -372
  6. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/data/organization.py +50 -1
  7. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/data/resource.py +0 -22
  8. hdx_python_api-6.6.7/tests/fixtures/config/hdx_resource_view_static.yaml +3 -0
  9. hdx_python_api-6.6.7/tests/fixtures/organization/organization_list_all_fields.yaml +389 -0
  10. hdx_python_api-6.6.7/tests/fixtures/update_dataset_resources/expected_resources_to_update.json +83 -0
  11. hdx_python_api-6.6.7/tests/fixtures/update_dataset_resources/unesco_dataset.json +326 -0
  12. hdx_python_api-6.6.7/tests/fixtures/update_dataset_resources/unesco_update_dataset.json +106 -0
  13. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/update_logic/update_logic_resources.yaml +0 -3
  14. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/update_logic/update_logic_resources_new.yaml +0 -3
  15. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/api/test_ckan.py +2 -2
  16. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/data/test_dataset_core.py +6 -6
  17. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/data/test_dataset_noncore.py +3 -3
  18. hdx_python_api-6.6.7/tests/hdx/data/test_dataset_resource_generation.py +518 -0
  19. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/data/test_organization.py +33 -1
  20. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/data/test_resource.py +2 -2
  21. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/data/test_resource_view.py +15 -20
  22. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/data/test_update_dataset_resources.py +8 -34
  23. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/data/test_update_logic.py +4 -36
  24. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/data/test_user.py +3 -1
  25. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/data/test_vocabulary.py +0 -6
  26. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/uv.lock +8 -87
  27. hdx_python_api-6.6.5/src/hdx/api/_version.py +0 -34
  28. hdx_python_api-6.6.5/src/hdx/data/hdx_datasource_topline.yaml +0 -30
  29. hdx_python_api-6.6.5/src/hdx/data/indicator_resource_view_template.yaml +0 -4
  30. hdx_python_api-6.6.5/tests/fixtures/config/hdx_resource_view_static.yaml +0 -4
  31. hdx_python_api-6.6.5/tests/fixtures/update_dataset_resources/expected_resources_to_update.json +0 -85
  32. hdx_python_api-6.6.5/tests/fixtures/update_dataset_resources/unesco_dataset.json +0 -1
  33. hdx_python_api-6.6.5/tests/fixtures/update_dataset_resources/unesco_update_dataset.json +0 -1
  34. hdx_python_api-6.6.5/tests/hdx/data/test_dataset_resource_generation.py +0 -1088
  35. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/.github/workflows/publish.yaml +0 -0
  36. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/.github/workflows/run-python-tests.yaml +0 -0
  37. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/.gitignore +0 -0
  38. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/.pre-commit-config.yaml +0 -0
  39. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/LICENSE +0 -0
  40. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/README.md +0 -0
  41. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/documentation/.readthedocs.yaml +0 -0
  42. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/documentation/mkdocs.yaml +0 -0
  43. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/api/__init__.py +0 -0
  44. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/api/configuration.py +0 -0
  45. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/api/hdx_base_configuration.yaml +0 -0
  46. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/api/locations.py +0 -0
  47. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/api/remotehdx.py +0 -0
  48. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/api/utilities/__init__.py +0 -0
  49. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/api/utilities/date_helper.py +0 -0
  50. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/api/utilities/filestore_helper.py +0 -0
  51. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/api/utilities/hdx_error_handler.py +0 -0
  52. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/api/utilities/hdx_state.py +0 -0
  53. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/api/utilities/url_utils.py +0 -0
  54. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/data/__init__.py +0 -0
  55. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/data/hdxobject.py +0 -0
  56. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/data/resource_matcher.py +0 -0
  57. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/data/resource_view.py +0 -0
  58. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/data/showcase.py +0 -0
  59. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/data/user.py +0 -0
  60. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/data/vocabulary.py +0 -0
  61. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/facades/__init__.py +0 -0
  62. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/facades/infer_arguments.py +0 -0
  63. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/facades/keyword_arguments.py +0 -0
  64. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/src/hdx/facades/simple.py +0 -0
  65. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/__init__.py +0 -0
  66. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/Accepted_Tags.csv +0 -0
  67. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/CKAN/hdx_dataset_static.yaml +0 -0
  68. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/Tag_Mapping.csv +0 -0
  69. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/Tag_Mapping_ChainRuleError.csv +0 -0
  70. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/empty.yaml +0 -0
  71. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/hdx_base_config.json +0 -0
  72. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/hdx_base_config.yaml +0 -0
  73. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/hdx_config.json +0 -0
  74. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/hdx_config.yaml +0 -0
  75. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/hdx_dataset_static.json +0 -0
  76. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/hdx_dataset_static.yaml +0 -0
  77. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/hdx_datasource_topline.json +0 -0
  78. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/hdx_datasource_topline.yaml +0 -0
  79. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/hdx_email_configuration.json +0 -0
  80. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/hdx_email_configuration.yaml +0 -0
  81. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/hdx_missing_site_config.json +0 -0
  82. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/hdx_organization_static.json +0 -0
  83. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/hdx_organization_static.yaml +0 -0
  84. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/hdx_resource_static.json +0 -0
  85. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/hdx_resource_static.yaml +0 -0
  86. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/hdx_resource_view_static.json +0 -0
  87. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/hdx_showcase_static.json +0 -0
  88. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/hdx_showcase_static.yaml +0 -0
  89. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/hdx_user_static.json +0 -0
  90. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/hdx_user_static.yaml +0 -0
  91. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/hdx_vocabulary_static.json +0 -0
  92. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/hdx_vocabulary_static.yaml +0 -0
  93. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/project_configuration.json +0 -0
  94. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/project_configuration.yaml +0 -0
  95. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/user_agent_config.yaml +0 -0
  96. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/user_agent_config2.yaml +0 -0
  97. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/user_agent_config3.yaml +0 -0
  98. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/config/user_agent_config_wrong.yaml +0 -0
  99. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/dataset_search_results.yaml +0 -0
  100. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/download_gen_resource/conflict_data_alg.csv +0 -0
  101. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/download_gen_resource/min_qc_conflict_data_alg.csv +0 -0
  102. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/download_gen_resource/qc_conflict_data_alg.csv +0 -0
  103. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/download_gen_resource/test_data_no_data.csv +0 -0
  104. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/download_gen_resource/test_data_no_years.csv +0 -0
  105. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/empty.csv +0 -0
  106. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/gen_resource/conflict_data_alg.csv +0 -0
  107. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/gen_resource/min_qc_conflict_data_alg.csv +0 -0
  108. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/gen_resource/qc_conflict_data_alg.csv +0 -0
  109. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/gen_resource/test_data_no_data.csv +0 -0
  110. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/gen_resource/test_data_no_years.csv +0 -0
  111. {hdx_python_api-6.6.5/tests/fixtures → hdx_python_api-6.6.7/tests/fixtures/organization}/organization_show_results.yaml +0 -0
  112. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/qc_from_rows/qc_conflict_data_alg.csv +0 -0
  113. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/qc_from_rows/qc_conflict_data_alg_one_col.csv +0 -0
  114. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/resource_formats.json +0 -0
  115. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/showcase_all_search_results.yaml +0 -0
  116. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/size_hash/ACLED-All-Africa-File_20170101-to-20170708.xlsx +0 -0
  117. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/state/analysis_dates.txt +0 -0
  118. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/state/last_build_date.txt +0 -0
  119. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/test_data.csv +0 -0
  120. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/test_data.zip +0 -0
  121. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/update_dataset_resources/dem_data_zwe.csv +0 -0
  122. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/update_dataset_resources/dem_indicatorlist_zwe.csv +0 -0
  123. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/update_dataset_resources/opri_data_zwe.csv +0 -0
  124. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/update_dataset_resources/opri_indicatorlist_zwe.csv +0 -0
  125. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/update_dataset_resources/opri_metadata_zwe.csv +0 -0
  126. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/update_dataset_resources/qc_sdg_data_zwe.csv +0 -0
  127. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/update_dataset_resources/sdg_data_zwe.csv +0 -0
  128. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/update_dataset_resources/sdg_indicatorlist_zwe.csv +0 -0
  129. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/fixtures/update_dataset_resources/sdg_metadata_zwe.csv +0 -0
  130. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/__init__.py +0 -0
  131. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/api/__init__.py +0 -0
  132. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/api/test_configuration.py +0 -0
  133. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/api/test_locations.py +0 -0
  134. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/api/utilities/__init__.py +0 -0
  135. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/api/utilities/test_filestore_helper.py +0 -0
  136. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/api/utilities/test_hdx_error_handler.py +0 -0
  137. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/api/utilities/test_hdx_state.py +0 -0
  138. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/api/utilities/test_url_utils.py +0 -0
  139. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/conftest.py +0 -0
  140. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/data/__init__.py +0 -0
  141. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/data/test_dataset_add_hapi_error.py +0 -0
  142. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/data/test_showcase.py +0 -0
  143. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/facades/__init__.py +0 -0
  144. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/facades/test_infer_arguments.py +0 -0
  145. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/facades/test_keyword_arguments.py +0 -0
  146. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/tests/hdx/facades/test_simple.py +0 -0
  147. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/workingexample/my_code.py +0 -0
  148. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/workingexample/my_resource.csv +0 -0
  149. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/workingexample/my_resource.xlsx +0 -0
  150. {hdx_python_api-6.6.5 → hdx_python_api-6.6.7}/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.5
3
+ Version: 6.6.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
@@ -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.0.1
32
- Requires-Dist: hdx-python-utilities>=4.0.4
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
@@ -29,7 +29,6 @@ upload your datasets to HDX.
29
29
  - [Organization](#organization)
30
30
  - [Custom Visualization](#custom-visualization)
31
31
  - [Resource Generation](#resource-generation)
32
- - [QuickCharts Generation](#quickcharts-generation)
33
32
  - [Resource Specific Operations](#resource-specific-operations)
34
33
  - [Showcase Management](#showcase-management)
35
34
  - [User Management](#user-management)
@@ -871,38 +870,6 @@ The rest of the arguments are the same as for `generate_resource`.
871
870
  RESOURCE_DATA, HEADER_INSERTIONS, ROW_FUNCTION,
872
871
  DATECOL or YEARCOL or DATE_FUNCTION, **KWARGS)
873
872
 
874
- ### QuickCharts Generation
875
-
876
- QuickCharts can be generated for datasets using the call below. RESOURCE is a
877
- a resource id or name, or resource metadata from a Resource object or a
878
- dictionary, or the position of the resource in the dataset. It defaults to the
879
- position 0. PATH points to configuration which if not supplied, defaults to the
880
- internal indicators resource view template. You can disable specific bites by
881
- providing BITES_DISABLED, a list of 3 bools where True indicates a specific bite
882
- is disabled and False indicates leave enabled.
883
-
884
- datasets.generate_quickcharts(RESOURCE, "PATH", BITES_DISABLED, INDICATORS,
885
- FIND_REPLACE)
886
-
887
- The parameter INDICATORS is only for use with the built-in configuration and is
888
- a list with 3 dictionaries of form:
889
-
890
- {"code": "MY_INDICATOR_CODE", "title": "MY_INDICATOR_TITLE",
891
- "unit": "MY_INDICATOR_UNIT"}.
892
-
893
- Optionally, the following defaults can be overridden in INDICATORS:
894
-
895
- {"code_col": "#indicator+code", "value_col": "#indicator+value+num",
896
- "date_col": "#date+year", "date_format": "%Y", "aggregate_col": "null"}.
897
-
898
- The built-in configuration assumes data will be of form similar to below:
899
-
900
- GHO (CODE),ENDYEAR,Numeric
901
- #indicator+code,#date+year+end,#indicator+value+num
902
- VIOLENCE_HOMICIDERATE,1994,123.4
903
- MDG_0000000001,2015,123.4
904
-
905
-
906
873
  ## Resource Specific Operations
907
874
 
908
875
  When creating or updating a resource that doesn't have an id, if you supply a parameter
@@ -39,8 +39,8 @@ dependencies = [
39
39
  "ckanapi>=4.8",
40
40
  "defopt>=7.0.0",
41
41
  "email_validator",
42
- "hdx-python-country>=4.0.1",
43
- "hdx-python-utilities>=4.0.4",
42
+ "hdx-python-country>=4.1.1",
43
+ "hdx-python-utilities>=4.0.8",
44
44
  "makefun",
45
45
  "requests",
46
46
  ]
@@ -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.7'
22
+ __version_tuple__ = version_tuple = (6, 6, 7)
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 warnings
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, HXL proxy urls etc. are followed to retrieve final urls.
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,
@@ -260,7 +260,56 @@ class Organization(HDXObject):
260
260
  List of all organization names in HDX
261
261
  """
262
262
  organization = Organization(configuration=configuration)
263
- return organization._write_to_hdx("list", kwargs)
263
+
264
+ # Early return for the standard, non-paginated case
265
+ if not kwargs.get("all_fields"):
266
+ return organization._write_to_hdx("list", kwargs)
267
+
268
+ compiled_orgs = {}
269
+ # Extract limit and offset to dictate our paging sizes, defaulting to 400 and 0
270
+ page_size = kwargs.pop("limit", 400)
271
+ current_offset = kwargs.pop("offset", 0)
272
+
273
+ # 1. Fetch in pages using the provided/default page size
274
+ while True:
275
+ page_kwargs = kwargs.copy()
276
+ page_kwargs["limit"] = page_size
277
+ page_kwargs["offset"] = current_offset
278
+
279
+ page_data = organization._write_to_hdx("list", page_kwargs)
280
+
281
+ if not page_data:
282
+ break
283
+
284
+ # Store by name to automatically deduplicate offset shifts
285
+ for org in page_data:
286
+ compiled_orgs[org["name"]] = org
287
+
288
+ if len(page_data) < page_size:
289
+ break
290
+
291
+ current_offset += page_size
292
+
293
+ # 2. Establish Ground Truth LAST (without limit/offset constraints)
294
+ truth_kwargs = kwargs.copy()
295
+ truth_kwargs["all_fields"] = False
296
+
297
+ ground_truth_names = organization._write_to_hdx("list", truth_kwargs)
298
+
299
+ # 3 & 4. Check for missing IDs, fetch individually, and implicitly prune deletes
300
+ final_orgs = []
301
+ for name in ground_truth_names:
302
+ if name in compiled_orgs:
303
+ final_orgs.append(compiled_orgs[name])
304
+ else:
305
+ try:
306
+ missing_org = organization._write_to_hdx("show", {"id": name})
307
+ if missing_org:
308
+ final_orgs.append(missing_org)
309
+ except Exception:
310
+ pass
311
+
312
+ return final_orgs
264
313
 
265
314
  @classmethod
266
315
  def autocomplete(