ckanapi-harvesters 0.0.4__tar.gz → 0.0.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.
Files changed (118) hide show
  1. {ckanapi_harvesters-0.0.4/src/ckanapi_harvesters.egg-info → ckanapi_harvesters-0.0.6}/PKG-INFO +1 -1
  2. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/pyproject.toml +1 -1
  3. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/example/builder_example_test_sql.py +21 -0
  4. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/ckan_api/ckan_api_2_readonly.py +22 -17
  5. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6/src/ckanapi_harvesters.egg-info}/PKG-INFO +1 -1
  6. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/LICENSE +0 -0
  7. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/README.md +0 -0
  8. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/setup.cfg +0 -0
  9. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/__init__.py +0 -0
  10. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/auxiliary/__init__.py +0 -0
  11. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/auxiliary/ckan_action.py +0 -0
  12. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/auxiliary/ckan_api_key.py +0 -0
  13. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/auxiliary/ckan_auxiliary.py +0 -0
  14. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/auxiliary/ckan_configuration.py +0 -0
  15. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/auxiliary/ckan_defs.py +0 -0
  16. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/auxiliary/ckan_errors.py +0 -0
  17. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/auxiliary/ckan_map.py +0 -0
  18. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/auxiliary/ckan_model.py +0 -0
  19. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/auxiliary/ckan_vocabulary_deprecated.py +0 -0
  20. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/auxiliary/deprecated.py +0 -0
  21. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/auxiliary/error_level_message.py +0 -0
  22. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/auxiliary/external_code_import.py +0 -0
  23. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/auxiliary/list_records.py +0 -0
  24. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/auxiliary/login.py +0 -0
  25. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/auxiliary/path.py +0 -0
  26. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/auxiliary/proxy_config.py +0 -0
  27. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/auxiliary/urls.py +0 -0
  28. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/__init__.py +0 -0
  29. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/builder_aux.py +0 -0
  30. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/builder_ckan.py +0 -0
  31. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/builder_errors.py +0 -0
  32. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/builder_field.py +0 -0
  33. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/builder_package.py +0 -0
  34. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/builder_package_1_basic.py +0 -0
  35. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/builder_package_2_harvesters.py +0 -0
  36. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/builder_package_3_multi_threaded.py +0 -0
  37. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/builder_package_example.xlsx +0 -0
  38. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/builder_resource.py +0 -0
  39. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/builder_resource_datastore.py +0 -0
  40. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/builder_resource_datastore_multi_abc.py +0 -0
  41. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/builder_resource_datastore_multi_folder.py +0 -0
  42. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/builder_resource_datastore_multi_harvester.py +0 -0
  43. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/builder_resource_datastore_unmanaged.py +0 -0
  44. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/builder_resource_datastore_url.py +0 -0
  45. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/builder_resource_init.py +0 -0
  46. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/builder_resource_multi_abc.py +0 -0
  47. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/builder_resource_multi_datastore.py +0 -0
  48. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/builder_resource_multi_file.py +0 -0
  49. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/example/__init__.py +0 -0
  50. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/example/builder_example.py +0 -0
  51. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/example/builder_example_aux_fun.py +0 -0
  52. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/example/builder_example_download.py +0 -0
  53. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/example/builder_example_generate_data.py +0 -0
  54. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/example/builder_example_patch_upload.py +0 -0
  55. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/example/builder_example_policy.py +0 -0
  56. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/example/builder_example_tests.py +0 -0
  57. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/example/builder_example_tests_offline.py +0 -0
  58. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/example/package/ckan-dpg.svg +0 -0
  59. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/example/package/traces/trace_000.csv +0 -0
  60. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/example/package/traces/trace_001.csv +0 -0
  61. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/example/package/traces/trace_002.csv +0 -0
  62. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/example/package/traces_multi/trace_000.csv +0 -0
  63. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/example/package/traces_multi/trace_001.csv +0 -0
  64. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/example/package/traces_multi/trace_002.csv +0 -0
  65. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/example/package/users_local.csv +0 -0
  66. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/mapper_datastore.py +0 -0
  67. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/mapper_datastore_multi.py +0 -0
  68. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/specific/__init__.py +0 -0
  69. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/specific/configuration_builder.py +0 -0
  70. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/builder/specific_builder_abc.py +0 -0
  71. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/ckan_api/__init__.py +0 -0
  72. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/ckan_api/ckan_api.py +0 -0
  73. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/ckan_api/ckan_api_0_base.py +0 -0
  74. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/ckan_api/ckan_api_1_map.py +0 -0
  75. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/ckan_api/ckan_api_3_policy.py +0 -0
  76. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/ckan_api/ckan_api_4_readwrite.py +0 -0
  77. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/ckan_api/ckan_api_5_manage.py +0 -0
  78. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/ckan_api/ckan_api_params.py +0 -0
  79. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/ckan_api/deprecated/__init__.py +0 -0
  80. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/ckan_api/deprecated/ckan_api_deprecated.py +0 -0
  81. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/ckan_api/deprecated/ckan_api_deprecated_vocabularies.py +0 -0
  82. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/harvesters/__init__.py +0 -0
  83. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/harvesters/data_cleaner/__init__.py +0 -0
  84. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/harvesters/data_cleaner/data_cleaner_abc.py +0 -0
  85. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/harvesters/data_cleaner/data_cleaner_errors.py +0 -0
  86. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/harvesters/data_cleaner/data_cleaner_upload.py +0 -0
  87. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/harvesters/data_cleaner/data_cleaner_upload_1_basic.py +0 -0
  88. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/harvesters/data_cleaner/data_cleaner_upload_2_geom.py +0 -0
  89. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/harvesters/file_formats/__init__.py +0 -0
  90. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/harvesters/file_formats/csv_format.py +0 -0
  91. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/harvesters/file_formats/file_format_abc.py +0 -0
  92. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/harvesters/file_formats/file_format_init.py +0 -0
  93. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/harvesters/file_formats/shp_format.py +0 -0
  94. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/harvesters/harvester_abc.py +0 -0
  95. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/harvesters/harvester_errors.py +0 -0
  96. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/harvesters/harvester_init.py +0 -0
  97. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/harvesters/harvester_model.py +0 -0
  98. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/harvesters/harvester_params.py +0 -0
  99. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/harvesters/postgre_harvester.py +0 -0
  100. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/harvesters/postgre_params.py +0 -0
  101. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/harvesters/pymongo_data_cleaner.py +0 -0
  102. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/harvesters/pymongo_harvester.py +0 -0
  103. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/harvesters/pymongo_params.py +0 -0
  104. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/policies/__init__.py +0 -0
  105. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/policies/data_format_policy.py +0 -0
  106. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/policies/data_format_policy_abc.py +0 -0
  107. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/policies/data_format_policy_custom_fields.py +0 -0
  108. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/policies/data_format_policy_defs.py +0 -0
  109. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/policies/data_format_policy_errors.py +0 -0
  110. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/policies/data_format_policy_lists.py +0 -0
  111. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/policies/data_format_policy_tag_groups.py +0 -0
  112. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/reports/__init__.py +0 -0
  113. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters/reports/admin_report.py +0 -0
  114. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters.egg-info/SOURCES.txt +0 -0
  115. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters.egg-info/dependency_links.txt +0 -0
  116. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters.egg-info/requires.txt +0 -0
  117. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/src/ckanapi_harvesters.egg-info/top_level.txt +0 -0
  118. {ckanapi_harvesters-0.0.4 → ckanapi_harvesters-0.0.6}/tests/test_builder_example_offline.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ckanapi_harvesters
3
- Version: 0.0.4
3
+ Version: 0.0.6
4
4
  Summary: Package helping to upload local resources to a CKAN server using the CKAN API. Metadata and the list of resources can be defined in an Excel spreadsheet. The package includes requests to download resources and checks metadata against formatting rules.
5
5
  Author-email: ifpen-gp <63413841+ifpen-gp@users.noreply.github.com>
6
6
  Maintainer-email: ifpen-gp <63413841+ifpen-gp@users.noreply.github.com>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ckanapi_harvesters"
3
- version = '0.0.4'
3
+ version = '0.0.6'
4
4
  authors = [
5
5
  { name = "ifpen-gp", email = "63413841+ifpen-gp@users.noreply.github.com" },
6
6
  ]
@@ -37,12 +37,33 @@ def run(ckan:CkanApi = None):
37
37
  ckan.api_help_show("datastore_search_sql")
38
38
  except CkanNotFoundError:
39
39
  print("No datastore_search_sql help")
40
+
40
41
  users_table_id = mdl.get_or_query_resource_id(ckan, "users.csv")
42
+ traces_table_id = mdl.get_or_query_resource_id(ckan, "traces.csv")
43
+
44
+ # datastore_search simple API
45
+ cursor = ckan.datastore_search_cursor(users_table_id, limit=1)
46
+ document = next(cursor)
47
+ user_id = document["user_id"]
48
+ cursor = ckan.datastore_search_cursor(traces_table_id, filters={"user_id": int(user_id)}, limit=10)
49
+ for document in cursor:
50
+ print(document)
51
+
41
52
  try:
42
53
  ckan.datastore_search_sql(f'SELECT * FROM "{users_table_id}"')
43
54
  except CkanSqlCapabilityError:
44
55
  print("datastore_search_sql is not accessible")
45
56
 
57
+ query = f"""
58
+ SELECT t.*, u.* FROM "{traces_table_id}" t
59
+ JOIN "{users_table_id}" u ON t.user_id = u.user_id
60
+ WHERE t.user_id = {user_id}
61
+ LIMIT 10
62
+ """
63
+ cursor = ckan.datastore_search_sql_cursor(query, return_df=False)
64
+ for document in cursor:
65
+ print(document)
66
+
46
67
  print("Tests done.")
47
68
 
48
69
 
@@ -280,7 +280,7 @@ class CkanApiReadOnly(CkanApiMap):
280
280
  ### Search method ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
281
281
  def _api_datastore_search_raw(self, resource_id:str, *, filters:dict=None, q:str=None, fields:List[str]=None,
282
282
  distinct:bool=None, sort:str=None, limit:int=None, offset:int=0, format:str=None,
283
- params:dict=None, compute_len:int=False) -> CkanActionResponse:
283
+ params:dict=None, compute_len:bool=False) -> CkanActionResponse:
284
284
  """
285
285
  API call to datastore_search. Performs queries on the DataStore.
286
286
 
@@ -338,7 +338,8 @@ class CkanApiReadOnly(CkanApiMap):
338
338
  raise response.default_error(self)
339
339
 
340
340
  def _api_datastore_search_df(self, resource_id:str, *, filters:dict=None, q:str=None, fields:List[str]=None,
341
- distinct:bool=None, sort:str=None, limit:int=None, offset:int=0, format:str=None, params:dict=None) -> pd.DataFrame:
341
+ distinct:bool=None, sort:str=None, limit:int=None, offset:int=0, format:str=None,
342
+ params:dict=None, compute_len:bool=True) -> pd.DataFrame:
342
343
  """
343
344
  Convert output of _api_datastore_search_raw to pandas DataFrame.
344
345
  """
@@ -377,7 +378,7 @@ class CkanApiReadOnly(CkanApiMap):
377
378
  def _api_datastore_search_all(self, resource_id:str, *, filters:dict=None, q:str=None, fields:List[str]=None,
378
379
  distinct:bool=None, sort:str=None, limit:int=None, offset:int=0, format:str=None,
379
380
  search_all:bool=True, params:dict=None, return_df:bool=True, compute_len:bool=False) \
380
- -> Union[pd.DataFrame, Tuple[ListRecords, OrderedDict], Any]:
381
+ -> Union[pd.DataFrame, ListRecords, Any]:
381
382
  """
382
383
  Successive calls to _api_datastore_search_df until an empty list is received.
383
384
 
@@ -409,7 +410,7 @@ class CkanApiReadOnly(CkanApiMap):
409
410
  search_all=search_all, resource_id=resource_id, filters=filters, q=q, fields=fields, distinct=distinct, sort=sort, format=format, compute_len=compute_len)
410
411
  # aggregate results, depending on the format
411
412
  if self.params.dry_run:
412
- return [], {}
413
+ return []
413
414
  if format is not None:
414
415
  format = format.lower()
415
416
  if len(responses) > 0:
@@ -420,12 +421,12 @@ class CkanApiReadOnly(CkanApiMap):
420
421
  fields_type_dict = None
421
422
  df_args = {}
422
423
  if format is None or format == "objects":
423
- return ListRecords(sum([response.result["records"] for response in responses], [])), fields_type_dict
424
+ return ListRecords(sum([response.result["records"] for response in responses], []))
424
425
  else:
425
426
  if format == "lists":
426
- return sum([response.result["records"] for response in responses], []), fields_type_dict
427
+ return sum([response.result["records"] for response in responses], [])
427
428
  else:
428
- return "\n".join([response.result["records"] for response in responses]), fields_type_dict
429
+ return "\n".join([response.result["records"] for response in responses])
429
430
 
430
431
  def _api_datastore_search_all_generator(self, resource_id:str, *, filters:dict=None, q:str=None, fields:List[str]=None,
431
432
  distinct:bool=None, sort:str=None, limit:int=None, offset:int=0,
@@ -486,6 +487,10 @@ class CkanApiReadOnly(CkanApiMap):
486
487
  params["limit"] = limit
487
488
  response = self._api_action_request(f"datastore_search_sql", method=RequestType.Post, params=params)
488
489
  if response.success:
490
+ if response.dry_run:
491
+ return response
492
+ else:
493
+ response.len = len(response.result["records"])
489
494
  return response
490
495
  elif response.status_code == 400 and response.success_json_loads and response.response.text == '"Bad request - Action name not known: datastore_search_sql"':
491
496
  raise CkanSqlCapabilityError(self, response)
@@ -513,7 +518,7 @@ class CkanApiReadOnly(CkanApiMap):
513
518
 
514
519
  def _api_datastore_search_sql_all(self, sql:str, *, params:dict=None,
515
520
  search_all:bool=True, limit:int=None, offset:int=0, return_df:bool=True) \
516
- -> Union[pd.DataFrame, Tuple[ListRecords, dict]]:
521
+ -> Union[pd.DataFrame, ListRecords]:
517
522
  """
518
523
  Successive calls to _api_datastore_search_sql until an empty list is received.
519
524
 
@@ -543,7 +548,7 @@ class CkanApiReadOnly(CkanApiMap):
543
548
  fields_type_dict = CkanApiReadOnly.read_fields_type_dict(response.result["fields"])
544
549
  else:
545
550
  fields_type_dict = None
546
- return ListRecords(sum([response.result["records"] for response in responses], [])), fields_type_dict
551
+ return ListRecords(sum([response.result["records"] for response in responses], []))
547
552
 
548
553
  def _api_datastore_search_sql_all_generator(self, sql:str, *, params:dict=None,
549
554
  search_all:bool=True, limit:int=None, offset:int=0, return_df:bool=True) \
@@ -659,8 +664,8 @@ class CkanApiReadOnly(CkanApiMap):
659
664
 
660
665
  def datastore_search_cursor(self, resource_id:str, *, filters:dict=None, q:str=None, fields:List[str]=None,
661
666
  distinct:bool=None, sort:str=None, limit:int=None, offset:int=0, params:dict=None,
662
- search_all:bool=False, search_method:bool=True, format:str=None, return_df:bool=True) \
663
- -> Generator[Union[pd.Series, Tuple[dict,dict], Tuple[list,dict], Tuple[str,dict]], Any, None]:
667
+ search_all:bool=False, search_method:bool=True, format:str=None, return_df:bool=False) \
668
+ -> Generator[Union[pd.Series, dict, list, str], Any, None]:
664
669
  """
665
670
  Cursor on rows
666
671
  """
@@ -682,12 +687,12 @@ class CkanApiReadOnly(CkanApiMap):
682
687
  for response in generator:
683
688
  fields_type_dict = CkanApiReadOnly.read_fields_type_dict(response.result["fields"])
684
689
  for element in response.result["records"]:
685
- yield element, fields_type_dict
690
+ yield element
686
691
  else:
687
692
  for response in generator:
688
693
  fields_type_dict = CkanApiReadOnly.read_fields_type_dict(response.result["fields"])
689
694
  for element in response.result["records"]:
690
- yield element, fields_type_dict
695
+ yield element
691
696
  else:
692
697
  raise TypeError("dumping datastore without parsing with a DataFrame does not return an iterable object")
693
698
 
@@ -752,8 +757,8 @@ class CkanApiReadOnly(CkanApiMap):
752
757
  return self._api_datastore_search_sql_all_generator(sql, params=params, limit=limit, offset=offset, search_all=search_all, return_df=return_df)
753
758
 
754
759
  def datastore_search_sql_cursor(self, sql:str, *, params:dict=None, search_all:bool=False,
755
- limit:int=None, offset:int=0, return_df:bool=True) \
756
- -> Generator[Union[pd.Series,Tuple[dict,dict]], Any, None]:
760
+ limit:int=None, offset:int=0, return_df:bool=False) \
761
+ -> Generator[Union[pd.Series,dict], Any, None]:
757
762
  generator = self.datastore_search_sql_generator(sql, params=params, search_all=search_all,
758
763
  limit=limit, offset=offset, return_df=return_df)
759
764
  if return_df:
@@ -769,7 +774,7 @@ class CkanApiReadOnly(CkanApiMap):
769
774
  for response in generator:
770
775
  fields_type_dict = CkanApiReadOnly.read_fields_type_dict(response.result["fields"])
771
776
  for element in response.result["records"]:
772
- yield element, fields_type_dict
777
+ yield element
773
778
 
774
779
  def datastore_search_sql_find_one(self, sql:str, *, params:dict=None,
775
780
  offset:int=0, return_df:bool=True) -> Union[pd.DataFrame, Tuple[ListRecords, dict]]:
@@ -912,7 +917,7 @@ class CkanApiReadOnly(CkanApiMap):
912
917
  ## Mapping of resource aliases from table
913
918
  def list_datastore_aliases(self) -> List[CkanAliasInfo]:
914
919
  alias_resource_id = "_table_metadata" # resource name of table containing CKAN aliases
915
- alias_list_dict, _ = self.datastore_search(alias_resource_id, search_all=True, return_df=False, format="objects", search_method=True)
920
+ alias_list_dict = self.datastore_search(alias_resource_id, search_all=True, return_df=False, format="objects", search_method=True)
916
921
  alias_list = [CkanAliasInfo(alias_dict) for alias_dict in alias_list_dict]
917
922
  for alias_info in alias_list:
918
923
  if alias_info.alias_of is not None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ckanapi_harvesters
3
- Version: 0.0.4
3
+ Version: 0.0.6
4
4
  Summary: Package helping to upload local resources to a CKAN server using the CKAN API. Metadata and the list of resources can be defined in an Excel spreadsheet. The package includes requests to download resources and checks metadata against formatting rules.
5
5
  Author-email: ifpen-gp <63413841+ifpen-gp@users.noreply.github.com>
6
6
  Maintainer-email: ifpen-gp <63413841+ifpen-gp@users.noreply.github.com>