|
@@
-1,500
+1,502
|
|
1
|
from ckanapi import RemoteCKAN
|
|
1
|
from ckanapi import RemoteCKAN
|
|
2
|
from datetime import datetime
|
|
2
|
from datetime import datetime
|
|
3
|
from CKAN_JRO import logic_download
|
|
3
|
from jrodb import download
|
|
4
|
from CKAN_JRO import resource
|
|
4
|
from jrodb import resource
|
|
5
|
#from ckanapi.errors import NotAuthorized, NotFound, ValidationError, SearchQueryError, SearchError, CKANAPIError, ServerIncompatibleError
|
|
5
|
#from ckanapi.errors import NotAuthorized, NotFound, ValidationError, SearchQueryError, SearchError, CKANAPIError, ServerIncompatibleError
|
|
6
|
import sys
|
|
6
|
import sys
|
|
7
|
import platform
|
|
7
|
import platform
|
|
8
|
import os
|
|
8
|
import os
|
|
9
|
import requests
|
|
9
|
import requests
|
|
10
|
|
|
10
|
|
|
11
|
class JROAPI():
|
|
11
|
class Api():
|
|
12
|
"""
|
|
12
|
"""
|
|
13
|
FINALIDAD:
|
|
13
|
FINALIDAD:
|
|
14
|
Script para administrar y obtener la data del repositorio por medio de APIs.
|
|
14
|
Script para administrar y obtener la data del repositorio por medio de APIs.
|
|
15
|
|
|
15
|
|
|
16
|
REQUISITIOS PREVIOS:
|
|
16
|
REQUISITIOS PREVIOS:
|
|
17
|
- Paso 1: Tener "pip [Python 2]" o "pip3 [Python 3]" instalado:
|
|
17
|
- Paso 1: Tener "pip [Python 2]" o "pip3 [Python 3]" instalado:
|
|
18
|
- Paso 2: Instalar los siguientes paquetes:
|
|
18
|
- Paso 2: Instalar los siguientes paquetes:
|
|
19
|
ckanapi==4.7
|
|
19
|
En Python 2
|
|
20
|
requests
|
|
20
|
- pip install -e git+http://intranet.igp.gob.pe:8082/DATABASES/ckanext-jro/api-cliente#egg=jrodb
|
|
|
|
|
21
|
En Python 3
|
|
|
|
|
22
|
- pip3 install -e git+http://intranet.igp.gob.pe:8082/DATABASES/ckanext-jro/api-cliente#egg=jrodb
|
|
21
|
|
|
23
|
|
|
22
|
FUNCIONES DISPONIBLES:
|
|
24
|
FUNCIONES DISPONIBLES:
|
|
23
|
- action
|
|
25
|
- action
|
|
24
|
- show
|
|
26
|
- show
|
|
25
|
- search
|
|
27
|
- search
|
|
26
|
- create
|
|
28
|
- create
|
|
27
|
- patch
|
|
29
|
- patch
|
|
28
|
- delete
|
|
30
|
- delete
|
|
29
|
- download_files
|
|
31
|
- download
|
|
30
|
|
|
32
|
|
|
31
|
EJEMPLOS:
|
|
33
|
EJEMPLOS:
|
|
32
|
#1:
|
|
34
|
#1:
|
|
33
|
with JROAPI('http://demo.example.com', Authorization='#########') as <access_name>:
|
|
35
|
with Api('http://demo.example.com', Authorization='#########') as <access_name>:
|
|
34
|
... some operation(s) ...
|
|
36
|
... some operation(s) ...
|
|
35
|
#2:
|
|
37
|
#2:
|
|
36
|
<access_name> = JROAPI('http://example.com', Authorization='#########')
|
|
38
|
<access_name> = Api('http://example.com', Authorization='#########')
|
|
37
|
... some operation(s) ...
|
|
39
|
... some operation(s) ...
|
|
38
|
<access_name>.ckan.close()
|
|
40
|
<access_name>.ckan.close()
|
|
39
|
|
|
41
|
|
|
40
|
REPORTAR ALGUN PROBLEMA:
|
|
42
|
REPORTAR ALGUN PROBLEMA:
|
|
41
|
Debe enviar un correo a eynilupu@igp.gob.pe detallando los siguientes pasos:
|
|
43
|
Debe enviar un correo a eynilupu@igp.gob.pe detallando los siguientes pasos:
|
|
42
|
1) Correo para contactarlo
|
|
44
|
1) Correo para contactarlo
|
|
43
|
2) Descripcion del problema
|
|
45
|
2) Descripcion del problema
|
|
44
|
3) ¿En que paso o seccion encontro el problema?
|
|
46
|
3) ¿En que paso o seccion encontro el problema?
|
|
45
|
4) ¿Cual era el resultado que usted esperaba?
|
|
47
|
4) ¿Cual era el resultado que usted esperaba?
|
|
46
|
"""
|
|
48
|
"""
|
|
47
|
def __init__(self, url, Authorization=None, secure=True):
|
|
49
|
def __init__(self, url, Authorization=None, secure=True):
|
|
48
|
#-------- Check Secure -------#
|
|
50
|
#-------- Check Secure -------#
|
|
49
|
self.verify = secure
|
|
51
|
self.verify = secure
|
|
50
|
if not secure and isinstance(secure, bool):
|
|
52
|
if not secure and isinstance(secure, bool):
|
|
51
|
session = requests.Session()
|
|
53
|
session = requests.Session()
|
|
52
|
session.verify = False
|
|
54
|
session.verify = False
|
|
53
|
else:
|
|
55
|
else:
|
|
54
|
session = None
|
|
56
|
session = None
|
|
55
|
#------------------------------#
|
|
57
|
#------------------------------#
|
|
56
|
self.url = url
|
|
58
|
self.url = url
|
|
57
|
ua = 'CKAN_JRO/2.9.2 (+'+str(self.url)+')'
|
|
59
|
ua = 'CKAN_JRO/2.9.2 (+'+str(self.url)+')'
|
|
58
|
#ua = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'
|
|
60
|
#ua = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'
|
|
59
|
self.ckan = RemoteCKAN(self.url, apikey=Authorization, user_agent=ua, session=session)
|
|
61
|
self.ckan = RemoteCKAN(self.url, apikey=Authorization, user_agent=ua, session=session)
|
|
60
|
#self.ckan = RemoteCKAN(self.url, apikey=Authorization)
|
|
62
|
#self.ckan = RemoteCKAN(self.url, apikey=Authorization)
|
|
61
|
self.Authorization = Authorization
|
|
63
|
self.Authorization = Authorization
|
|
62
|
# Change for --> self.separator = os.sep
|
|
64
|
# Change for --> self.separator = os.sep
|
|
63
|
if platform.system() == 'Windows':
|
|
65
|
if platform.system() == 'Windows':
|
|
64
|
self.separator = '\\'
|
|
66
|
self.separator = '\\'
|
|
65
|
else:
|
|
67
|
else:
|
|
66
|
self.separator = '/'
|
|
68
|
self.separator = '/'
|
|
67
|
|
|
69
|
|
|
68
|
self.chunk_size = 1024
|
|
70
|
self.chunk_size = 1024
|
|
69
|
self.list = []
|
|
71
|
self.list = []
|
|
70
|
self.dict = {}
|
|
72
|
self.dict = {}
|
|
71
|
self.str = ''
|
|
73
|
self.str = ''
|
|
72
|
self.check = 1
|
|
74
|
self.check = 1
|
|
73
|
self.cont = 0
|
|
75
|
self.cont = 0
|
|
74
|
|
|
76
|
|
|
75
|
def __enter__(self):
|
|
77
|
def __enter__(self):
|
|
76
|
return self
|
|
78
|
return self
|
|
77
|
|
|
79
|
|
|
78
|
def __exit__(self, *args):
|
|
80
|
def __exit__(self, *args):
|
|
79
|
self.ckan.close()
|
|
81
|
self.ckan.close()
|
|
80
|
|
|
82
|
|
|
81
|
def action(self, action, **kwargs):
|
|
83
|
def action(self, action, **kwargs):
|
|
82
|
"""
|
|
84
|
"""
|
|
83
|
FINALIDAD:
|
|
85
|
FINALIDAD:
|
|
84
|
Funcion para llamar a las APIs disponibles
|
|
86
|
Funcion para llamar a las APIs disponibles
|
|
85
|
|
|
87
|
|
|
86
|
APIs DISPONIBLES:
|
|
88
|
APIs DISPONIBLES:
|
|
87
|
CONSULTAR: "GUIA DE SCRIPT.pdf"
|
|
89
|
CONSULTAR: "GUIA DE SCRIPT.pdf"
|
|
88
|
|
|
90
|
|
|
89
|
EJEMPLO:
|
|
91
|
EJEMPLO:
|
|
90
|
<access_name>.action(<consuming API>, param_1 = <class 'param_1'>, ...)
|
|
92
|
<access_name>.action(<consuming API>, param_1 = <class 'param_1'>, ...)
|
|
91
|
"""
|
|
93
|
"""
|
|
92
|
#--------------- CASE: PACKAGE SEARCH ---------------#
|
|
94
|
#--------------- CASE: PACKAGE SEARCH ---------------#
|
|
93
|
if kwargs is not None:
|
|
95
|
if kwargs is not None:
|
|
94
|
if action == 'package_search':
|
|
96
|
if action == 'package_search':
|
|
95
|
self.list = ['facet_mincount', 'facet_limit', 'facet_field']
|
|
97
|
self.list = ['facet_mincount', 'facet_limit', 'facet_field']
|
|
96
|
for facet in self.list:
|
|
98
|
for facet in self.list:
|
|
97
|
if facet in kwargs:
|
|
99
|
if facet in kwargs:
|
|
98
|
kwargs[facet.replace('_', '.')] = kwargs[facet]
|
|
100
|
kwargs[facet.replace('_', '.')] = kwargs[facet]
|
|
99
|
kwargs.pop(facet)
|
|
101
|
kwargs.pop(facet)
|
|
100
|
#----------------------------------------------------#
|
|
102
|
#----------------------------------------------------#
|
|
101
|
try:
|
|
103
|
try:
|
|
102
|
return getattr(self.ckan.action, action)(**kwargs)
|
|
104
|
return getattr(self.ckan.action, action)(**kwargs)
|
|
103
|
except:
|
|
105
|
except:
|
|
104
|
_, exc_value, _ = sys.exc_info()
|
|
106
|
_, exc_value, _ = sys.exc_info()
|
|
105
|
return exc_value
|
|
107
|
return exc_value
|
|
106
|
|
|
108
|
|
|
107
|
def show(self, type_option, id, **kwargs):
|
|
109
|
def show(self, type_option, id, **kwargs):
|
|
108
|
'''
|
|
110
|
'''
|
|
109
|
FINALIDAD:
|
|
111
|
FINALIDAD:
|
|
110
|
Funcion personalizada para una busqueda en especifico.
|
|
112
|
Funcion personalizada para una busqueda en especifico.
|
|
111
|
|
|
113
|
|
|
112
|
PARAMETROS DISPONIBLES:
|
|
114
|
PARAMETROS DISPONIBLES:
|
|
113
|
CONSULTAR: "GUIA DE SCRIPT.pdf"
|
|
115
|
CONSULTAR: "GUIA DE SCRIPT.pdf"
|
|
114
|
|
|
116
|
|
|
115
|
ESTRUCTURA:
|
|
117
|
ESTRUCTURA:
|
|
116
|
<access_name>.show(type_option = <class 'str'>, id = <class 'str'>, param_1 = <class 'param_1'>, ...)
|
|
118
|
<access_name>.show(type_option = <class 'str'>, id = <class 'str'>, param_1 = <class 'param_1'>, ...)
|
|
117
|
'''
|
|
119
|
'''
|
|
118
|
if type(type_option) is str:
|
|
120
|
if type(type_option) is str:
|
|
119
|
try:
|
|
121
|
try:
|
|
120
|
if type_option == 'dataset':
|
|
122
|
if type_option == 'dataset':
|
|
121
|
return getattr(self.ckan.action, 'package_show')(id=id, **kwargs)
|
|
123
|
return getattr(self.ckan.action, 'package_show')(id=id, **kwargs)
|
|
122
|
elif type_option == 'resource':
|
|
124
|
elif type_option == 'resource':
|
|
123
|
return getattr(self.ckan.action, 'resource_show')(id=id, **kwargs)
|
|
125
|
return getattr(self.ckan.action, 'resource_show')(id=id, **kwargs)
|
|
124
|
elif type_option == 'project':
|
|
126
|
elif type_option == 'project':
|
|
125
|
return getattr(self.ckan.action, 'organization_show')(id=id, **kwargs)
|
|
127
|
return getattr(self.ckan.action, 'organization_show')(id=id, **kwargs)
|
|
126
|
elif type_option == 'collaborator':
|
|
128
|
elif type_option == 'collaborator':
|
|
127
|
return getattr(self.ckan.action, 'package_collaborator_list_for_user')(id=id, **kwargs)
|
|
129
|
return getattr(self.ckan.action, 'package_collaborator_list_for_user')(id=id, **kwargs)
|
|
128
|
elif type_option == 'member':
|
|
130
|
elif type_option == 'member':
|
|
129
|
return getattr(self.ckan.action, 'organization_list_for_user')(id=id, **kwargs)
|
|
131
|
return getattr(self.ckan.action, 'organization_list_for_user')(id=id, **kwargs)
|
|
130
|
elif type_option == 'vocabulary':
|
|
132
|
elif type_option == 'vocabulary':
|
|
131
|
return getattr(self.ckan.action, 'vocabulary_show')(id=id, **kwargs)
|
|
133
|
return getattr(self.ckan.action, 'vocabulary_show')(id=id, **kwargs)
|
|
132
|
elif type_option == 'tag':
|
|
134
|
elif type_option == 'tag':
|
|
133
|
if not 'vocabulary_id' in kwargs:
|
|
135
|
if not 'vocabulary_id' in kwargs:
|
|
134
|
print('Missing "vocabulary_id" value: assume it is a free tag')
|
|
136
|
print('Missing "vocabulary_id" value: assume it is a free tag')
|
|
135
|
return getattr(self.ckan.action, 'tag_show')(id=id, **kwargs)
|
|
137
|
return getattr(self.ckan.action, 'tag_show')(id=id, **kwargs)
|
|
136
|
elif type_option == 'user':
|
|
138
|
elif type_option == 'user':
|
|
137
|
return getattr(self.ckan.action, 'user_show')(id=id, **kwargs)
|
|
139
|
return getattr(self.ckan.action, 'user_show')(id=id, **kwargs)
|
|
138
|
elif type_option == 'job':
|
|
140
|
elif type_option == 'job':
|
|
139
|
return getattr(self.ckan.action, 'job_show')(id=id, **kwargs)
|
|
141
|
return getattr(self.ckan.action, 'job_show')(id=id, **kwargs)
|
|
140
|
else:
|
|
142
|
else:
|
|
141
|
return 'ERROR:: "type_option = %s" is not accepted' % (type_option)
|
|
143
|
return 'ERROR:: "type_option = %s" is not accepted' % (type_option)
|
|
142
|
except:
|
|
144
|
except:
|
|
143
|
_, exc_value, _ = sys.exc_info()
|
|
145
|
_, exc_value, _ = sys.exc_info()
|
|
144
|
return exc_value
|
|
146
|
return exc_value
|
|
145
|
else:
|
|
147
|
else:
|
|
146
|
return 'ERROR:: "type_option" must be a str'
|
|
148
|
return 'ERROR:: "type_option" must be a str'
|
|
147
|
|
|
149
|
|
|
148
|
def search(self, type_option, query=None, **kwargs):
|
|
150
|
def search(self, type_option, query=None, **kwargs):
|
|
149
|
'''
|
|
151
|
'''
|
|
150
|
FINALIDAD:
|
|
152
|
FINALIDAD:
|
|
151
|
Funcion personalizada para busquedas que satisfagan algun criterio.
|
|
153
|
Funcion personalizada para busquedas que satisfagan algun criterio.
|
|
152
|
|
|
154
|
|
|
153
|
PARAMETROS DISPONIBLES:
|
|
155
|
PARAMETROS DISPONIBLES:
|
|
154
|
CONSULTAR: "GUIA DE SCRIPT.pdf"
|
|
156
|
CONSULTAR: "GUIA DE SCRIPT.pdf"
|
|
155
|
|
|
157
|
|
|
156
|
ESTRUCTURA:
|
|
158
|
ESTRUCTURA:
|
|
157
|
<access_name>.search(type_option = <class 'str'>, query = <class 'dict'>, param_1 = <class 'param_1'>, ...)
|
|
159
|
<access_name>.search(type_option = <class 'str'>, query = <class 'dict'>, param_1 = <class 'param_1'>, ...)
|
|
158
|
'''
|
|
160
|
'''
|
|
159
|
if type(type_option) is str:
|
|
161
|
if type(type_option) is str:
|
|
160
|
try:
|
|
162
|
try:
|
|
161
|
if type_option == 'dataset':
|
|
163
|
if type_option == 'dataset':
|
|
162
|
key_replace = ['fq', 'fq_list', 'include_private']
|
|
164
|
key_replace = ['fq', 'fq_list', 'include_private']
|
|
163
|
key_point = ['facet_mincount', 'facet_limit', 'facet_field']
|
|
165
|
key_point = ['facet_mincount', 'facet_limit', 'facet_field']
|
|
164
|
for key1, value1 in kwargs.items():
|
|
166
|
for key1, value1 in kwargs.items():
|
|
165
|
if not key1 in key_replace:
|
|
167
|
if not key1 in key_replace:
|
|
166
|
if key1 in key_point:
|
|
168
|
if key1 in key_point:
|
|
167
|
self.dict[key1.replace('_', '.')] = value1
|
|
169
|
self.dict[key1.replace('_', '.')] = value1
|
|
168
|
else:
|
|
170
|
else:
|
|
169
|
self.dict[key1] = value1
|
|
171
|
self.dict[key1] = value1
|
|
170
|
|
|
172
|
|
|
171
|
if query is not None:
|
|
173
|
if query is not None:
|
|
172
|
if type(query) is dict:
|
|
174
|
if type(query) is dict:
|
|
173
|
self.dict['fq_list'] = []
|
|
175
|
self.dict['fq_list'] = []
|
|
174
|
#NUM_RESOURCES_MIN / NUM_RESOURCES_MAX
|
|
176
|
#NUM_RESOURCES_MIN / NUM_RESOURCES_MAX
|
|
175
|
#----------------------------------------------------#
|
|
177
|
#----------------------------------------------------#
|
|
176
|
if 'dataset_start_date' in query:
|
|
178
|
if 'dataset_start_date' in query:
|
|
177
|
if type(query['dataset_start_date']) is str:
|
|
179
|
if type(query['dataset_start_date']) is str:
|
|
178
|
try:
|
|
180
|
try:
|
|
179
|
datetime.strptime(query['dataset_start_date'], '%Y-%m-%d')
|
|
181
|
datetime.strptime(query['dataset_start_date'], '%Y-%m-%d')
|
|
180
|
if len(query['dataset_start_date']) != 10:
|
|
182
|
if len(query['dataset_start_date']) != 10:
|
|
181
|
return '"dataset_start_date", must be: <YYYY-MM-DD>'
|
|
183
|
return '"dataset_start_date", must be: <YYYY-MM-DD>'
|
|
182
|
self.dict['fq_list'].append('dataset_start_date:"'+query['dataset_start_date']+'"')
|
|
184
|
self.dict['fq_list'].append('dataset_start_date:"'+query['dataset_start_date']+'"')
|
|
183
|
self.list.append('dataset_start_date')
|
|
185
|
self.list.append('dataset_start_date')
|
|
184
|
except:
|
|
186
|
except:
|
|
185
|
return '"dataset_start_date" incorrect: "%s"' % (query['dataset_start_date'])
|
|
187
|
return '"dataset_start_date" incorrect: "%s"' % (query['dataset_start_date'])
|
|
186
|
else:
|
|
188
|
else:
|
|
187
|
return '"dataset_start_date" must be <str>'
|
|
189
|
return '"dataset_start_date" must be <str>'
|
|
188
|
#----------------------------------------------------#
|
|
190
|
#----------------------------------------------------#
|
|
189
|
if 'dataset_end_date' in query:
|
|
191
|
if 'dataset_end_date' in query:
|
|
190
|
if type(query['dataset_end_date']) is str:
|
|
192
|
if type(query['dataset_end_date']) is str:
|
|
191
|
try:
|
|
193
|
try:
|
|
192
|
datetime.strptime(query['dataset_end_date'], '%Y-%m-%d')
|
|
194
|
datetime.strptime(query['dataset_end_date'], '%Y-%m-%d')
|
|
193
|
if len(query['dataset_end_date']) != 10:
|
|
195
|
if len(query['dataset_end_date']) != 10:
|
|
194
|
return '"dataset_end_date", must be: <YYYY-MM-DD>'
|
|
196
|
return '"dataset_end_date", must be: <YYYY-MM-DD>'
|
|
195
|
|
|
197
|
|
|
196
|
if 'dataset_start_date' in query:
|
|
198
|
if 'dataset_start_date' in query:
|
|
197
|
if query['dataset_start_date'] > query['dataset_end_date']:
|
|
199
|
if query['dataset_start_date'] > query['dataset_end_date']:
|
|
198
|
return '"dataset_end_date" must be greater than "dataset_start_date"'
|
|
200
|
return '"dataset_end_date" must be greater than "dataset_start_date"'
|
|
199
|
|
|
201
|
|
|
200
|
self.dict['fq_list'].append('dataset_end_date:"'+query['dataset_end_date']+'"')
|
|
202
|
self.dict['fq_list'].append('dataset_end_date:"'+query['dataset_end_date']+'"')
|
|
201
|
self.list.append('dataset_end_date')
|
|
203
|
self.list.append('dataset_end_date')
|
|
202
|
except:
|
|
204
|
except:
|
|
203
|
return '"dataset_end_date" incorrect: "%s"' % (query['dataset_end_date'])
|
|
205
|
return '"dataset_end_date" incorrect: "%s"' % (query['dataset_end_date'])
|
|
204
|
else:
|
|
206
|
else:
|
|
205
|
return '"dataset_end_date" must be <str>'
|
|
207
|
return '"dataset_end_date" must be <str>'
|
|
206
|
#----------------------------------------------------#
|
|
208
|
#----------------------------------------------------#
|
|
207
|
for key, value in query.items():
|
|
209
|
for key, value in query.items():
|
|
208
|
if value is not None and not key in self.list:
|
|
210
|
if value is not None and not key in self.list:
|
|
209
|
self.dict['fq_list'].append(str(key)+':"'+str(value)+'"')
|
|
211
|
self.dict['fq_list'].append(str(key)+':"'+str(value)+'"')
|
|
210
|
else:
|
|
212
|
else:
|
|
211
|
return '"query" must be <dict>'
|
|
213
|
return '"query" must be <dict>'
|
|
212
|
|
|
214
|
|
|
213
|
return getattr(self.ckan.action, 'package_search')(include_private=True, **self.dict)
|
|
215
|
return getattr(self.ckan.action, 'package_search')(include_private=True, **self.dict)
|
|
214
|
|
|
216
|
|
|
215
|
elif type_option == 'resource':
|
|
217
|
elif type_option == 'resource':
|
|
216
|
for key1, value1 in kwargs.items():
|
|
218
|
for key1, value1 in kwargs.items():
|
|
217
|
if key1 != 'fields':
|
|
219
|
if key1 != 'fields':
|
|
218
|
self.dict[key1] = value1
|
|
220
|
self.dict[key1] = value1
|
|
219
|
|
|
221
|
|
|
220
|
if query is not None:
|
|
222
|
if query is not None:
|
|
221
|
if type(query) is dict:
|
|
223
|
if type(query) is dict:
|
|
222
|
#----------------------------------------------------#
|
|
224
|
#----------------------------------------------------#
|
|
223
|
if 'file_date_min' in query:
|
|
225
|
if 'file_date_min' in query:
|
|
224
|
if type(query['file_date_min']) is str:
|
|
226
|
if type(query['file_date_min']) is str:
|
|
225
|
try:
|
|
227
|
try:
|
|
226
|
datetime.strptime(query['file_date_min'], '%Y-%m-%d')
|
|
228
|
datetime.strptime(query['file_date_min'], '%Y-%m-%d')
|
|
227
|
if len(query['file_date_min']) != 10:
|
|
229
|
if len(query['file_date_min']) != 10:
|
|
228
|
return '"file_date_min", must be: <YYYY-MM-DD>'
|
|
230
|
return '"file_date_min", must be: <YYYY-MM-DD>'
|
|
229
|
except:
|
|
231
|
except:
|
|
230
|
return '"file_date_min" incorrect: "%s"' % (query['file_date_min'])
|
|
232
|
return '"file_date_min" incorrect: "%s"' % (query['file_date_min'])
|
|
231
|
else:
|
|
233
|
else:
|
|
232
|
return '"file_date_min" must be <str>'
|
|
234
|
return '"file_date_min" must be <str>'
|
|
233
|
#----------------------------------------------------#
|
|
235
|
#----------------------------------------------------#
|
|
234
|
if 'file_date_max' in query:
|
|
236
|
if 'file_date_max' in query:
|
|
235
|
if type(query['file_date_max']) is str:
|
|
237
|
if type(query['file_date_max']) is str:
|
|
236
|
try:
|
|
238
|
try:
|
|
237
|
datetime.strptime(query['file_date_max'], '%Y-%m-%d')
|
|
239
|
datetime.strptime(query['file_date_max'], '%Y-%m-%d')
|
|
238
|
if len(query['file_date_max']) != 10:
|
|
240
|
if len(query['file_date_max']) != 10:
|
|
239
|
return '"file_date_max", must be: <YYYY-MM-DD>'
|
|
241
|
return '"file_date_max", must be: <YYYY-MM-DD>'
|
|
240
|
|
|
242
|
|
|
241
|
if 'file_date_min' in query:
|
|
243
|
if 'file_date_min' in query:
|
|
242
|
if query['file_date_min'] > query['file_date_max']:
|
|
244
|
if query['file_date_min'] > query['file_date_max']:
|
|
243
|
return '"file_date_max" must be greater than "file_date_min"'
|
|
245
|
return '"file_date_max" must be greater than "file_date_min"'
|
|
244
|
except:
|
|
246
|
except:
|
|
245
|
return '"file_date_max" incorrect: "%s"' % (query['file_date_max'])
|
|
247
|
return '"file_date_max" incorrect: "%s"' % (query['file_date_max'])
|
|
246
|
else:
|
|
248
|
else:
|
|
247
|
return '"file_date_max" must be <str>'
|
|
249
|
return '"file_date_max" must be <str>'
|
|
248
|
#----------------------------------------------------#
|
|
250
|
#----------------------------------------------------#
|
|
249
|
self.dict['query'] = query
|
|
251
|
self.dict['query'] = query
|
|
250
|
else:
|
|
252
|
else:
|
|
251
|
return '"query" must be <dict>'
|
|
253
|
return '"query" must be <dict>'
|
|
252
|
return getattr(self.ckan.action, 'resources_search')(**self.dict)
|
|
254
|
return getattr(self.ckan.action, 'resources_search')(**self.dict)
|
|
253
|
|
|
255
|
|
|
254
|
elif type_option == 'tag':
|
|
256
|
elif type_option == 'tag':
|
|
255
|
for key1, value1 in kwargs.items():
|
|
257
|
for key1, value1 in kwargs.items():
|
|
256
|
if key1 != 'fields':
|
|
258
|
if key1 != 'fields':
|
|
257
|
self.dict[key1] = value1
|
|
259
|
self.dict[key1] = value1
|
|
258
|
|
|
260
|
|
|
259
|
if not 'vocabulary_id' in kwargs:
|
|
261
|
if not 'vocabulary_id' in kwargs:
|
|
260
|
print('Missing "vocabulary_id" value: tags that don’t belong to any vocabulary')
|
|
262
|
print('Missing "vocabulary_id" value: tags that don’t belong to any vocabulary')
|
|
261
|
else:
|
|
263
|
else:
|
|
262
|
print('Only tags that belong to "{}" vocabulary'.format(kwargs['vocabulary_id']))
|
|
264
|
print('Only tags that belong to "{}" vocabulary'.format(kwargs['vocabulary_id']))
|
|
263
|
|
|
265
|
|
|
264
|
if query is not None:
|
|
266
|
if query is not None:
|
|
265
|
if type(query) is dict:
|
|
267
|
if type(query) is dict:
|
|
266
|
if 'search' in query:
|
|
268
|
if 'search' in query:
|
|
267
|
if type(query['search']) is list or type(query['search']) is str:
|
|
269
|
if type(query['search']) is list or type(query['search']) is str:
|
|
268
|
self.dict['query'] = query['search']
|
|
270
|
self.dict['query'] = query['search']
|
|
269
|
else:
|
|
271
|
else:
|
|
270
|
return '"search" must be <list> or <str>'
|
|
272
|
return '"search" must be <list> or <str>'
|
|
271
|
else:
|
|
273
|
else:
|
|
272
|
return '"query" must be <dict>'
|
|
274
|
return '"query" must be <dict>'
|
|
273
|
return getattr(self.ckan.action, 'tag_search')(**self.dict)
|
|
275
|
return getattr(self.ckan.action, 'tag_search')(**self.dict)
|
|
274
|
|
|
276
|
|
|
275
|
else:
|
|
277
|
else:
|
|
276
|
return 'ERROR:: "type_option = %s" is not accepted' % (type_option)
|
|
278
|
return 'ERROR:: "type_option = %s" is not accepted' % (type_option)
|
|
277
|
|
|
279
|
|
|
278
|
except:
|
|
280
|
except:
|
|
279
|
_, exc_value, _ = sys.exc_info()
|
|
281
|
_, exc_value, _ = sys.exc_info()
|
|
280
|
return exc_value
|
|
282
|
return exc_value
|
|
281
|
else:
|
|
283
|
else:
|
|
282
|
return 'ERROR:: "type_option" must be <str>'
|
|
284
|
return 'ERROR:: "type_option" must be <str>'
|
|
283
|
|
|
285
|
|
|
284
|
def create(self, type_option, select=None, **kwargs):
|
|
286
|
def create(self, type_option, select=None, **kwargs):
|
|
285
|
'''
|
|
287
|
'''
|
|
286
|
FINALIDAD:
|
|
288
|
FINALIDAD:
|
|
287
|
Funcion personalizada para crear.
|
|
289
|
Funcion personalizada para crear.
|
|
288
|
|
|
290
|
|
|
289
|
PARAMETROS DISPONIBLES:
|
|
291
|
PARAMETROS DISPONIBLES:
|
|
290
|
CONSULTAR: "GUIA DE SCRIPT.pdf"
|
|
292
|
CONSULTAR: "GUIA DE SCRIPT.pdf"
|
|
291
|
|
|
293
|
|
|
292
|
ESTRUCTURA:
|
|
294
|
ESTRUCTURA:
|
|
293
|
<access_name>.create(type_option = <class 'str'>, param_1 = <class 'param_1'>, ...)
|
|
295
|
<access_name>.create(type_option = <class 'str'>, param_1 = <class 'param_1'>, ...)
|
|
294
|
'''
|
|
296
|
'''
|
|
295
|
if type(type_option) is str:
|
|
297
|
if type(type_option) is str:
|
|
296
|
try:
|
|
298
|
try:
|
|
297
|
if type_option == 'dataset':
|
|
299
|
if type_option == 'dataset':
|
|
298
|
return getattr(self.ckan.action, 'package_create')(**kwargs)
|
|
300
|
return getattr(self.ckan.action, 'package_create')(**kwargs)
|
|
299
|
if type_option == 'resource':
|
|
301
|
if type_option == 'resource':
|
|
300
|
return resource.resource_create(self, **kwargs)
|
|
302
|
return resource.resource_create(self, **kwargs)
|
|
301
|
elif type_option == 'project':
|
|
303
|
elif type_option == 'project':
|
|
302
|
return getattr(self.ckan.action, 'organization_create')(**kwargs)
|
|
304
|
return getattr(self.ckan.action, 'organization_create')(**kwargs)
|
|
303
|
elif type_option == 'member':
|
|
305
|
elif type_option == 'member':
|
|
304
|
return getattr(self.ckan.action, 'organization_member_create')(**kwargs)
|
|
306
|
return getattr(self.ckan.action, 'organization_member_create')(**kwargs)
|
|
305
|
elif type_option == 'collaborator':
|
|
307
|
elif type_option == 'collaborator':
|
|
306
|
return getattr(self.ckan.action, 'package_collaborator_create')(**kwargs)
|
|
308
|
return getattr(self.ckan.action, 'package_collaborator_create')(**kwargs)
|
|
307
|
elif type_option == 'vocabulary':
|
|
309
|
elif type_option == 'vocabulary':
|
|
308
|
return getattr(self.ckan.action, 'vocabulary_create')(**kwargs)
|
|
310
|
return getattr(self.ckan.action, 'vocabulary_create')(**kwargs)
|
|
309
|
elif type_option == 'tag':
|
|
311
|
elif type_option == 'tag':
|
|
310
|
return getattr(self.ckan.action, 'tag_create')(**kwargs)
|
|
312
|
return getattr(self.ckan.action, 'tag_create')(**kwargs)
|
|
311
|
elif type_option == 'user':
|
|
313
|
elif type_option == 'user':
|
|
312
|
return getattr(self.ckan.action, 'user_create')(**kwargs)
|
|
314
|
return getattr(self.ckan.action, 'user_create')(**kwargs)
|
|
313
|
elif type_option == 'views':
|
|
315
|
elif type_option == 'views':
|
|
314
|
if 'resource' == select:
|
|
316
|
if 'resource' == select:
|
|
315
|
self.list = ['package']
|
|
317
|
self.list = ['package']
|
|
316
|
for key1, value1 in kwargs.items():
|
|
318
|
for key1, value1 in kwargs.items():
|
|
317
|
if not key1 in self.list:
|
|
319
|
if not key1 in self.list:
|
|
318
|
self.dict[key1] = value1
|
|
320
|
self.dict[key1] = value1
|
|
319
|
return getattr(self.ckan.action, 'resource_create_default_resource_views')(**self.dict)
|
|
321
|
return getattr(self.ckan.action, 'resource_create_default_resource_views')(**self.dict)
|
|
320
|
elif 'dataset' == select:
|
|
322
|
elif 'dataset' == select:
|
|
321
|
return getattr(self.ckan.action, 'package_create_default_resource_views')(**kwargs)
|
|
323
|
return getattr(self.ckan.action, 'package_create_default_resource_views')(**kwargs)
|
|
322
|
else:
|
|
324
|
else:
|
|
323
|
return 'ERROR:: "select = %s" is not accepted' % (select)
|
|
325
|
return 'ERROR:: "select = %s" is not accepted' % (select)
|
|
324
|
else:
|
|
326
|
else:
|
|
325
|
return 'ERROR:: "type_option = %s" is not accepted' % (type_option)
|
|
327
|
return 'ERROR:: "type_option = %s" is not accepted' % (type_option)
|
|
326
|
except:
|
|
328
|
except:
|
|
327
|
_, exc_value, _ = sys.exc_info()
|
|
329
|
_, exc_value, _ = sys.exc_info()
|
|
328
|
return exc_value
|
|
330
|
return exc_value
|
|
329
|
else:
|
|
331
|
else:
|
|
330
|
return 'ERROR:: "type_option" must be <str>'
|
|
332
|
return 'ERROR:: "type_option" must be <str>'
|
|
331
|
|
|
333
|
|
|
332
|
def patch(self, type_option, **kwargs):
|
|
334
|
def patch(self, type_option, **kwargs):
|
|
333
|
'''
|
|
335
|
'''
|
|
334
|
FINALIDAD:
|
|
336
|
FINALIDAD:
|
|
335
|
Funciones personalizadas para actualizar
|
|
337
|
Funciones personalizadas para actualizar
|
|
336
|
|
|
338
|
|
|
337
|
PARAMETROS DISPONIBLES:
|
|
339
|
PARAMETROS DISPONIBLES:
|
|
338
|
CONSULTAR: "GUIA DE SCRIPT.pdf"
|
|
340
|
CONSULTAR: "GUIA DE SCRIPT.pdf"
|
|
339
|
|
|
341
|
|
|
340
|
ESTRUCTURA:
|
|
342
|
ESTRUCTURA:
|
|
341
|
<access_name>.patch(type_option = <class 'str'>, param_1 = <class 'param_1'>, ...)
|
|
343
|
<access_name>.patch(type_option = <class 'str'>, param_1 = <class 'param_1'>, ...)
|
|
342
|
'''
|
|
344
|
'''
|
|
343
|
if type(type_option) is str:
|
|
345
|
if type(type_option) is str:
|
|
344
|
try:
|
|
346
|
try:
|
|
345
|
if type_option == 'dataset':
|
|
347
|
if type_option == 'dataset':
|
|
346
|
#Agregar que solo se debe modificar parámetros del Dataset y que no incluya Resources
|
|
348
|
#Agregar que solo se debe modificar parámetros del Dataset y que no incluya Resources
|
|
347
|
return getattr(self.ckan.action, 'package_patch')(**kwargs)
|
|
349
|
return getattr(self.ckan.action, 'package_patch')(**kwargs)
|
|
348
|
elif type_option == 'project':
|
|
350
|
elif type_option == 'project':
|
|
349
|
return getattr(self.ckan.action, 'organization_patch')(**kwargs)
|
|
351
|
return getattr(self.ckan.action, 'organization_patch')(**kwargs)
|
|
350
|
elif type_option == 'resource':
|
|
352
|
elif type_option == 'resource':
|
|
351
|
return resource.resource_patch(self, **kwargs)
|
|
353
|
return resource.resource_patch(self, **kwargs)
|
|
352
|
elif type_option == 'member':
|
|
354
|
elif type_option == 'member':
|
|
353
|
return getattr(self.ckan.action, 'organization_member_create')(**kwargs)
|
|
355
|
return getattr(self.ckan.action, 'organization_member_create')(**kwargs)
|
|
354
|
elif type_option == 'collaborator':
|
|
356
|
elif type_option == 'collaborator':
|
|
355
|
return getattr(self.ckan.action, 'package_collaborator_create')(**kwargs)
|
|
357
|
return getattr(self.ckan.action, 'package_collaborator_create')(**kwargs)
|
|
356
|
else:
|
|
358
|
else:
|
|
357
|
return 'ERROR:: "type_option = %s" is not accepted' % (type_option)
|
|
359
|
return 'ERROR:: "type_option = %s" is not accepted' % (type_option)
|
|
358
|
except:
|
|
360
|
except:
|
|
359
|
_, exc_value, _ = sys.exc_info()
|
|
361
|
_, exc_value, _ = sys.exc_info()
|
|
360
|
return exc_value
|
|
362
|
return exc_value
|
|
361
|
else:
|
|
363
|
else:
|
|
362
|
return 'ERROR:: "type_option" must be <str>'
|
|
364
|
return 'ERROR:: "type_option" must be <str>'
|
|
363
|
|
|
365
|
|
|
364
|
def delete(self, type_option, select=None, **kwargs):
|
|
366
|
def delete(self, type_option, select=None, **kwargs):
|
|
365
|
'''
|
|
367
|
'''
|
|
366
|
FINALIDAD:
|
|
368
|
FINALIDAD:
|
|
367
|
Función personalizada para eliminar y/o purgar.
|
|
369
|
Función personalizada para eliminar y/o purgar.
|
|
368
|
|
|
370
|
|
|
369
|
PARAMETROS DISPONIBLES:
|
|
371
|
PARAMETROS DISPONIBLES:
|
|
370
|
CONSULTAR: "GUIA DE SCRIPT.pdf"
|
|
372
|
CONSULTAR: "GUIA DE SCRIPT.pdf"
|
|
371
|
|
|
373
|
|
|
372
|
ESTRUCTURA:
|
|
374
|
ESTRUCTURA:
|
|
373
|
<access_name>.delete(type_option = <class 'str'>, param_1 = <class 'param_1'>, ...)
|
|
375
|
<access_name>.delete(type_option = <class 'str'>, param_1 = <class 'param_1'>, ...)
|
|
374
|
'''
|
|
376
|
'''
|
|
375
|
if type(type_option) is str:
|
|
377
|
if type(type_option) is str:
|
|
376
|
try:
|
|
378
|
try:
|
|
377
|
if type_option == 'dataset':
|
|
379
|
if type_option == 'dataset':
|
|
378
|
if select is None:
|
|
380
|
if select is None:
|
|
379
|
return 'ERROR:: "select" must not be "None"'
|
|
381
|
return 'ERROR:: "select" must not be "None"'
|
|
380
|
else:
|
|
382
|
else:
|
|
381
|
if 'delete' == select:
|
|
383
|
if 'delete' == select:
|
|
382
|
return getattr(self.ckan.action, 'package_delete')(**kwargs)
|
|
384
|
return getattr(self.ckan.action, 'package_delete')(**kwargs)
|
|
383
|
elif 'purge' == select:
|
|
385
|
elif 'purge' == select:
|
|
384
|
return getattr(self.ckan.action, 'dataset_purge')(**kwargs)
|
|
386
|
return getattr(self.ckan.action, 'dataset_purge')(**kwargs)
|
|
385
|
else:
|
|
387
|
else:
|
|
386
|
return 'ERROR:: "select = %s" is not accepted' % (select)
|
|
388
|
return 'ERROR:: "select = %s" is not accepted' % (select)
|
|
387
|
elif type_option == 'project':
|
|
389
|
elif type_option == 'project':
|
|
388
|
if select is None:
|
|
390
|
if select is None:
|
|
389
|
return 'ERROR:: "select" must not be "None"'
|
|
391
|
return 'ERROR:: "select" must not be "None"'
|
|
390
|
else:
|
|
392
|
else:
|
|
391
|
if 'delete' == select:
|
|
393
|
if 'delete' == select:
|
|
392
|
return getattr(self.ckan.action, 'organization_delete')(**kwargs)
|
|
394
|
return getattr(self.ckan.action, 'organization_delete')(**kwargs)
|
|
393
|
elif 'purge' == select:
|
|
395
|
elif 'purge' == select:
|
|
394
|
return getattr(self.ckan.action, 'organization_purge')(**kwargs)
|
|
396
|
return getattr(self.ckan.action, 'organization_purge')(**kwargs)
|
|
395
|
else:
|
|
397
|
else:
|
|
396
|
return 'ERROR:: "select = %s" is not accepted' % (select)
|
|
398
|
return 'ERROR:: "select = %s" is not accepted' % (select)
|
|
397
|
elif type_option == 'resource':
|
|
399
|
elif type_option == 'resource':
|
|
398
|
if select is None:
|
|
400
|
if select is None:
|
|
399
|
return 'ERROR:: "select" must not be "None"'
|
|
401
|
return 'ERROR:: "select" must not be "None"'
|
|
400
|
else:
|
|
402
|
else:
|
|
401
|
return resource.resource_delete(self, select, **kwargs)
|
|
403
|
return resource.resource_delete(self, select, **kwargs)
|
|
402
|
elif type_option == 'vocabulary':
|
|
404
|
elif type_option == 'vocabulary':
|
|
403
|
return getattr(self.ckan.action, 'vocabulary_delete')(**kwargs)
|
|
405
|
return getattr(self.ckan.action, 'vocabulary_delete')(**kwargs)
|
|
404
|
elif type_option == 'tag':
|
|
406
|
elif type_option == 'tag':
|
|
405
|
return getattr(self.ckan.action, 'tag_delete')(**kwargs)
|
|
407
|
return getattr(self.ckan.action, 'tag_delete')(**kwargs)
|
|
406
|
elif type_option == 'user':
|
|
408
|
elif type_option == 'user':
|
|
407
|
return getattr(self.ckan.action, 'user_delete')(**kwargs)
|
|
409
|
return getattr(self.ckan.action, 'user_delete')(**kwargs)
|
|
408
|
else:
|
|
410
|
else:
|
|
409
|
return 'ERROR:: "type_option = %s" is not accepted' % (type_option)
|
|
411
|
return 'ERROR:: "type_option = %s" is not accepted' % (type_option)
|
|
410
|
except:
|
|
412
|
except:
|
|
411
|
_, exc_value, _ = sys.exc_info()
|
|
413
|
_, exc_value, _ = sys.exc_info()
|
|
412
|
return exc_value
|
|
414
|
return exc_value
|
|
413
|
else:
|
|
415
|
else:
|
|
414
|
return 'ERROR:: "type_option" must be <str>'
|
|
416
|
return 'ERROR:: "type_option" must be <str>'
|
|
415
|
|
|
417
|
|
|
416
|
def download_files(self, id, processes=1, path=os.path.expanduser("~"), **kwargs):
|
|
418
|
def download(self, id, processes=1, path=os.path.expanduser("~"), **kwargs):
|
|
417
|
'''
|
|
419
|
'''
|
|
418
|
FINALIDAD:
|
|
420
|
FINALIDAD:
|
|
419
|
Funcion personalizada avanzada para la descarga de archivos existentes de un(os) dataset(s).
|
|
421
|
Funcion personalizada avanzada para la descarga de archivos existentes de un(os) dataset(s).
|
|
420
|
|
|
422
|
|
|
421
|
PARAMETROS DISPONIBLES:
|
|
423
|
PARAMETROS DISPONIBLES:
|
|
422
|
CONSULTAR: "GUIA DE SCRIPT.pdf"
|
|
424
|
CONSULTAR: "GUIA DE SCRIPT.pdf"
|
|
423
|
|
|
425
|
|
|
424
|
ESTRUCTURA:
|
|
426
|
ESTRUCTURA:
|
|
425
|
<access_name>.download_files(id = <class 'str' or 'list'>, param_1 = <class 'param_1'>, ...)
|
|
427
|
<access_name>.download(id = <class 'str' or 'list'>, param_1 = <class 'param_1'>, ...)
|
|
426
|
'''
|
|
428
|
'''
|
|
427
|
#------------------ PATH ----------------------#
|
|
429
|
#------------------ PATH ----------------------#
|
|
428
|
if isinstance(path, str):
|
|
430
|
if isinstance(path, str):
|
|
429
|
if os.path.isdir(path):
|
|
431
|
if os.path.isdir(path):
|
|
430
|
if not path.endswith(os.sep):
|
|
432
|
if not path.endswith(os.sep):
|
|
431
|
path = path + os.sep
|
|
433
|
path = path + os.sep
|
|
432
|
test_txt = path + datetime.now().strftime("%Y_%m_%d_%H_%M_%S_%f")+'.txt'
|
|
434
|
test_txt = path + datetime.now().strftime("%Y_%m_%d_%H_%M_%S_%f")+'.txt'
|
|
433
|
try:
|
|
435
|
try:
|
|
434
|
file_txt = open(test_txt, 'w')
|
|
436
|
file_txt = open(test_txt, 'w')
|
|
435
|
file_txt.close()
|
|
437
|
file_txt.close()
|
|
436
|
os.remove(test_txt)
|
|
438
|
os.remove(test_txt)
|
|
437
|
except:
|
|
439
|
except:
|
|
438
|
return 'ERROR:: Access denied, you are not authorized to write files: "%s"' % (path)
|
|
440
|
return 'ERROR:: Access denied, you are not authorized to write files: "%s"' % (path)
|
|
439
|
else:
|
|
441
|
else:
|
|
440
|
return 'ERROR:: "path" does not exist'
|
|
442
|
return 'ERROR:: "path" does not exist'
|
|
441
|
else:
|
|
443
|
else:
|
|
442
|
return 'ERROR:: "path" must be: <class "str">'
|
|
444
|
return 'ERROR:: "path" must be: <class "str">'
|
|
443
|
|
|
445
|
|
|
444
|
#------------------ PROCESSES -----------------#
|
|
446
|
#------------------ PROCESSES -----------------#
|
|
445
|
if not isinstance(processes, int):
|
|
447
|
if not isinstance(processes, int):
|
|
446
|
return 'ERROR:: "processes" must be: <class "int">'
|
|
448
|
return 'ERROR:: "processes" must be: <class "int">'
|
|
447
|
|
|
449
|
|
|
448
|
#------------------ ID OR NAME ----------------#
|
|
450
|
#------------------ ID OR NAME ----------------#
|
|
449
|
if isinstance(id, str):
|
|
451
|
if isinstance(id, str):
|
|
450
|
id = [id]
|
|
452
|
id = [id]
|
|
451
|
elif isinstance(id, list):
|
|
453
|
elif isinstance(id, list):
|
|
452
|
id = list(map(str, id))
|
|
454
|
id = list(map(str, id))
|
|
453
|
else:
|
|
455
|
else:
|
|
454
|
return 'ERROR:: dataset "id" must be: <class "str" or "list">'
|
|
456
|
return 'ERROR:: dataset "id" must be: <class "str" or "list">'
|
|
455
|
#----------------------------------------------#
|
|
457
|
#----------------------------------------------#
|
|
456
|
arguments = {
|
|
458
|
arguments = {
|
|
457
|
'--apikey': self.Authorization,
|
|
459
|
'--apikey': self.Authorization,
|
|
458
|
'--ckan-user': None,
|
|
460
|
'--ckan-user': None,
|
|
459
|
'--config': None,
|
|
461
|
'--config': None,
|
|
460
|
'--datapackages': path,
|
|
462
|
'--datapackages': path,
|
|
461
|
'--datastore-fields': False,
|
|
463
|
'--datastore-fields': False,
|
|
462
|
'--get-request': False,
|
|
464
|
'--get-request': False,
|
|
463
|
'--insecure': not self.verify,
|
|
465
|
'--insecure': not self.verify,
|
|
464
|
'--processes': str(processes),
|
|
466
|
'--processes': str(processes),
|
|
465
|
'--quiet': False,
|
|
467
|
'--quiet': False,
|
|
466
|
'--remote': self.url,
|
|
468
|
'--remote': self.url,
|
|
467
|
'--worker': False,
|
|
469
|
'--worker': False,
|
|
468
|
#'--log': 'log.txt',
|
|
470
|
#'--log': 'log.txt',
|
|
469
|
#'--all': False,
|
|
471
|
#'--all': False,
|
|
470
|
#'--gzip': False,
|
|
472
|
#'--gzip': False,
|
|
471
|
#'--output': None,
|
|
473
|
#'--output': None,
|
|
472
|
#'--max-records': None,
|
|
474
|
#'--max-records': None,
|
|
473
|
#'--output-json': False,
|
|
475
|
#'--output-json': False,
|
|
474
|
#'--output-jsonl': False,
|
|
476
|
#'--output-jsonl': False,
|
|
475
|
#'--create-only': False,
|
|
477
|
#'--create-only': False,
|
|
476
|
#'--help': False,
|
|
478
|
#'--help': False,
|
|
477
|
#'--input': None,
|
|
479
|
#'--input': None,
|
|
478
|
#'--input-json': False,
|
|
480
|
#'--input-json': False,
|
|
479
|
#'--start-record': '1',
|
|
481
|
#'--start-record': '1',
|
|
480
|
#'--update-only': False,
|
|
482
|
#'--update-only': False,
|
|
481
|
#'--upload-logo': False,
|
|
483
|
#'--upload-logo': False,
|
|
482
|
#'--upload-resources': False,
|
|
484
|
#'--upload-resources': False,
|
|
483
|
#'--version': False,
|
|
485
|
#'--version': False,
|
|
484
|
'ID_OR_NAME': id,
|
|
486
|
'ID_OR_NAME': id,
|
|
485
|
'datasets': True,
|
|
487
|
'datasets': True,
|
|
486
|
'dump': True,
|
|
488
|
'dump': True,
|
|
487
|
#'ACTION_NAME': None,
|
|
489
|
#'ACTION_NAME': None,
|
|
488
|
#'KEY:JSON': [],
|
|
490
|
#'KEY:JSON': [],
|
|
489
|
#'KEY=STRING': [],
|
|
491
|
#'KEY=STRING': [],
|
|
490
|
#'KEY@FILE': [],
|
|
492
|
#'KEY@FILE': [],
|
|
491
|
#'action': False,
|
|
493
|
#'action': False,
|
|
492
|
#'delete': False,
|
|
494
|
#'delete': False,
|
|
493
|
#'groups': False,
|
|
495
|
#'groups': False,
|
|
494
|
#'load': False,
|
|
496
|
#'load': False,
|
|
495
|
#'organizations': False,
|
|
497
|
#'organizations': False,
|
|
496
|
#'related': False,
|
|
498
|
#'related': False,
|
|
497
|
#'search': False,
|
|
499
|
#'search': False,
|
|
498
|
#'users': False
|
|
500
|
#'users': False
|
|
499
|
}
|
|
501
|
}
|
|
500
|
return logic_download.dump_things_change(self.ckan, 'datasets', arguments, **kwargs)
No newline at end of file
|
|
502
|
return download.dump_things_change(self.ckan, 'datasets', arguments, **kwargs)
No newline at end of file
|