gazu 0.10.19__py2.py3-none-any.whl → 0.10.21__py2.py3-none-any.whl
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/__init__.py +2 -16
- gazu/__version__.py +1 -1
- gazu/client.py +274 -44
- gazu/events.py +6 -4
- gazu/sync.py +3 -3
- {gazu-0.10.19.dist-info → gazu-0.10.21.dist-info}/METADATA +15 -13
- {gazu-0.10.19.dist-info → gazu-0.10.21.dist-info}/RECORD +10 -10
- {gazu-0.10.19.dist-info → gazu-0.10.21.dist-info}/WHEEL +1 -1
- {gazu-0.10.19.dist-info → gazu-0.10.21.dist-info}/LICENSE +0 -0
- {gazu-0.10.19.dist-info → gazu-0.10.21.dist-info}/top_level.txt +0 -0
gazu/__init__.py
CHANGED
|
@@ -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):
|
gazu/__version__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.10.
|
|
1
|
+
__version__ = "0.10.21"
|
gazu/client.py
CHANGED
|
@@ -2,7 +2,6 @@ import sys
|
|
|
2
2
|
import functools
|
|
3
3
|
import json
|
|
4
4
|
import shutil
|
|
5
|
-
import urllib
|
|
6
5
|
import os
|
|
7
6
|
|
|
8
7
|
from .encoder import CustomJSONEncoder
|
|
@@ -23,8 +22,10 @@ from .exception import (
|
|
|
23
22
|
|
|
24
23
|
if sys.version_info[0] == 3:
|
|
25
24
|
from json import JSONDecodeError
|
|
25
|
+
from urllib.parse import urlencode
|
|
26
26
|
else:
|
|
27
27
|
JSONDecodeError = ValueError
|
|
28
|
+
from urllib import urlencode
|
|
28
29
|
|
|
29
30
|
DEBUG = os.getenv("GAZU_DEBUG", "false").lower() == "true"
|
|
30
31
|
|
|
@@ -35,32 +36,107 @@ class KitsuClient(object):
|
|
|
35
36
|
host,
|
|
36
37
|
ssl_verify=True,
|
|
37
38
|
cert=None,
|
|
38
|
-
|
|
39
|
+
use_refresh_token=True,
|
|
39
40
|
callback_not_authenticated=None,
|
|
41
|
+
tokens={"access_token": None, "refresh_token": None},
|
|
42
|
+
access_token=None,
|
|
43
|
+
refresh_token=None,
|
|
40
44
|
):
|
|
41
|
-
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
|
+
|
|
42
53
|
self.session = requests.Session()
|
|
43
54
|
self.session.verify = ssl_verify
|
|
44
55
|
self.session.cert = cert
|
|
45
56
|
self.host = host
|
|
46
57
|
self.event_host = host
|
|
47
|
-
|
|
48
|
-
|
|
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
|
|
49
110
|
|
|
50
111
|
|
|
51
112
|
def create_client(
|
|
52
113
|
host,
|
|
53
114
|
ssl_verify=True,
|
|
54
115
|
cert=None,
|
|
55
|
-
|
|
116
|
+
use_refresh_token=False,
|
|
56
117
|
callback_not_authenticated=None,
|
|
118
|
+
**kwargs
|
|
57
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
|
+
"""
|
|
58
133
|
return KitsuClient(
|
|
59
134
|
host,
|
|
60
135
|
ssl_verify,
|
|
61
136
|
cert=cert,
|
|
62
|
-
|
|
137
|
+
use_refresh_token=use_refresh_token,
|
|
63
138
|
callback_not_authenticated=callback_not_authenticated,
|
|
139
|
+
**kwargs
|
|
64
140
|
)
|
|
65
141
|
|
|
66
142
|
|
|
@@ -80,8 +156,13 @@ except Exception:
|
|
|
80
156
|
|
|
81
157
|
def host_is_up(client=default_client):
|
|
82
158
|
"""
|
|
159
|
+
Check if the host is up.
|
|
160
|
+
|
|
161
|
+
Args:
|
|
162
|
+
client (KitsuClient): The client to use for the request.
|
|
163
|
+
|
|
83
164
|
Returns:
|
|
84
|
-
True if the host is up.
|
|
165
|
+
bool: True if the host is up.
|
|
85
166
|
"""
|
|
86
167
|
try:
|
|
87
168
|
response = client.session.head(client.host)
|
|
@@ -93,8 +174,12 @@ def host_is_up(client=default_client):
|
|
|
93
174
|
def host_is_valid(client=default_client):
|
|
94
175
|
"""
|
|
95
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
|
+
|
|
96
181
|
Returns:
|
|
97
|
-
True if the host is valid.
|
|
182
|
+
bool: True if the host is valid.
|
|
98
183
|
"""
|
|
99
184
|
if not host_is_up(client):
|
|
100
185
|
return False
|
|
@@ -106,14 +191,23 @@ def host_is_valid(client=default_client):
|
|
|
106
191
|
|
|
107
192
|
def get_host(client=default_client):
|
|
108
193
|
"""
|
|
194
|
+
Get client.host.
|
|
195
|
+
|
|
196
|
+
Args:
|
|
197
|
+
client (KitsuClient): The client to use for the request.
|
|
198
|
+
|
|
109
199
|
Returns:
|
|
110
|
-
|
|
200
|
+
str: The host of the client.
|
|
111
201
|
"""
|
|
112
202
|
return client.host
|
|
113
203
|
|
|
114
204
|
|
|
115
205
|
def get_api_url_from_host(client=default_client):
|
|
116
206
|
"""
|
|
207
|
+
Get the API url from the host.
|
|
208
|
+
|
|
209
|
+
Args:
|
|
210
|
+
client (KitsuClient): The client to use for the request.
|
|
117
211
|
Returns:
|
|
118
212
|
Zou url, retrieved from host.
|
|
119
213
|
"""
|
|
@@ -122,8 +216,14 @@ def get_api_url_from_host(client=default_client):
|
|
|
122
216
|
|
|
123
217
|
def set_host(new_host, client=default_client):
|
|
124
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
|
+
|
|
125
225
|
Returns:
|
|
126
|
-
|
|
226
|
+
str: The new host.
|
|
127
227
|
"""
|
|
128
228
|
client.host = new_host
|
|
129
229
|
return client.host
|
|
@@ -131,16 +231,27 @@ def set_host(new_host, client=default_client):
|
|
|
131
231
|
|
|
132
232
|
def get_event_host(client=default_client):
|
|
133
233
|
"""
|
|
234
|
+
Get the host on which listening for events.
|
|
235
|
+
|
|
236
|
+
Args:
|
|
237
|
+
client (KitsuClient): The client to use for the request.
|
|
238
|
+
|
|
134
239
|
Returns:
|
|
135
|
-
|
|
240
|
+
str: The event host.
|
|
136
241
|
"""
|
|
137
242
|
return client.event_host or client.host
|
|
138
243
|
|
|
139
244
|
|
|
140
245
|
def set_event_host(new_host, client=default_client):
|
|
141
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
|
+
|
|
142
253
|
Returns:
|
|
143
|
-
|
|
254
|
+
str: The new event host.
|
|
144
255
|
"""
|
|
145
256
|
client.event_host = new_host
|
|
146
257
|
return client.event_host
|
|
@@ -152,6 +263,10 @@ def set_tokens(new_tokens, client=default_client):
|
|
|
152
263
|
|
|
153
264
|
Args:
|
|
154
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.
|
|
155
270
|
"""
|
|
156
271
|
client.tokens = new_tokens
|
|
157
272
|
return client.tokens
|
|
@@ -159,13 +274,15 @@ def set_tokens(new_tokens, client=default_client):
|
|
|
159
274
|
|
|
160
275
|
def make_auth_header(client=default_client):
|
|
161
276
|
"""
|
|
277
|
+
Make headers required to authenticate.
|
|
278
|
+
|
|
279
|
+
Args:
|
|
280
|
+
client (KitsuClient): The client to use for the request.
|
|
281
|
+
|
|
162
282
|
Returns:
|
|
163
|
-
Headers required to authenticate.
|
|
283
|
+
dict: Headers required to authenticate.
|
|
164
284
|
"""
|
|
165
|
-
|
|
166
|
-
if "access_token" in client.tokens:
|
|
167
|
-
headers["Authorization"] = "Bearer %s" % client.tokens["access_token"]
|
|
168
|
-
return headers
|
|
285
|
+
return client.make_auth_header()
|
|
169
286
|
|
|
170
287
|
|
|
171
288
|
def url_path_join(*items):
|
|
@@ -175,12 +292,17 @@ def url_path_join(*items):
|
|
|
175
292
|
|
|
176
293
|
Args:
|
|
177
294
|
items (list): Path elements
|
|
295
|
+
|
|
296
|
+
Returns:
|
|
297
|
+
str: The joined path.
|
|
178
298
|
"""
|
|
179
299
|
return "/".join([item.lstrip("/").rstrip("/") for item in items])
|
|
180
300
|
|
|
181
301
|
|
|
182
302
|
def get_full_url(path, client=default_client):
|
|
183
303
|
"""
|
|
304
|
+
Join host url with given path.
|
|
305
|
+
|
|
184
306
|
Args:
|
|
185
307
|
path (str): The path to integrate to host url.
|
|
186
308
|
|
|
@@ -192,7 +314,7 @@ def get_full_url(path, client=default_client):
|
|
|
192
314
|
|
|
193
315
|
def build_path_with_params(path, params):
|
|
194
316
|
"""
|
|
195
|
-
Add params to a path using urllib encoding
|
|
317
|
+
Add params to a path using urllib encoding.
|
|
196
318
|
|
|
197
319
|
Args:
|
|
198
320
|
path (str): The url base path
|
|
@@ -204,10 +326,13 @@ def build_path_with_params(path, params):
|
|
|
204
326
|
if not params:
|
|
205
327
|
return path
|
|
206
328
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
329
|
+
query_string = urlencode(params)
|
|
330
|
+
|
|
331
|
+
if query_string:
|
|
332
|
+
# Support base paths that already contain query parameters.
|
|
333
|
+
path += "&" if "?" in path else "?"
|
|
334
|
+
path += query_string
|
|
335
|
+
|
|
211
336
|
return path
|
|
212
337
|
|
|
213
338
|
|
|
@@ -215,6 +340,12 @@ def get(path, json_response=True, params=None, client=default_client):
|
|
|
215
340
|
"""
|
|
216
341
|
Run a get request toward given path for configured host.
|
|
217
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
|
+
|
|
218
349
|
Returns:
|
|
219
350
|
The request result.
|
|
220
351
|
"""
|
|
@@ -239,6 +370,11 @@ def post(path, data, client=default_client):
|
|
|
239
370
|
"""
|
|
240
371
|
Run a post request toward given path for configured host.
|
|
241
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
|
+
|
|
242
378
|
Returns:
|
|
243
379
|
The request result.
|
|
244
380
|
"""
|
|
@@ -266,6 +402,11 @@ def put(path, data, client=default_client):
|
|
|
266
402
|
"""
|
|
267
403
|
Run a put request toward given path for configured host.
|
|
268
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
|
+
|
|
269
410
|
Returns:
|
|
270
411
|
The request result.
|
|
271
412
|
"""
|
|
@@ -287,6 +428,11 @@ def delete(path, params=None, client=default_client):
|
|
|
287
428
|
"""
|
|
288
429
|
Run a delete request toward given path for configured host.
|
|
289
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
|
+
|
|
290
436
|
Returns:
|
|
291
437
|
The request result.
|
|
292
438
|
"""
|
|
@@ -316,7 +462,7 @@ def get_message_from_response(
|
|
|
316
462
|
default_message: str - An optional default value to revert to if no message is detected.
|
|
317
463
|
|
|
318
464
|
Returns:
|
|
319
|
-
The message
|
|
465
|
+
str: The message to display to the user.
|
|
320
466
|
"""
|
|
321
467
|
message = default_message
|
|
322
468
|
message_json = response.json()
|
|
@@ -336,6 +482,8 @@ def check_status(request, path, client=None):
|
|
|
336
482
|
|
|
337
483
|
Args:
|
|
338
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.
|
|
339
487
|
|
|
340
488
|
Returns:
|
|
341
489
|
int: Status code
|
|
@@ -365,19 +513,18 @@ def check_status(request, path, client=None):
|
|
|
365
513
|
)
|
|
366
514
|
elif status_code in [401, 422]:
|
|
367
515
|
try:
|
|
368
|
-
if
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
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()
|
|
373
523
|
return status_code, True
|
|
374
524
|
else:
|
|
375
525
|
raise NotAuthenticatedException(path)
|
|
376
526
|
except NotAuthenticatedException:
|
|
377
|
-
if
|
|
378
|
-
client is not None
|
|
379
|
-
and client.callback_not_authenticated is not None
|
|
380
|
-
):
|
|
527
|
+
if client and client.callback_not_authenticated:
|
|
381
528
|
retry = client.callback_not_authenticated(client, path)
|
|
382
529
|
if retry:
|
|
383
530
|
return status_code, True
|
|
@@ -400,22 +547,59 @@ def check_status(request, path, client=None):
|
|
|
400
547
|
return status_code, False
|
|
401
548
|
|
|
402
549
|
|
|
403
|
-
def fetch_all(
|
|
550
|
+
def fetch_all(
|
|
551
|
+
path, params=None, client=default_client, paginated=False, limit=None
|
|
552
|
+
):
|
|
404
553
|
"""
|
|
405
554
|
Args:
|
|
406
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.
|
|
558
|
+
paginated (bool): Will query entries page by page.
|
|
559
|
+
limit (int): Limit the number of entries per page.
|
|
407
560
|
|
|
408
561
|
Returns:
|
|
409
562
|
list: All entries stored in database for a given model. You can add a
|
|
410
563
|
filter to the model name like this: "tasks?project_id=project-id"
|
|
411
564
|
"""
|
|
412
|
-
|
|
565
|
+
|
|
566
|
+
if paginated:
|
|
567
|
+
if not params:
|
|
568
|
+
params = {}
|
|
569
|
+
params["page"] = 1
|
|
570
|
+
if limit is not None:
|
|
571
|
+
params["limit"] = limit
|
|
572
|
+
|
|
573
|
+
url = url_path_join("data", path)
|
|
574
|
+
|
|
575
|
+
response = get(url, params=params, client=client)
|
|
576
|
+
|
|
577
|
+
if not paginated:
|
|
578
|
+
return response
|
|
579
|
+
|
|
580
|
+
nb_pages = response.get("nb_pages", 1)
|
|
581
|
+
current_page = response.get("page", 1)
|
|
582
|
+
results = response.get("data", [])
|
|
583
|
+
|
|
584
|
+
if current_page != nb_pages:
|
|
585
|
+
for page in range(2, nb_pages + 1):
|
|
586
|
+
params["page"] = page
|
|
587
|
+
response = get(
|
|
588
|
+
url,
|
|
589
|
+
params=params,
|
|
590
|
+
client=client,
|
|
591
|
+
)
|
|
592
|
+
results += response.get("data", [])
|
|
593
|
+
|
|
594
|
+
return results
|
|
413
595
|
|
|
414
596
|
|
|
415
597
|
def fetch_first(path, params=None, client=default_client):
|
|
416
598
|
"""
|
|
417
599
|
Args:
|
|
418
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.
|
|
419
603
|
|
|
420
604
|
Returns:
|
|
421
605
|
dict: The first entry for which a model is required.
|
|
@@ -427,7 +611,7 @@ def fetch_first(path, params=None, client=default_client):
|
|
|
427
611
|
return None
|
|
428
612
|
|
|
429
613
|
|
|
430
|
-
def fetch_one(model_name, id, client=default_client):
|
|
614
|
+
def fetch_one(model_name, id, params=None, client=default_client):
|
|
431
615
|
"""
|
|
432
616
|
Function dedicated at targeting routes that returns a single model
|
|
433
617
|
instance.
|
|
@@ -435,11 +619,15 @@ def fetch_one(model_name, id, client=default_client):
|
|
|
435
619
|
Args:
|
|
436
620
|
model_name (str): Model type name.
|
|
437
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.
|
|
438
624
|
|
|
439
625
|
Returns:
|
|
440
626
|
dict: The model instance matching id and model name.
|
|
441
627
|
"""
|
|
442
|
-
return get(
|
|
628
|
+
return get(
|
|
629
|
+
url_path_join("data", model_name, id), params=params, client=client
|
|
630
|
+
)
|
|
443
631
|
|
|
444
632
|
|
|
445
633
|
def create(model_name, data, client=default_client):
|
|
@@ -447,8 +635,9 @@ def create(model_name, data, client=default_client):
|
|
|
447
635
|
Create an entry for given model and data.
|
|
448
636
|
|
|
449
637
|
Args:
|
|
450
|
-
|
|
451
|
-
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.
|
|
452
641
|
|
|
453
642
|
Returns:
|
|
454
643
|
dict: Created entry
|
|
@@ -461,9 +650,10 @@ def update(model_name, model_id, data, client=default_client):
|
|
|
461
650
|
Update an entry for given model, id and data.
|
|
462
651
|
|
|
463
652
|
Args:
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
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.
|
|
467
657
|
|
|
468
658
|
Returns:
|
|
469
659
|
dict: Updated entry
|
|
@@ -480,6 +670,9 @@ def upload(path, file_path, data={}, extra_files=[], client=default_client):
|
|
|
480
670
|
Args:
|
|
481
671
|
path (str): The url path to upload file.
|
|
482
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.
|
|
483
676
|
|
|
484
677
|
Returns:
|
|
485
678
|
Response: Request response object.
|
|
@@ -509,6 +702,17 @@ def upload(path, file_path, data={}, extra_files=[], client=default_client):
|
|
|
509
702
|
|
|
510
703
|
|
|
511
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
|
+
|
|
512
716
|
files = {"file": open(file_path, "rb")}
|
|
513
717
|
i = 2
|
|
514
718
|
for file_path in extra_files:
|
|
@@ -524,6 +728,8 @@ def download(path, file_path, params=None, client=default_client):
|
|
|
524
728
|
Args:
|
|
525
729
|
path (str): The url path to download file from.
|
|
526
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.
|
|
527
733
|
|
|
528
734
|
Returns:
|
|
529
735
|
Response: Request response object.
|
|
@@ -543,6 +749,14 @@ def download(path, file_path, params=None, client=default_client):
|
|
|
543
749
|
def get_file_data_from_url(url, full=False, client=default_client):
|
|
544
750
|
"""
|
|
545
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.
|
|
546
760
|
"""
|
|
547
761
|
if not full:
|
|
548
762
|
url = get_full_url(url)
|
|
@@ -559,15 +773,26 @@ def get_file_data_from_url(url, full=False, client=default_client):
|
|
|
559
773
|
|
|
560
774
|
def import_data(model_name, data, client=default_client):
|
|
561
775
|
"""
|
|
776
|
+
Import data for given model.
|
|
777
|
+
|
|
562
778
|
Args:
|
|
563
|
-
model_name (str): The data model to import
|
|
564
|
-
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.
|
|
565
785
|
"""
|
|
566
786
|
return post("/import/kitsu/%s" % model_name, data, client=client)
|
|
567
787
|
|
|
568
788
|
|
|
569
789
|
def get_api_version(client=default_client):
|
|
570
790
|
"""
|
|
791
|
+
Get the current version of the API.
|
|
792
|
+
|
|
793
|
+
Args:
|
|
794
|
+
client (KitsuClient): The client to use for the request.
|
|
795
|
+
|
|
571
796
|
Returns:
|
|
572
797
|
str: Current version of the API.
|
|
573
798
|
"""
|
|
@@ -576,6 +801,11 @@ def get_api_version(client=default_client):
|
|
|
576
801
|
|
|
577
802
|
def get_current_user(client=default_client):
|
|
578
803
|
"""
|
|
804
|
+
Get the current user.
|
|
805
|
+
|
|
806
|
+
Args:
|
|
807
|
+
client (KitsuClient): The client to use for the request.
|
|
808
|
+
|
|
579
809
|
Returns:
|
|
580
810
|
dict: User database information for user linked to auth tokens.
|
|
581
811
|
"""
|
gazu/events.py
CHANGED
|
@@ -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())
|
gazu/sync.py
CHANGED
|
@@ -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"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: gazu
|
|
3
|
-
Version: 0.10.
|
|
3
|
+
Version: 0.10.21
|
|
4
4
|
Summary: Gazu is a client for Zou, the API to store the data of your CG production.
|
|
5
5
|
Home-page: https://gazu.cg-wire.com/
|
|
6
6
|
Author: CG Wire
|
|
@@ -20,25 +20,27 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.10
|
|
21
21
|
Classifier: Programming Language :: Python :: 3.11
|
|
22
22
|
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
24
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
24
25
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
25
26
|
Classifier: Topic :: Multimedia :: Graphics
|
|
26
27
|
Requires-Python: >= 2.7, != 3.0.*, != 3.1.*, != 3.2.*, != 3.3.*, != 3.4.*, != 3.5.*, != 3.6.1, != 3.6.2
|
|
27
28
|
License-File: LICENSE
|
|
28
|
-
Requires-Dist:
|
|
29
|
-
Requires-Dist:
|
|
30
|
-
Requires-Dist:
|
|
31
|
-
Requires-Dist: pywin32
|
|
29
|
+
Requires-Dist: python-socketio[client]<6,>=5.11.0; python_version != "2.7"
|
|
30
|
+
Requires-Dist: requests>=2.25.1
|
|
31
|
+
Requires-Dist: Deprecated==1.2.15
|
|
32
|
+
Requires-Dist: pywin32>=308; sys_platform == "win32" and python_version != "2.7"
|
|
32
33
|
Provides-Extra: dev
|
|
33
|
-
Requires-Dist: wheel
|
|
34
|
-
Provides-Extra: lint
|
|
35
|
-
Requires-Dist: autoflake ==2.3.1 ; (python_version >= "3.8") and extra == 'lint'
|
|
36
|
-
Requires-Dist: black ==24.10.0 ; (python_version >= "3.9") and extra == 'lint'
|
|
37
|
-
Requires-Dist: pre-commit ==4.0.1 ; (python_version >= "3.9") and extra == 'lint'
|
|
34
|
+
Requires-Dist: wheel; extra == "dev"
|
|
38
35
|
Provides-Extra: test
|
|
39
|
-
Requires-Dist: pytest
|
|
40
|
-
Requires-Dist: pytest-cov
|
|
41
|
-
Requires-Dist:
|
|
36
|
+
Requires-Dist: pytest; extra == "test"
|
|
37
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
38
|
+
Requires-Dist: requests_mock; extra == "test"
|
|
39
|
+
Requires-Dist: multipart; python_version >= "3.13" and extra == "test"
|
|
40
|
+
Provides-Extra: lint
|
|
41
|
+
Requires-Dist: autoflake==2.3.1; python_version >= "3.8" and extra == "lint"
|
|
42
|
+
Requires-Dist: black==24.10.0; python_version >= "3.9" and extra == "lint"
|
|
43
|
+
Requires-Dist: pre-commit==4.0.1; python_version >= "3.9" and extra == "lint"
|
|
42
44
|
|
|
43
45
|
.. figure:: https://zou.cg-wire.com/kitsu.png
|
|
44
46
|
:alt: Kitsu Logo
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
gazu/__init__.py,sha256=
|
|
2
|
-
gazu/__version__.py,sha256=
|
|
1
|
+
gazu/__init__.py,sha256=KPAVnFOSbzZnd24ItkZEOv7yQ5w0Pv7k1TFmL8saiqY,2594
|
|
2
|
+
gazu/__version__.py,sha256=W69o5JUR26BK90cqamed5YGEcQII_Xm_6Nbg6iJ5L9o,24
|
|
3
3
|
gazu/asset.py,sha256=2D7_2fFElfkS6DrHVh0FI-1H73-vhX7VuYCjRgQPVJ0,14564
|
|
4
4
|
gazu/cache.py,sha256=MnxrnfYN7wHNTTL7qzkEpYCYzWcolT56fqQ0_RegMbE,5879
|
|
5
5
|
gazu/casting.py,sha256=0LTdsHaCTHSKEflBWFeuraSaYNYetGkMHAIdg6Lv81U,5059
|
|
6
|
-
gazu/client.py,sha256=
|
|
6
|
+
gazu/client.py,sha256=6mK1NTV9I9cEedCp4SiHoJU3OjmFKkHssvqnyvrL6TY,21985
|
|
7
7
|
gazu/concept.py,sha256=GcOPEmkbtZcSwlX8tnUj9Q5DTPBprSxtmXhlq7ioPwk,3727
|
|
8
8
|
gazu/context.py,sha256=iUyug8EUz3kkF-kmYlH5JuLp66TUqR3uhAq7CouVd_U,4349
|
|
9
9
|
gazu/edit.py,sha256=sPSsnzykGr1Htl6ceKulUSVHGhoQLGLeWDni3Pul7BE,4609
|
|
10
10
|
gazu/encoder.py,sha256=dj8U5mlGVy0GeaA7HIIdPSRdKswUQ8h4DzjFKLhwvR0,394
|
|
11
11
|
gazu/entity.py,sha256=Pbc_sbgo8RhQV88nksP1whHyWL4hVyHR3CZ0sVplPY4,3670
|
|
12
|
-
gazu/events.py,sha256=
|
|
12
|
+
gazu/events.py,sha256=4j8wbF4K-f5Kyu_jI4bklS12huzAN0cjCdY4hcKyhuk,2221
|
|
13
13
|
gazu/exception.py,sha256=Y0kVNm6h-uXLEU1sNIbMSUep7Zxk738uYHOIVs2waM8,1880
|
|
14
14
|
gazu/files.py,sha256=L82d5Bx3TkcaNczQ5t9s8DTKAcYXiqGaKUrag2cKjqI,39645
|
|
15
15
|
gazu/helpers.py,sha256=Qa4JlZitiXsfYMJGGuwVaedLvHQVMbIwcqEZ099EjMw,3916
|
|
@@ -19,11 +19,11 @@ gazu/project.py,sha256=fssI_Bf5UqqRd9bfM68oyfkhjxwWvjdiAcYvvUhI5LY,12649
|
|
|
19
19
|
gazu/scene.py,sha256=Q4AVmiMfGhSZfaXwOceyR-taTlpx1WCELe0UBSiHm8o,5357
|
|
20
20
|
gazu/shot.py,sha256=mHg-8B7xk3PXMqbPo0oCx2X7br2sGCBmuM7hEhpXRas,18942
|
|
21
21
|
gazu/sorting.py,sha256=qSIO0pOHkj0Tl4gm9BJrYrcifWGGGmsW68Pl86zB_bg,266
|
|
22
|
-
gazu/sync.py,sha256=
|
|
22
|
+
gazu/sync.py,sha256=3clThVFC9pSIQiCyVkNRPnlbYQDA2kfR-lxaWxHbeUk,21611
|
|
23
23
|
gazu/task.py,sha256=rnOKunR-vXLQPkD5nOufPhppYLLkgAWZS9tYlutCMp0,36412
|
|
24
24
|
gazu/user.py,sha256=GyJf6mrynHvLllw3Hsiv-6wjaYTHO_PBNkJzyJjJA1A,9556
|
|
25
|
-
gazu-0.10.
|
|
26
|
-
gazu-0.10.
|
|
27
|
-
gazu-0.10.
|
|
28
|
-
gazu-0.10.
|
|
29
|
-
gazu-0.10.
|
|
25
|
+
gazu-0.10.21.dist-info/LICENSE,sha256=2n6rt7r999OuXp8iOqW9we7ORaxWncIbOwN1ILRGR2g,7651
|
|
26
|
+
gazu-0.10.21.dist-info/METADATA,sha256=CbvK4jP5Wy6MvRx_UERfYSVihpw0ai6iU-OJQxJgIqM,5447
|
|
27
|
+
gazu-0.10.21.dist-info/WHEEL,sha256=pxeNX5JdtCe58PUSYP9upmc7jdRPgvT0Gm9kb1SHlVw,109
|
|
28
|
+
gazu-0.10.21.dist-info/top_level.txt,sha256=nv7fRIVpYYyIlk_66hBmMyvWcSC7UU-r-GE8uC1u1Go,5
|
|
29
|
+
gazu-0.10.21.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|