gazu 0.10.20__tar.gz → 0.10.21__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.
- {gazu-0.10.20 → gazu-0.10.21}/PKG-INFO +1 -1
- {gazu-0.10.20 → gazu-0.10.21}/gazu/__init__.py +2 -16
- gazu-0.10.21/gazu/__version__.py +1 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu/client.py +229 -36
- {gazu-0.10.20 → gazu-0.10.21}/gazu/events.py +6 -4
- {gazu-0.10.20 → gazu-0.10.21}/gazu/sync.py +3 -3
- {gazu-0.10.20 → gazu-0.10.21}/gazu.egg-info/PKG-INFO +1 -1
- {gazu-0.10.20 → gazu-0.10.21}/tests/test_client.py +6 -2
- gazu-0.10.20/gazu/__version__.py +0 -1
- {gazu-0.10.20 → gazu-0.10.21}/LICENSE +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/README.rst +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu/asset.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu/cache.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu/casting.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu/concept.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu/context.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu/edit.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu/encoder.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu/entity.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu/exception.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu/files.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu/helpers.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu/person.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu/playlist.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu/project.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu/scene.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu/shot.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu/sorting.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu/task.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu/user.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu.egg-info/SOURCES.txt +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu.egg-info/dependency_links.txt +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu.egg-info/not-zip-safe +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu.egg-info/requires.txt +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/gazu.egg-info/top_level.txt +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/pyproject.toml +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/setup.cfg +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/setup.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/tests/test_asset.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/tests/test_cache.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/tests/test_casting.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/tests/test_concept.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/tests/test_context.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/tests/test_edit.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/tests/test_entity.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/tests/test_files.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/tests/test_helpers.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/tests/test_person.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/tests/test_playlist.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/tests/test_project.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/tests/test_scene.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/tests/test_shot.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/tests/test_sync.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/tests/test_task.py +0 -0
- {gazu-0.10.20 → gazu-0.10.21}/tests/test_user.py +0 -0
|
@@ -87,22 +87,8 @@ def log_out(client=raw.default_client):
|
|
|
87
87
|
return tokens
|
|
88
88
|
|
|
89
89
|
|
|
90
|
-
def
|
|
91
|
-
|
|
92
|
-
if "refresh_token" in client.tokens:
|
|
93
|
-
headers["Authorization"] = "Bearer %s" % client.tokens["refresh_token"]
|
|
94
|
-
|
|
95
|
-
response = client.session.get(
|
|
96
|
-
raw.get_full_url("auth/refresh-token", client=client),
|
|
97
|
-
headers=headers,
|
|
98
|
-
)
|
|
99
|
-
raw.check_status(response, "auth/refresh-token")
|
|
100
|
-
|
|
101
|
-
tokens = response.json()
|
|
102
|
-
|
|
103
|
-
client.tokens["access_token"] = tokens["access_token"]
|
|
104
|
-
|
|
105
|
-
return tokens
|
|
90
|
+
def refresh_access_token(client=raw.default_client):
|
|
91
|
+
return client.refresh_access_token()
|
|
106
92
|
|
|
107
93
|
|
|
108
94
|
def get_event_host(client=raw.default_client):
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.10.21"
|
|
@@ -36,32 +36,107 @@ class KitsuClient(object):
|
|
|
36
36
|
host,
|
|
37
37
|
ssl_verify=True,
|
|
38
38
|
cert=None,
|
|
39
|
-
|
|
39
|
+
use_refresh_token=True,
|
|
40
40
|
callback_not_authenticated=None,
|
|
41
|
+
tokens={"access_token": None, "refresh_token": None},
|
|
42
|
+
access_token=None,
|
|
43
|
+
refresh_token=None,
|
|
41
44
|
):
|
|
42
|
-
self.tokens =
|
|
45
|
+
self.tokens = tokens
|
|
46
|
+
if access_token:
|
|
47
|
+
self.access_token = access_token
|
|
48
|
+
if refresh_token:
|
|
49
|
+
self.refresh_token = refresh_token
|
|
50
|
+
self.use_refresh_token = use_refresh_token
|
|
51
|
+
self.callback_not_authenticated = callback_not_authenticated
|
|
52
|
+
|
|
43
53
|
self.session = requests.Session()
|
|
44
54
|
self.session.verify = ssl_verify
|
|
45
55
|
self.session.cert = cert
|
|
46
56
|
self.host = host
|
|
47
57
|
self.event_host = host
|
|
48
|
-
|
|
49
|
-
|
|
58
|
+
|
|
59
|
+
@property
|
|
60
|
+
def access_token(self):
|
|
61
|
+
return self.tokens.get("access_token", None)
|
|
62
|
+
|
|
63
|
+
@access_token.setter
|
|
64
|
+
def access_token(self, token):
|
|
65
|
+
self.tokens["access_token"] = token
|
|
66
|
+
|
|
67
|
+
@property
|
|
68
|
+
def refresh_token(self):
|
|
69
|
+
return self.tokens.get("refresh_token", None)
|
|
70
|
+
|
|
71
|
+
@refresh_token.setter
|
|
72
|
+
def refresh_token(self, token):
|
|
73
|
+
self.tokens["refresh_token"] = token
|
|
74
|
+
|
|
75
|
+
def refresh_access_token(self):
|
|
76
|
+
"""
|
|
77
|
+
Refresh access tokens for this client.
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
dict: The new access token.
|
|
81
|
+
"""
|
|
82
|
+
response = self.session.get(
|
|
83
|
+
get_full_url("auth/refresh-token", client=self),
|
|
84
|
+
headers={
|
|
85
|
+
"User-Agent": "CGWire Gazu " + __version__,
|
|
86
|
+
"Authorization": "Bearer " + self.refresh_token,
|
|
87
|
+
},
|
|
88
|
+
)
|
|
89
|
+
check_status(response, "auth/refresh-token")
|
|
90
|
+
tokens = response.json()
|
|
91
|
+
|
|
92
|
+
self.access_token = tokens["access_token"]
|
|
93
|
+
self.refresh_token = None
|
|
94
|
+
|
|
95
|
+
return tokens
|
|
96
|
+
|
|
97
|
+
def make_auth_header(self):
|
|
98
|
+
"""
|
|
99
|
+
Make headers required to authenticate.
|
|
100
|
+
|
|
101
|
+
Returns:
|
|
102
|
+
dict: Headers required to authenticate.
|
|
103
|
+
"""
|
|
104
|
+
headers = {"User-Agent": "CGWire Gazu " + __version__}
|
|
105
|
+
|
|
106
|
+
if self.access_token:
|
|
107
|
+
headers["Authorization"] = "Bearer " + self.access_token
|
|
108
|
+
|
|
109
|
+
return headers
|
|
50
110
|
|
|
51
111
|
|
|
52
112
|
def create_client(
|
|
53
113
|
host,
|
|
54
114
|
ssl_verify=True,
|
|
55
115
|
cert=None,
|
|
56
|
-
|
|
116
|
+
use_refresh_token=False,
|
|
57
117
|
callback_not_authenticated=None,
|
|
118
|
+
**kwargs
|
|
58
119
|
):
|
|
120
|
+
"""
|
|
121
|
+
Create a client with given parameters.
|
|
122
|
+
|
|
123
|
+
Args:
|
|
124
|
+
host (str): The host to use for requests.
|
|
125
|
+
ssl_verify (bool): Whether to verify SSL certificates.
|
|
126
|
+
cert (str): Path to a client certificate.
|
|
127
|
+
use_refresh_token (bool): Whether to automatically refresh tokens.
|
|
128
|
+
callback_not_authenticated (function): Function to call when not authenticated.
|
|
129
|
+
|
|
130
|
+
Returns:
|
|
131
|
+
KitsuClient: The created client.
|
|
132
|
+
"""
|
|
59
133
|
return KitsuClient(
|
|
60
134
|
host,
|
|
61
135
|
ssl_verify,
|
|
62
136
|
cert=cert,
|
|
63
|
-
|
|
137
|
+
use_refresh_token=use_refresh_token,
|
|
64
138
|
callback_not_authenticated=callback_not_authenticated,
|
|
139
|
+
**kwargs
|
|
65
140
|
)
|
|
66
141
|
|
|
67
142
|
|
|
@@ -81,8 +156,13 @@ except Exception:
|
|
|
81
156
|
|
|
82
157
|
def host_is_up(client=default_client):
|
|
83
158
|
"""
|
|
159
|
+
Check if the host is up.
|
|
160
|
+
|
|
161
|
+
Args:
|
|
162
|
+
client (KitsuClient): The client to use for the request.
|
|
163
|
+
|
|
84
164
|
Returns:
|
|
85
|
-
True if the host is up.
|
|
165
|
+
bool: True if the host is up.
|
|
86
166
|
"""
|
|
87
167
|
try:
|
|
88
168
|
response = client.session.head(client.host)
|
|
@@ -94,8 +174,12 @@ def host_is_up(client=default_client):
|
|
|
94
174
|
def host_is_valid(client=default_client):
|
|
95
175
|
"""
|
|
96
176
|
Check if the host is valid by simulating a fake login.
|
|
177
|
+
|
|
178
|
+
Args:
|
|
179
|
+
client (KitsuClient): The client to use for the request.
|
|
180
|
+
|
|
97
181
|
Returns:
|
|
98
|
-
True if the host is valid.
|
|
182
|
+
bool: True if the host is valid.
|
|
99
183
|
"""
|
|
100
184
|
if not host_is_up(client):
|
|
101
185
|
return False
|
|
@@ -107,14 +191,23 @@ def host_is_valid(client=default_client):
|
|
|
107
191
|
|
|
108
192
|
def get_host(client=default_client):
|
|
109
193
|
"""
|
|
194
|
+
Get client.host.
|
|
195
|
+
|
|
196
|
+
Args:
|
|
197
|
+
client (KitsuClient): The client to use for the request.
|
|
198
|
+
|
|
110
199
|
Returns:
|
|
111
|
-
|
|
200
|
+
str: The host of the client.
|
|
112
201
|
"""
|
|
113
202
|
return client.host
|
|
114
203
|
|
|
115
204
|
|
|
116
205
|
def get_api_url_from_host(client=default_client):
|
|
117
206
|
"""
|
|
207
|
+
Get the API url from the host.
|
|
208
|
+
|
|
209
|
+
Args:
|
|
210
|
+
client (KitsuClient): The client to use for the request.
|
|
118
211
|
Returns:
|
|
119
212
|
Zou url, retrieved from host.
|
|
120
213
|
"""
|
|
@@ -123,8 +216,14 @@ def get_api_url_from_host(client=default_client):
|
|
|
123
216
|
|
|
124
217
|
def set_host(new_host, client=default_client):
|
|
125
218
|
"""
|
|
219
|
+
Set the host for the client.
|
|
220
|
+
|
|
221
|
+
Args:
|
|
222
|
+
new_host (str): The new host to set.
|
|
223
|
+
client (KitsuClient): The client to use for the request.
|
|
224
|
+
|
|
126
225
|
Returns:
|
|
127
|
-
|
|
226
|
+
str: The new host.
|
|
128
227
|
"""
|
|
129
228
|
client.host = new_host
|
|
130
229
|
return client.host
|
|
@@ -132,16 +231,27 @@ def set_host(new_host, client=default_client):
|
|
|
132
231
|
|
|
133
232
|
def get_event_host(client=default_client):
|
|
134
233
|
"""
|
|
234
|
+
Get the host on which listening for events.
|
|
235
|
+
|
|
236
|
+
Args:
|
|
237
|
+
client (KitsuClient): The client to use for the request.
|
|
238
|
+
|
|
135
239
|
Returns:
|
|
136
|
-
|
|
240
|
+
str: The event host.
|
|
137
241
|
"""
|
|
138
242
|
return client.event_host or client.host
|
|
139
243
|
|
|
140
244
|
|
|
141
245
|
def set_event_host(new_host, client=default_client):
|
|
142
246
|
"""
|
|
247
|
+
Set the host on which listening for events.
|
|
248
|
+
|
|
249
|
+
Args:
|
|
250
|
+
new_host (str): The new host to set.
|
|
251
|
+
client (KitsuClient): The client to use for the request.
|
|
252
|
+
|
|
143
253
|
Returns:
|
|
144
|
-
|
|
254
|
+
str: The new event host.
|
|
145
255
|
"""
|
|
146
256
|
client.event_host = new_host
|
|
147
257
|
return client.event_host
|
|
@@ -153,6 +263,10 @@ def set_tokens(new_tokens, client=default_client):
|
|
|
153
263
|
|
|
154
264
|
Args:
|
|
155
265
|
new_tokens (dict): Tokens to use for authentication.
|
|
266
|
+
client (KitsuClient): The client to use for the request.
|
|
267
|
+
|
|
268
|
+
Returns:
|
|
269
|
+
dict: The stored tokens.
|
|
156
270
|
"""
|
|
157
271
|
client.tokens = new_tokens
|
|
158
272
|
return client.tokens
|
|
@@ -160,13 +274,15 @@ def set_tokens(new_tokens, client=default_client):
|
|
|
160
274
|
|
|
161
275
|
def make_auth_header(client=default_client):
|
|
162
276
|
"""
|
|
277
|
+
Make headers required to authenticate.
|
|
278
|
+
|
|
279
|
+
Args:
|
|
280
|
+
client (KitsuClient): The client to use for the request.
|
|
281
|
+
|
|
163
282
|
Returns:
|
|
164
|
-
Headers required to authenticate.
|
|
283
|
+
dict: Headers required to authenticate.
|
|
165
284
|
"""
|
|
166
|
-
|
|
167
|
-
if "access_token" in client.tokens:
|
|
168
|
-
headers["Authorization"] = "Bearer %s" % client.tokens["access_token"]
|
|
169
|
-
return headers
|
|
285
|
+
return client.make_auth_header()
|
|
170
286
|
|
|
171
287
|
|
|
172
288
|
def url_path_join(*items):
|
|
@@ -176,12 +292,17 @@ def url_path_join(*items):
|
|
|
176
292
|
|
|
177
293
|
Args:
|
|
178
294
|
items (list): Path elements
|
|
295
|
+
|
|
296
|
+
Returns:
|
|
297
|
+
str: The joined path.
|
|
179
298
|
"""
|
|
180
299
|
return "/".join([item.lstrip("/").rstrip("/") for item in items])
|
|
181
300
|
|
|
182
301
|
|
|
183
302
|
def get_full_url(path, client=default_client):
|
|
184
303
|
"""
|
|
304
|
+
Join host url with given path.
|
|
305
|
+
|
|
185
306
|
Args:
|
|
186
307
|
path (str): The path to integrate to host url.
|
|
187
308
|
|
|
@@ -219,6 +340,12 @@ def get(path, json_response=True, params=None, client=default_client):
|
|
|
219
340
|
"""
|
|
220
341
|
Run a get request toward given path for configured host.
|
|
221
342
|
|
|
343
|
+
Args:
|
|
344
|
+
path (str): The path to query.
|
|
345
|
+
json_response (bool): Whether to return a json response.
|
|
346
|
+
params (dict): The parameters to pass to the request.
|
|
347
|
+
client (KitsuClient): The client to use for the request.
|
|
348
|
+
|
|
222
349
|
Returns:
|
|
223
350
|
The request result.
|
|
224
351
|
"""
|
|
@@ -243,6 +370,11 @@ def post(path, data, client=default_client):
|
|
|
243
370
|
"""
|
|
244
371
|
Run a post request toward given path for configured host.
|
|
245
372
|
|
|
373
|
+
Args:
|
|
374
|
+
path (str): The path to query.
|
|
375
|
+
data (dict): The data to post.
|
|
376
|
+
client (KitsuClient): The client to use for the request.
|
|
377
|
+
|
|
246
378
|
Returns:
|
|
247
379
|
The request result.
|
|
248
380
|
"""
|
|
@@ -270,6 +402,11 @@ def put(path, data, client=default_client):
|
|
|
270
402
|
"""
|
|
271
403
|
Run a put request toward given path for configured host.
|
|
272
404
|
|
|
405
|
+
Args:
|
|
406
|
+
path (str): The path to query.
|
|
407
|
+
data (dict): The data to put.
|
|
408
|
+
client (KitsuClient): The client to use for the request.
|
|
409
|
+
|
|
273
410
|
Returns:
|
|
274
411
|
The request result.
|
|
275
412
|
"""
|
|
@@ -291,6 +428,11 @@ def delete(path, params=None, client=default_client):
|
|
|
291
428
|
"""
|
|
292
429
|
Run a delete request toward given path for configured host.
|
|
293
430
|
|
|
431
|
+
Args:
|
|
432
|
+
path (str): The path to query.
|
|
433
|
+
params (dict): The parameters to pass to the request.
|
|
434
|
+
client (KitsuClient): The client to use for the request.
|
|
435
|
+
|
|
294
436
|
Returns:
|
|
295
437
|
The request result.
|
|
296
438
|
"""
|
|
@@ -320,7 +462,7 @@ def get_message_from_response(
|
|
|
320
462
|
default_message: str - An optional default value to revert to if no message is detected.
|
|
321
463
|
|
|
322
464
|
Returns:
|
|
323
|
-
The message
|
|
465
|
+
str: The message to display to the user.
|
|
324
466
|
"""
|
|
325
467
|
message = default_message
|
|
326
468
|
message_json = response.json()
|
|
@@ -340,6 +482,8 @@ def check_status(request, path, client=None):
|
|
|
340
482
|
|
|
341
483
|
Args:
|
|
342
484
|
request (Request): The request to validate.
|
|
485
|
+
path (str): The path of the request.
|
|
486
|
+
client (KitsuClient): The client to use for the request.
|
|
343
487
|
|
|
344
488
|
Returns:
|
|
345
489
|
int: Status code
|
|
@@ -369,19 +513,18 @@ def check_status(request, path, client=None):
|
|
|
369
513
|
)
|
|
370
514
|
elif status_code in [401, 422]:
|
|
371
515
|
try:
|
|
372
|
-
if
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
516
|
+
if (
|
|
517
|
+
client
|
|
518
|
+
and client.refresh_token
|
|
519
|
+
and client.use_refresh_token
|
|
520
|
+
and request.json()["message"] == "Signature has expired"
|
|
521
|
+
):
|
|
522
|
+
client.refresh_access_token()
|
|
377
523
|
return status_code, True
|
|
378
524
|
else:
|
|
379
525
|
raise NotAuthenticatedException(path)
|
|
380
526
|
except NotAuthenticatedException:
|
|
381
|
-
if
|
|
382
|
-
client is not None
|
|
383
|
-
and client.callback_not_authenticated is not None
|
|
384
|
-
):
|
|
527
|
+
if client and client.callback_not_authenticated:
|
|
385
528
|
retry = client.callback_not_authenticated(client, path)
|
|
386
529
|
if retry:
|
|
387
530
|
return status_code, True
|
|
@@ -410,6 +553,8 @@ def fetch_all(
|
|
|
410
553
|
"""
|
|
411
554
|
Args:
|
|
412
555
|
path (str): The path for which we want to retrieve all entries.
|
|
556
|
+
params (dict): The parameters to pass to the request.
|
|
557
|
+
client (KitsuClient): The client to use for the request.
|
|
413
558
|
paginated (bool): Will query entries page by page.
|
|
414
559
|
limit (int): Limit the number of entries per page.
|
|
415
560
|
|
|
@@ -453,6 +598,8 @@ def fetch_first(path, params=None, client=default_client):
|
|
|
453
598
|
"""
|
|
454
599
|
Args:
|
|
455
600
|
path (str): The path for which we want to retrieve the first entry.
|
|
601
|
+
params (dict): The parameters to pass to the request.
|
|
602
|
+
client (KitsuClient): The client to use for the request.
|
|
456
603
|
|
|
457
604
|
Returns:
|
|
458
605
|
dict: The first entry for which a model is required.
|
|
@@ -464,7 +611,7 @@ def fetch_first(path, params=None, client=default_client):
|
|
|
464
611
|
return None
|
|
465
612
|
|
|
466
613
|
|
|
467
|
-
def fetch_one(model_name, id, client=default_client):
|
|
614
|
+
def fetch_one(model_name, id, params=None, client=default_client):
|
|
468
615
|
"""
|
|
469
616
|
Function dedicated at targeting routes that returns a single model
|
|
470
617
|
instance.
|
|
@@ -472,11 +619,15 @@ def fetch_one(model_name, id, client=default_client):
|
|
|
472
619
|
Args:
|
|
473
620
|
model_name (str): Model type name.
|
|
474
621
|
id (str): Model instance ID.
|
|
622
|
+
params (dict): The parameters to pass to the request.
|
|
623
|
+
client (KitsuClient): The client to use for the request.
|
|
475
624
|
|
|
476
625
|
Returns:
|
|
477
626
|
dict: The model instance matching id and model name.
|
|
478
627
|
"""
|
|
479
|
-
return get(
|
|
628
|
+
return get(
|
|
629
|
+
url_path_join("data", model_name, id), params=params, client=client
|
|
630
|
+
)
|
|
480
631
|
|
|
481
632
|
|
|
482
633
|
def create(model_name, data, client=default_client):
|
|
@@ -484,8 +635,9 @@ def create(model_name, data, client=default_client):
|
|
|
484
635
|
Create an entry for given model and data.
|
|
485
636
|
|
|
486
637
|
Args:
|
|
487
|
-
|
|
488
|
-
data (str): The data to use for creation
|
|
638
|
+
model_name (str): The model type involved.
|
|
639
|
+
data (str): The data to use for creation.
|
|
640
|
+
client (KitsuClient): The client to use for the request.
|
|
489
641
|
|
|
490
642
|
Returns:
|
|
491
643
|
dict: Created entry
|
|
@@ -498,9 +650,10 @@ def update(model_name, model_id, data, client=default_client):
|
|
|
498
650
|
Update an entry for given model, id and data.
|
|
499
651
|
|
|
500
652
|
Args:
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
data (dict): The data to update
|
|
653
|
+
model_name (str): The model type involved.
|
|
654
|
+
model_id (str): The target model id.
|
|
655
|
+
data (dict): The data to update.
|
|
656
|
+
client (KitsuClient): The client to use for the request.
|
|
504
657
|
|
|
505
658
|
Returns:
|
|
506
659
|
dict: Updated entry
|
|
@@ -517,6 +670,9 @@ def upload(path, file_path, data={}, extra_files=[], client=default_client):
|
|
|
517
670
|
Args:
|
|
518
671
|
path (str): The url path to upload file.
|
|
519
672
|
file_path (str): The file location on the hard drive.
|
|
673
|
+
data (dict): The data to send with the file.
|
|
674
|
+
extra_files (list): List of extra files to upload.
|
|
675
|
+
client (KitsuClient): The client to use for the request.
|
|
520
676
|
|
|
521
677
|
Returns:
|
|
522
678
|
Response: Request response object.
|
|
@@ -546,6 +702,17 @@ def upload(path, file_path, data={}, extra_files=[], client=default_client):
|
|
|
546
702
|
|
|
547
703
|
|
|
548
704
|
def _build_file_dict(file_path, extra_files):
|
|
705
|
+
"""
|
|
706
|
+
Build a dictionary of files to upload.
|
|
707
|
+
|
|
708
|
+
Args:
|
|
709
|
+
file_path (str): The file location on the hard drive.
|
|
710
|
+
extra_files (list): List of extra files to upload.
|
|
711
|
+
|
|
712
|
+
Returns:
|
|
713
|
+
dict: The dictionary of files to upload.
|
|
714
|
+
"""
|
|
715
|
+
|
|
549
716
|
files = {"file": open(file_path, "rb")}
|
|
550
717
|
i = 2
|
|
551
718
|
for file_path in extra_files:
|
|
@@ -561,6 +728,8 @@ def download(path, file_path, params=None, client=default_client):
|
|
|
561
728
|
Args:
|
|
562
729
|
path (str): The url path to download file from.
|
|
563
730
|
file_path (str): The location to store the file on the hard drive.
|
|
731
|
+
params (dict): The parameters to pass to the request.
|
|
732
|
+
client (KitsuClient): The client to use for the request.
|
|
564
733
|
|
|
565
734
|
Returns:
|
|
566
735
|
Response: Request response object.
|
|
@@ -580,6 +749,14 @@ def download(path, file_path, params=None, client=default_client):
|
|
|
580
749
|
def get_file_data_from_url(url, full=False, client=default_client):
|
|
581
750
|
"""
|
|
582
751
|
Return data found at given url.
|
|
752
|
+
|
|
753
|
+
Args:
|
|
754
|
+
url (str): The url to fetch data from.
|
|
755
|
+
full (bool): Whether to use full url.
|
|
756
|
+
client (KitsuClient): The client to use for the request.
|
|
757
|
+
|
|
758
|
+
Returns:
|
|
759
|
+
bytes: The data found at the given url.
|
|
583
760
|
"""
|
|
584
761
|
if not full:
|
|
585
762
|
url = get_full_url(url)
|
|
@@ -596,15 +773,26 @@ def get_file_data_from_url(url, full=False, client=default_client):
|
|
|
596
773
|
|
|
597
774
|
def import_data(model_name, data, client=default_client):
|
|
598
775
|
"""
|
|
776
|
+
Import data for given model.
|
|
777
|
+
|
|
599
778
|
Args:
|
|
600
|
-
model_name (str): The data model to import
|
|
601
|
-
data (dict): The data to import
|
|
779
|
+
model_name (str): The data model to import.
|
|
780
|
+
data (dict): The data to import.
|
|
781
|
+
client (KitsuClient): The client to use for the request.
|
|
782
|
+
|
|
783
|
+
Returns:
|
|
784
|
+
dict: The imported data.
|
|
602
785
|
"""
|
|
603
786
|
return post("/import/kitsu/%s" % model_name, data, client=client)
|
|
604
787
|
|
|
605
788
|
|
|
606
789
|
def get_api_version(client=default_client):
|
|
607
790
|
"""
|
|
791
|
+
Get the current version of the API.
|
|
792
|
+
|
|
793
|
+
Args:
|
|
794
|
+
client (KitsuClient): The client to use for the request.
|
|
795
|
+
|
|
608
796
|
Returns:
|
|
609
797
|
str: Current version of the API.
|
|
610
798
|
"""
|
|
@@ -613,6 +801,11 @@ def get_api_version(client=default_client):
|
|
|
613
801
|
|
|
614
802
|
def get_current_user(client=default_client):
|
|
615
803
|
"""
|
|
804
|
+
Get the current user.
|
|
805
|
+
|
|
806
|
+
Args:
|
|
807
|
+
client (KitsuClient): The client to use for the request.
|
|
808
|
+
|
|
616
809
|
Returns:
|
|
617
810
|
dict: User database information for user linked to auth tokens.
|
|
618
811
|
"""
|
|
@@ -52,11 +52,13 @@ def init(
|
|
|
52
52
|
Returns:
|
|
53
53
|
Event client that will be able to set listeners.
|
|
54
54
|
"""
|
|
55
|
-
params = {
|
|
55
|
+
params = {
|
|
56
|
+
"ssl_verify": ssl_verify,
|
|
57
|
+
"reconnection": reconnection,
|
|
58
|
+
"logger": logger,
|
|
59
|
+
}
|
|
56
60
|
params.update(kwargs)
|
|
57
|
-
event_client = socketio.Client(
|
|
58
|
-
logger=logger, reconnection=reconnection, **params
|
|
59
|
-
)
|
|
61
|
+
event_client = socketio.Client(**params)
|
|
60
62
|
event_client.on("connect_error", connect_error)
|
|
61
63
|
event_client.register_namespace(EventsNamespace("/events"))
|
|
62
64
|
event_client.connect(get_event_host(client), make_auth_header())
|
|
@@ -17,7 +17,7 @@ default = raw.default_client
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
def get_last_events(
|
|
20
|
-
|
|
20
|
+
limit=20000,
|
|
21
21
|
project=None,
|
|
22
22
|
after=None,
|
|
23
23
|
before=None,
|
|
@@ -29,7 +29,7 @@ def get_last_events(
|
|
|
29
29
|
Get last events that occured on the machine.
|
|
30
30
|
|
|
31
31
|
Args:
|
|
32
|
-
|
|
32
|
+
limit (int): Number of events to retrieve.
|
|
33
33
|
project (dict/id): Get only events related to this project.
|
|
34
34
|
after (dict/id): Get only events occuring after given date.
|
|
35
35
|
before (dict/id): Get only events occuring before given date.
|
|
@@ -39,7 +39,7 @@ def get_last_events(
|
|
|
39
39
|
dict: Last events matching criterions.
|
|
40
40
|
"""
|
|
41
41
|
path = "/data/events/last"
|
|
42
|
-
params = {"
|
|
42
|
+
params = {"limit": limit, "only_files": only_files}
|
|
43
43
|
if project is not None:
|
|
44
44
|
project = normalize_model_parameter(project)
|
|
45
45
|
params["project_id"] = project["id"]
|
|
@@ -70,7 +70,10 @@ class BaseFuncTestCase(ClientTestCase):
|
|
|
70
70
|
pass
|
|
71
71
|
|
|
72
72
|
def test_make_auth_header(self):
|
|
73
|
-
|
|
73
|
+
self.assertEqual(
|
|
74
|
+
raw.default_client.make_auth_header(),
|
|
75
|
+
raw.make_auth_header(),
|
|
76
|
+
)
|
|
74
77
|
|
|
75
78
|
def test_url_path_join(self):
|
|
76
79
|
root = raw.get_host()
|
|
@@ -255,6 +258,7 @@ class BaseFuncTestCase(ClientTestCase):
|
|
|
255
258
|
|
|
256
259
|
def test_make_auth_token(self):
|
|
257
260
|
tokens = {"access_token": "token_test"}
|
|
261
|
+
|
|
258
262
|
raw.set_tokens(tokens)
|
|
259
263
|
self.assertEqual(
|
|
260
264
|
raw.make_auth_header(),
|
|
@@ -437,7 +441,7 @@ class BaseFuncTestCase(ClientTestCase):
|
|
|
437
441
|
"auth/refresh-token",
|
|
438
442
|
text={"access_token": "tokentest1"},
|
|
439
443
|
)
|
|
440
|
-
gazu.
|
|
444
|
+
gazu.refresh_access_token()
|
|
441
445
|
self.assertEqual(
|
|
442
446
|
raw.default_client.tokens["access_token"], "tokentest1"
|
|
443
447
|
)
|
gazu-0.10.20/gazu/__version__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.10.20"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|