gazu 0.10.20__tar.gz → 0.10.22__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. {gazu-0.10.20 → gazu-0.10.22}/PKG-INFO +1 -1
  2. {gazu-0.10.20 → gazu-0.10.22}/gazu/__init__.py +2 -16
  3. gazu-0.10.22/gazu/__version__.py +1 -0
  4. {gazu-0.10.20 → gazu-0.10.22}/gazu/client.py +248 -44
  5. {gazu-0.10.20 → gazu-0.10.22}/gazu/events.py +6 -4
  6. {gazu-0.10.20 → gazu-0.10.22}/gazu/sync.py +3 -3
  7. {gazu-0.10.20 → gazu-0.10.22}/gazu/task.py +37 -0
  8. {gazu-0.10.20 → gazu-0.10.22}/gazu.egg-info/PKG-INFO +1 -1
  9. {gazu-0.10.20 → gazu-0.10.22}/tests/test_client.py +7 -3
  10. gazu-0.10.20/gazu/__version__.py +0 -1
  11. {gazu-0.10.20 → gazu-0.10.22}/LICENSE +0 -0
  12. {gazu-0.10.20 → gazu-0.10.22}/README.rst +0 -0
  13. {gazu-0.10.20 → gazu-0.10.22}/gazu/asset.py +0 -0
  14. {gazu-0.10.20 → gazu-0.10.22}/gazu/cache.py +0 -0
  15. {gazu-0.10.20 → gazu-0.10.22}/gazu/casting.py +0 -0
  16. {gazu-0.10.20 → gazu-0.10.22}/gazu/concept.py +0 -0
  17. {gazu-0.10.20 → gazu-0.10.22}/gazu/context.py +0 -0
  18. {gazu-0.10.20 → gazu-0.10.22}/gazu/edit.py +0 -0
  19. {gazu-0.10.20 → gazu-0.10.22}/gazu/encoder.py +0 -0
  20. {gazu-0.10.20 → gazu-0.10.22}/gazu/entity.py +0 -0
  21. {gazu-0.10.20 → gazu-0.10.22}/gazu/exception.py +0 -0
  22. {gazu-0.10.20 → gazu-0.10.22}/gazu/files.py +0 -0
  23. {gazu-0.10.20 → gazu-0.10.22}/gazu/helpers.py +0 -0
  24. {gazu-0.10.20 → gazu-0.10.22}/gazu/person.py +0 -0
  25. {gazu-0.10.20 → gazu-0.10.22}/gazu/playlist.py +0 -0
  26. {gazu-0.10.20 → gazu-0.10.22}/gazu/project.py +0 -0
  27. {gazu-0.10.20 → gazu-0.10.22}/gazu/scene.py +0 -0
  28. {gazu-0.10.20 → gazu-0.10.22}/gazu/shot.py +0 -0
  29. {gazu-0.10.20 → gazu-0.10.22}/gazu/sorting.py +0 -0
  30. {gazu-0.10.20 → gazu-0.10.22}/gazu/user.py +0 -0
  31. {gazu-0.10.20 → gazu-0.10.22}/gazu.egg-info/SOURCES.txt +0 -0
  32. {gazu-0.10.20 → gazu-0.10.22}/gazu.egg-info/dependency_links.txt +0 -0
  33. {gazu-0.10.20 → gazu-0.10.22}/gazu.egg-info/not-zip-safe +0 -0
  34. {gazu-0.10.20 → gazu-0.10.22}/gazu.egg-info/requires.txt +0 -0
  35. {gazu-0.10.20 → gazu-0.10.22}/gazu.egg-info/top_level.txt +0 -0
  36. {gazu-0.10.20 → gazu-0.10.22}/pyproject.toml +0 -0
  37. {gazu-0.10.20 → gazu-0.10.22}/setup.cfg +0 -0
  38. {gazu-0.10.20 → gazu-0.10.22}/setup.py +0 -0
  39. {gazu-0.10.20 → gazu-0.10.22}/tests/test_asset.py +0 -0
  40. {gazu-0.10.20 → gazu-0.10.22}/tests/test_cache.py +0 -0
  41. {gazu-0.10.20 → gazu-0.10.22}/tests/test_casting.py +0 -0
  42. {gazu-0.10.20 → gazu-0.10.22}/tests/test_concept.py +0 -0
  43. {gazu-0.10.20 → gazu-0.10.22}/tests/test_context.py +0 -0
  44. {gazu-0.10.20 → gazu-0.10.22}/tests/test_edit.py +0 -0
  45. {gazu-0.10.20 → gazu-0.10.22}/tests/test_entity.py +0 -0
  46. {gazu-0.10.20 → gazu-0.10.22}/tests/test_files.py +0 -0
  47. {gazu-0.10.20 → gazu-0.10.22}/tests/test_helpers.py +0 -0
  48. {gazu-0.10.20 → gazu-0.10.22}/tests/test_person.py +0 -0
  49. {gazu-0.10.20 → gazu-0.10.22}/tests/test_playlist.py +0 -0
  50. {gazu-0.10.20 → gazu-0.10.22}/tests/test_project.py +0 -0
  51. {gazu-0.10.20 → gazu-0.10.22}/tests/test_scene.py +0 -0
  52. {gazu-0.10.20 → gazu-0.10.22}/tests/test_shot.py +0 -0
  53. {gazu-0.10.20 → gazu-0.10.22}/tests/test_sync.py +0 -0
  54. {gazu-0.10.20 → gazu-0.10.22}/tests/test_task.py +0 -0
  55. {gazu-0.10.20 → gazu-0.10.22}/tests/test_user.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gazu
3
- Version: 0.10.20
3
+ Version: 0.10.22
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
@@ -87,22 +87,8 @@ def log_out(client=raw.default_client):
87
87
  return tokens
88
88
 
89
89
 
90
- def refresh_token(client=raw.default_client):
91
- headers = {"User-Agent": "CGWire Gazu %s" % __version__}
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.22"
@@ -36,32 +36,107 @@ class KitsuClient(object):
36
36
  host,
37
37
  ssl_verify=True,
38
38
  cert=None,
39
- automatic_refresh_token=False,
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 = {"access_token": "", "refresh_token": ""}
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
- self.automatic_refresh_token = automatic_refresh_token
49
- self.callback_not_authenticated = callback_not_authenticated
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
- automatic_refresh_token=False,
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
- automatic_refresh_token=automatic_refresh_token,
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
- Host on which requests are sent.
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
- Set currently configured host on which requests are sent.
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
- Host on which listening for events.
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
- Set currently configured host on which listening for events.
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
- headers = {"User-Agent": "CGWire Gazu %s" % __version__}
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,15 +462,16 @@ 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 of a given response, or a default message - if any.
465
+ str: The message to display to the user.
324
466
  """
325
467
  message = default_message
326
468
  message_json = response.json()
327
469
 
328
- for key in ["error", "message"]:
329
- if message_json.get(key):
330
- message = message_json[key]
331
- break
470
+ if hasattr(message_json, "get"):
471
+ for key in ["error", "message"]:
472
+ if message_json.get(key):
473
+ message = message_json[key]
474
+ break
332
475
 
333
476
  return message
334
477
 
@@ -340,6 +483,8 @@ def check_status(request, path, client=None):
340
483
 
341
484
  Args:
342
485
  request (Request): The request to validate.
486
+ path (str): The path of the request.
487
+ client (KitsuClient): The client to use for the request.
343
488
 
344
489
  Returns:
345
490
  int: Status code
@@ -369,19 +514,18 @@ def check_status(request, path, client=None):
369
514
  )
370
515
  elif status_code in [401, 422]:
371
516
  try:
372
- if client is not None and client.automatic_refresh_token:
373
- from . import refresh_token
374
-
375
- refresh_token(client=client)
376
-
517
+ if (
518
+ client
519
+ and client.refresh_token
520
+ and client.use_refresh_token
521
+ and request.json()["message"] == "Signature has expired"
522
+ ):
523
+ client.refresh_access_token()
377
524
  return status_code, True
378
525
  else:
379
526
  raise NotAuthenticatedException(path)
380
527
  except NotAuthenticatedException:
381
- if (
382
- client is not None
383
- and client.callback_not_authenticated is not None
384
- ):
528
+ if client and client.callback_not_authenticated:
385
529
  retry = client.callback_not_authenticated(client, path)
386
530
  if retry:
387
531
  return status_code, True
@@ -410,6 +554,8 @@ def fetch_all(
410
554
  """
411
555
  Args:
412
556
  path (str): The path for which we want to retrieve all entries.
557
+ params (dict): The parameters to pass to the request.
558
+ client (KitsuClient): The client to use for the request.
413
559
  paginated (bool): Will query entries page by page.
414
560
  limit (int): Limit the number of entries per page.
415
561
 
@@ -453,6 +599,8 @@ def fetch_first(path, params=None, client=default_client):
453
599
  """
454
600
  Args:
455
601
  path (str): The path for which we want to retrieve the first entry.
602
+ params (dict): The parameters to pass to the request.
603
+ client (KitsuClient): The client to use for the request.
456
604
 
457
605
  Returns:
458
606
  dict: The first entry for which a model is required.
@@ -464,7 +612,7 @@ def fetch_first(path, params=None, client=default_client):
464
612
  return None
465
613
 
466
614
 
467
- def fetch_one(model_name, id, client=default_client):
615
+ def fetch_one(model_name, id, params=None, client=default_client):
468
616
  """
469
617
  Function dedicated at targeting routes that returns a single model
470
618
  instance.
@@ -472,11 +620,15 @@ def fetch_one(model_name, id, client=default_client):
472
620
  Args:
473
621
  model_name (str): Model type name.
474
622
  id (str): Model instance ID.
623
+ params (dict): The parameters to pass to the request.
624
+ client (KitsuClient): The client to use for the request.
475
625
 
476
626
  Returns:
477
627
  dict: The model instance matching id and model name.
478
628
  """
479
- return get(url_path_join("data", model_name, id), client=client)
629
+ return get(
630
+ url_path_join("data", model_name, id), params=params, client=client
631
+ )
480
632
 
481
633
 
482
634
  def create(model_name, data, client=default_client):
@@ -484,8 +636,9 @@ def create(model_name, data, client=default_client):
484
636
  Create an entry for given model and data.
485
637
 
486
638
  Args:
487
- model (str): The model type involved
488
- data (str): The data to use for creation
639
+ model_name (str): The model type involved.
640
+ data (str): The data to use for creation.
641
+ client (KitsuClient): The client to use for the request.
489
642
 
490
643
  Returns:
491
644
  dict: Created entry
@@ -498,9 +651,10 @@ def update(model_name, model_id, data, client=default_client):
498
651
  Update an entry for given model, id and data.
499
652
 
500
653
  Args:
501
- model (str): The model type involved
502
- id (str): The target model id
503
- data (dict): The data to update
654
+ model_name (str): The model type involved.
655
+ model_id (str): The target model id.
656
+ data (dict): The data to update.
657
+ client (KitsuClient): The client to use for the request.
504
658
 
505
659
  Returns:
506
660
  dict: Updated entry
@@ -510,19 +664,31 @@ def update(model_name, model_id, data, client=default_client):
510
664
  )
511
665
 
512
666
 
513
- def upload(path, file_path, data={}, extra_files=[], client=default_client):
667
+ def upload(
668
+ path,
669
+ file_path=None,
670
+ data={},
671
+ extra_files=[],
672
+ files=None,
673
+ client=default_client,
674
+ ):
514
675
  """
515
676
  Upload file located at *file_path* to given url *path*.
516
677
 
517
678
  Args:
518
679
  path (str): The url path to upload file.
519
680
  file_path (str): The file location on the hard drive.
681
+ data (dict): The data to send with the file.
682
+ extra_files (list): List of extra files to upload.
683
+ files (dict): The dictionary of files to upload.
684
+ client (KitsuClient): The client to use for the request.
520
685
 
521
686
  Returns:
522
687
  Response: Request response object.
523
688
  """
524
689
  url = get_full_url(path, client)
525
- files = _build_file_dict(file_path, extra_files)
690
+ if not files:
691
+ files = _build_file_dict(file_path, extra_files)
526
692
  retry = True
527
693
  while retry:
528
694
  response = client.session.post(
@@ -546,11 +712,23 @@ def upload(path, file_path, data={}, extra_files=[], client=default_client):
546
712
 
547
713
 
548
714
  def _build_file_dict(file_path, extra_files):
715
+ """
716
+ Build a dictionary of files to upload.
717
+
718
+ Args:
719
+ file_path (str): The file location on the hard drive.
720
+ extra_files (list): List of extra files to upload.
721
+
722
+ Returns:
723
+ dict: The dictionary of files to upload.
724
+ """
725
+
549
726
  files = {"file": open(file_path, "rb")}
550
- i = 2
727
+ i = 0
551
728
  for file_path in extra_files:
552
- files["file-%s" % i] = open(file_path, "rb")
553
729
  i += 1
730
+ files["file-%s" % i] = open(file_path, "rb")
731
+
554
732
  return files
555
733
 
556
734
 
@@ -561,6 +739,8 @@ def download(path, file_path, params=None, client=default_client):
561
739
  Args:
562
740
  path (str): The url path to download file from.
563
741
  file_path (str): The location to store the file on the hard drive.
742
+ params (dict): The parameters to pass to the request.
743
+ client (KitsuClient): The client to use for the request.
564
744
 
565
745
  Returns:
566
746
  Response: Request response object.
@@ -580,6 +760,14 @@ def download(path, file_path, params=None, client=default_client):
580
760
  def get_file_data_from_url(url, full=False, client=default_client):
581
761
  """
582
762
  Return data found at given url.
763
+
764
+ Args:
765
+ url (str): The url to fetch data from.
766
+ full (bool): Whether to use full url.
767
+ client (KitsuClient): The client to use for the request.
768
+
769
+ Returns:
770
+ bytes: The data found at the given url.
583
771
  """
584
772
  if not full:
585
773
  url = get_full_url(url)
@@ -596,15 +784,26 @@ def get_file_data_from_url(url, full=False, client=default_client):
596
784
 
597
785
  def import_data(model_name, data, client=default_client):
598
786
  """
787
+ Import data for given model.
788
+
599
789
  Args:
600
- model_name (str): The data model to import
601
- data (dict): The data to import
790
+ model_name (str): The data model to import.
791
+ data (dict): The data to import.
792
+ client (KitsuClient): The client to use for the request.
793
+
794
+ Returns:
795
+ dict: The imported data.
602
796
  """
603
797
  return post("/import/kitsu/%s" % model_name, data, client=client)
604
798
 
605
799
 
606
800
  def get_api_version(client=default_client):
607
801
  """
802
+ Get the current version of the API.
803
+
804
+ Args:
805
+ client (KitsuClient): The client to use for the request.
806
+
608
807
  Returns:
609
808
  str: Current version of the API.
610
809
  """
@@ -613,6 +812,11 @@ def get_api_version(client=default_client):
613
812
 
614
813
  def get_current_user(client=default_client):
615
814
  """
815
+ Get the current user.
816
+
817
+ Args:
818
+ client (KitsuClient): The client to use for the request.
819
+
616
820
  Returns:
617
821
  dict: User database information for user linked to auth tokens.
618
822
  """
@@ -52,11 +52,13 @@ def init(
52
52
  Returns:
53
53
  Event client that will be able to set listeners.
54
54
  """
55
- params = {"ssl_verify": ssl_verify}
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
- page_size=20000,
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
- page_size (int): Number of events to retrieve.
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 = {"page_size": page_size, "only_files": only_files}
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"]
@@ -839,6 +839,7 @@ def add_comment(
839
839
  "task_status_id": task_status["id"],
840
840
  "comment": comment,
841
841
  "checklist": checklist,
842
+ "links": links,
842
843
  }
843
844
 
844
845
  if person is not None:
@@ -1014,6 +1015,7 @@ def publish_preview(
1014
1015
  normalize_movie=True,
1015
1016
  revision=None,
1016
1017
  set_thumbnail=False,
1018
+ links=[],
1017
1019
  client=default,
1018
1020
  ):
1019
1021
  """
@@ -1035,6 +1037,7 @@ def publish_preview(
1035
1037
  server side.
1036
1038
  revision (int): Revision number.
1037
1039
  set_thumbnail (bool): Set the preview as thumbnail of the entity.
1040
+ links (list): List of links to add to the comment
1038
1041
  Returns:
1039
1042
  tuple(dict, dict): Created comment model and created preview file
1040
1043
  model.
@@ -1047,6 +1050,7 @@ def publish_preview(
1047
1050
  checklist=checklist,
1048
1051
  attachments=attachments,
1049
1052
  created_at=created_at,
1053
+ links=links,
1050
1054
  client=client,
1051
1055
  )
1052
1056
  preview_file = add_preview(
@@ -1063,6 +1067,39 @@ def publish_preview(
1063
1067
  return new_comment, preview_file
1064
1068
 
1065
1069
 
1070
+ def publish_comments_previews(task, comments=[], client=default):
1071
+ """
1072
+ Publish a list of comments (with attachments and previews) for given task.
1073
+ Each dict comments may contain a list of attachment files path and preview
1074
+ files path in the keys "attachment_files" and "preview_files".
1075
+
1076
+ Args:
1077
+ task (str / dict): The task dict or the task ID.
1078
+ comments (list): List of comments to publish.
1079
+
1080
+ Returns:
1081
+ list: List of created comments.
1082
+ """
1083
+ task = normalize_model_parameter(task)
1084
+
1085
+ files = {}
1086
+ for x, comment in enumerate(comments):
1087
+ if comment.get("attachment_files"):
1088
+ for y, file_path in enumerate(comment["attachment_files"]):
1089
+ files["attachment_file-%i-%i" % (x, y)] = open(file_path, "rb")
1090
+ if comment.get("preview_files"):
1091
+ for y, file_path in enumerate(comment["preview_files"]):
1092
+ files["preview_file-%i-%i" % (x, y)] = open(file_path, "rb")
1093
+
1094
+ files["comments"] = (None, json.dumps(comments), "application/json")
1095
+ return raw.upload(
1096
+ "actions/tasks/%s/add-comments-previews" % task["id"],
1097
+ file_path=None,
1098
+ files=files,
1099
+ client=client,
1100
+ )
1101
+
1102
+
1066
1103
  def set_main_preview(preview_file, frame_number=None, client=default):
1067
1104
  """
1068
1105
  Set given preview as thumbnail of given entity.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gazu
3
- Version: 0.10.20
3
+ Version: 0.10.22
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
@@ -70,7 +70,10 @@ class BaseFuncTestCase(ClientTestCase):
70
70
  pass
71
71
 
72
72
  def test_make_auth_header(self):
73
- pass
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(),
@@ -327,7 +331,7 @@ class BaseFuncTestCase(ClientTestCase):
327
331
  mock,
328
332
  {
329
333
  "file": test_file_read,
330
- "file-2": test_file_read,
334
+ "file-1": test_file_read,
331
335
  "test": "True",
332
336
  },
333
337
  )
@@ -437,7 +441,7 @@ class BaseFuncTestCase(ClientTestCase):
437
441
  "auth/refresh-token",
438
442
  text={"access_token": "tokentest1"},
439
443
  )
440
- gazu.refresh_token()
444
+ gazu.refresh_access_token()
441
445
  self.assertEqual(
442
446
  raw.default_client.tokens["access_token"], "tokentest1"
443
447
  )
@@ -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