gazu 0.10.15__tar.gz → 0.10.17__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.15 → gazu-0.10.17}/PKG-INFO +3 -3
  2. gazu-0.10.17/gazu/__version__.py +1 -0
  3. {gazu-0.10.15 → gazu-0.10.17}/gazu/casting.py +4 -1
  4. {gazu-0.10.15 → gazu-0.10.17}/gazu/client.py +37 -8
  5. {gazu-0.10.15 → gazu-0.10.17}/gazu/playlist.py +11 -21
  6. {gazu-0.10.15 → gazu-0.10.17}/gazu/task.py +3 -23
  7. {gazu-0.10.15 → gazu-0.10.17}/gazu.egg-info/PKG-INFO +3 -3
  8. {gazu-0.10.15 → gazu-0.10.17}/gazu.egg-info/requires.txt +2 -2
  9. {gazu-0.10.15 → gazu-0.10.17}/setup.cfg +2 -2
  10. {gazu-0.10.15 → gazu-0.10.17}/tests/test_casting.py +3 -1
  11. {gazu-0.10.15 → gazu-0.10.17}/tests/test_client.py +28 -10
  12. {gazu-0.10.15 → gazu-0.10.17}/tests/test_files.py +20 -0
  13. {gazu-0.10.15 → gazu-0.10.17}/tests/test_playlist.py +27 -19
  14. gazu-0.10.15/gazu/__version__.py +0 -1
  15. {gazu-0.10.15 → gazu-0.10.17}/LICENSE +0 -0
  16. {gazu-0.10.15 → gazu-0.10.17}/README.rst +0 -0
  17. {gazu-0.10.15 → gazu-0.10.17}/gazu/__init__.py +0 -0
  18. {gazu-0.10.15 → gazu-0.10.17}/gazu/asset.py +0 -0
  19. {gazu-0.10.15 → gazu-0.10.17}/gazu/cache.py +0 -0
  20. {gazu-0.10.15 → gazu-0.10.17}/gazu/concept.py +0 -0
  21. {gazu-0.10.15 → gazu-0.10.17}/gazu/context.py +0 -0
  22. {gazu-0.10.15 → gazu-0.10.17}/gazu/edit.py +0 -0
  23. {gazu-0.10.15 → gazu-0.10.17}/gazu/encoder.py +0 -0
  24. {gazu-0.10.15 → gazu-0.10.17}/gazu/entity.py +0 -0
  25. {gazu-0.10.15 → gazu-0.10.17}/gazu/events.py +0 -0
  26. {gazu-0.10.15 → gazu-0.10.17}/gazu/exception.py +0 -0
  27. {gazu-0.10.15 → gazu-0.10.17}/gazu/files.py +0 -0
  28. {gazu-0.10.15 → gazu-0.10.17}/gazu/helpers.py +0 -0
  29. {gazu-0.10.15 → gazu-0.10.17}/gazu/person.py +0 -0
  30. {gazu-0.10.15 → gazu-0.10.17}/gazu/project.py +0 -0
  31. {gazu-0.10.15 → gazu-0.10.17}/gazu/scene.py +0 -0
  32. {gazu-0.10.15 → gazu-0.10.17}/gazu/shot.py +0 -0
  33. {gazu-0.10.15 → gazu-0.10.17}/gazu/sorting.py +0 -0
  34. {gazu-0.10.15 → gazu-0.10.17}/gazu/sync.py +0 -0
  35. {gazu-0.10.15 → gazu-0.10.17}/gazu/user.py +0 -0
  36. {gazu-0.10.15 → gazu-0.10.17}/gazu.egg-info/SOURCES.txt +0 -0
  37. {gazu-0.10.15 → gazu-0.10.17}/gazu.egg-info/dependency_links.txt +0 -0
  38. {gazu-0.10.15 → gazu-0.10.17}/gazu.egg-info/not-zip-safe +0 -0
  39. {gazu-0.10.15 → gazu-0.10.17}/gazu.egg-info/top_level.txt +0 -0
  40. {gazu-0.10.15 → gazu-0.10.17}/pyproject.toml +0 -0
  41. {gazu-0.10.15 → gazu-0.10.17}/setup.py +0 -0
  42. {gazu-0.10.15 → gazu-0.10.17}/tests/test_asset.py +0 -0
  43. {gazu-0.10.15 → gazu-0.10.17}/tests/test_cache.py +0 -0
  44. {gazu-0.10.15 → gazu-0.10.17}/tests/test_concept.py +0 -0
  45. {gazu-0.10.15 → gazu-0.10.17}/tests/test_context.py +0 -0
  46. {gazu-0.10.15 → gazu-0.10.17}/tests/test_edit.py +0 -0
  47. {gazu-0.10.15 → gazu-0.10.17}/tests/test_entity.py +0 -0
  48. {gazu-0.10.15 → gazu-0.10.17}/tests/test_helpers.py +0 -0
  49. {gazu-0.10.15 → gazu-0.10.17}/tests/test_person.py +0 -0
  50. {gazu-0.10.15 → gazu-0.10.17}/tests/test_project.py +0 -0
  51. {gazu-0.10.15 → gazu-0.10.17}/tests/test_scene.py +0 -0
  52. {gazu-0.10.15 → gazu-0.10.17}/tests/test_shot.py +0 -0
  53. {gazu-0.10.15 → gazu-0.10.17}/tests/test_sync.py +0 -0
  54. {gazu-0.10.15 → gazu-0.10.17}/tests/test_task.py +0 -0
  55. {gazu-0.10.15 → gazu-0.10.17}/tests/test_user.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gazu
3
- Version: 0.10.15
3
+ Version: 0.10.17
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
@@ -36,8 +36,8 @@ Requires-Dist: pytest-cov; extra == "test"
36
36
  Requires-Dist: requests_mock; extra == "test"
37
37
  Provides-Extra: lint
38
38
  Requires-Dist: autoflake==2.3.1; python_version >= "3.8" and extra == "lint"
39
- Requires-Dist: black==24.8.0; python_version >= "3.8" and extra == "lint"
40
- Requires-Dist: pre-commit==3.8.0; python_version >= "3.9" and extra == "lint"
39
+ Requires-Dist: black==24.10.0; python_version >= "3.9" and extra == "lint"
40
+ Requires-Dist: pre-commit==4.0.1; python_version >= "3.9" and extra == "lint"
41
41
 
42
42
  .. figure:: https://zou.cg-wire.com/kitsu.png
43
43
  :alt: Kitsu Logo
@@ -0,0 +1 @@
1
+ __version__ = "0.10.17"
@@ -60,7 +60,10 @@ def update_episode_casting(project, episode, casting, client=default):
60
60
  """
61
61
  episode = normalize_model_parameter(episode)
62
62
  project = normalize_model_parameter(project)
63
- path = "data/projects/%s/entities/%s/casting" % (project["id"], episode["id"])
63
+ path = "data/projects/%s/entities/%s/casting" % (
64
+ project["id"],
65
+ episode["id"],
66
+ )
64
67
  return raw.put(path, casting, client=client)
65
68
 
66
69
 
@@ -303,6 +303,32 @@ def delete(path, params=None, client=default_client):
303
303
  return response.text
304
304
 
305
305
 
306
+ def get_message_from_response(
307
+ response, default_message="No additional information"
308
+ ):
309
+ """
310
+ A utility function that handles Zou's inconsistent message keys.
311
+ For a given request, checks if any error messages or regular messages were given and returns their value.
312
+ If no messages are found, returns a default message.
313
+
314
+ Args:
315
+ response: requests.Request - A response to check.
316
+ default_message: str - An optional default value to revert to if no message is detected.
317
+
318
+ Returns:
319
+ The message of a given response, or a default message - if any.
320
+ """
321
+ message = default_message
322
+ message_json = response.json()
323
+
324
+ for key in ["error", "message"]:
325
+ if message_json.get(key):
326
+ message = message_json[key]
327
+ break
328
+
329
+ return message
330
+
331
+
306
332
  def check_status(request, path, client=None):
307
333
  """
308
334
  Raise an exception related to status code, if the status code does not
@@ -329,8 +355,7 @@ def check_status(request, path, client=None):
329
355
  elif status_code == 403:
330
356
  raise NotAllowedException(path)
331
357
  elif status_code == 400:
332
- text = request.json().get("message", "No additional information")
333
- raise ParameterException(path, text)
358
+ raise ParameterException(path, get_message_from_response(request))
334
359
  elif status_code == 405:
335
360
  raise MethodNotAllowedException(path)
336
361
  elif status_code == 413:
@@ -359,14 +384,15 @@ def check_status(request, path, client=None):
359
384
  raise
360
385
  elif status_code in [500, 502]:
361
386
  try:
387
+ print("A server error occured!\n")
362
388
  stacktrace = request.json().get(
363
389
  "stacktrace", "No stacktrace sent by the server"
364
390
  )
365
- message = request.json().get(
366
- "message", "No message sent by the server"
367
- )
368
- print("A server error occured!\n")
369
391
  print("Server stacktrace:\n%s" % stacktrace)
392
+ message = get_message_from_response(
393
+ response=request,
394
+ default_message="No message sent by the server",
395
+ )
370
396
  print("Error message:\n%s\n" % message)
371
397
  except Exception:
372
398
  print(request.text)
@@ -474,8 +500,11 @@ def upload(path, file_path, data={}, extra_files=[], client=default_client):
474
500
  except JSONDecodeError:
475
501
  print(response.text)
476
502
  raise
477
- if "message" in result:
478
- raise UploadFailedException(result["message"])
503
+
504
+ result_message = get_message_from_response(response, default_message="")
505
+ if result_message:
506
+ raise UploadFailedException(result_message)
507
+
479
508
  return result
480
509
 
481
510
 
@@ -166,16 +166,12 @@ def get_entity_preview_files(entity, client=default):
166
166
  entity = normalize_model_parameter(entity)
167
167
  return raw.get(
168
168
  "data/playlists/entities/%s/preview-files" % entity["id"],
169
- client=client
169
+ client=client,
170
170
  )
171
171
 
172
172
 
173
173
  def add_entity_to_playlist(
174
- playlist,
175
- entity,
176
- preview_file=None,
177
- persist=True,
178
- client=default
174
+ playlist, entity, preview_file=None, persist=True, client=default
179
175
  ):
180
176
  """
181
177
  Add an entity to the playlist, use the last uploaded preview as revision
@@ -197,25 +193,23 @@ def add_entity_to_playlist(
197
193
  for task_type_id in preview_files.keys():
198
194
  task_type_files = preview_files[task_type_id]
199
195
  first_file = task_type_files[0]
200
- if preview_file is None or \
201
- preview_file["created_at"] < first_file["created_at"]:
196
+ if (
197
+ preview_file is None
198
+ or preview_file["created_at"] < first_file["created_at"]
199
+ ):
202
200
  preview_file = first_file
203
201
 
204
202
  preview_file = normalize_model_parameter(preview_file)
205
- playlist["shots"].append({
206
- "entity_id": entity["id"],
207
- "preview_file_id": preview_file["id"]
208
- })
203
+ playlist["shots"].append(
204
+ {"entity_id": entity["id"], "preview_file_id": preview_file["id"]}
205
+ )
209
206
  if persist:
210
207
  update_playlist(playlist, client=client)
211
208
  return playlist
212
209
 
213
210
 
214
211
  def remove_entity_from_playlist(
215
- playlist,
216
- entity,
217
- persist=True,
218
- client=default
212
+ playlist, entity, persist=True, client=default
219
213
  ):
220
214
  """
221
215
  Remove all occurences of a given entity from a playlist.
@@ -239,11 +233,7 @@ def remove_entity_from_playlist(
239
233
 
240
234
 
241
235
  def update_entity_preview(
242
- playlist,
243
- entity,
244
- preview_file,
245
- persist=True,
246
- client=default
236
+ playlist, entity, preview_file, persist=True, client=default
247
237
  ):
248
238
  """
249
239
  Remove all occurences of a given entity from a playlist.
@@ -257,12 +257,7 @@ def all_tasks_for_task_status(project, task_type, task_status, client=default):
257
257
 
258
258
 
259
259
  @cache
260
- def all_tasks_for_task_type(
261
- project,
262
- task_type,
263
- episode=None,
264
- client=default
265
- ):
260
+ def all_tasks_for_task_type(project, task_type, episode=None, client=default):
266
261
  """
267
262
  Args:
268
263
  project (str / dict): The project dict or the project ID.
@@ -532,18 +527,6 @@ def get_task_status_by_name(name, client=default):
532
527
  return raw.fetch_first("task-status", {"name": name}, client=client)
533
528
 
534
529
 
535
- @cache
536
- def get_default_task_status(client=default):
537
- """
538
- Args:
539
- name (str / dict): The name of claimed task status.
540
-
541
- Returns:
542
- dict: Task status matching given name.
543
- """
544
- return raw.fetch_first("task-status", {"is_default": True}, client=client)
545
-
546
-
547
530
  @cache
548
531
  def get_task_status_by_short_name(task_status_short_name, client=default):
549
532
  """
@@ -661,7 +644,7 @@ def new_task(
661
644
  entity = normalize_model_parameter(entity)
662
645
  task_type = normalize_model_parameter(task_type)
663
646
  if task_status is None:
664
- task_status = get_default_task_status()
647
+ task_status = get_default_task_status(client=client)
665
648
 
666
649
  data = {
667
650
  "project_id": entity["project_id"],
@@ -1267,10 +1250,7 @@ def get_task_url(task, client=default):
1267
1250
 
1268
1251
 
1269
1252
  def all_tasks_for_project(
1270
- project,
1271
- task_type=None,
1272
- episode=None,
1273
- client=default
1253
+ project, task_type=None, episode=None, client=default
1274
1254
  ):
1275
1255
  """
1276
1256
  Args:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gazu
3
- Version: 0.10.15
3
+ Version: 0.10.17
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
@@ -36,8 +36,8 @@ Requires-Dist: pytest-cov; extra == "test"
36
36
  Requires-Dist: requests_mock; extra == "test"
37
37
  Provides-Extra: lint
38
38
  Requires-Dist: autoflake==2.3.1; python_version >= "3.8" and extra == "lint"
39
- Requires-Dist: black==24.8.0; python_version >= "3.8" and extra == "lint"
40
- Requires-Dist: pre-commit==3.8.0; python_version >= "3.9" and extra == "lint"
39
+ Requires-Dist: black==24.10.0; python_version >= "3.9" and extra == "lint"
40
+ Requires-Dist: pre-commit==4.0.1; python_version >= "3.9" and extra == "lint"
41
41
 
42
42
  .. figure:: https://zou.cg-wire.com/kitsu.png
43
43
  :alt: Kitsu Logo
@@ -11,10 +11,10 @@ wheel
11
11
 
12
12
  [lint:python_version >= "3.8"]
13
13
  autoflake==2.3.1
14
- black==24.8.0
15
14
 
16
15
  [lint:python_version >= "3.9"]
17
- pre-commit==3.8.0
16
+ black==24.10.0
17
+ pre-commit==4.0.1
18
18
 
19
19
  [test]
20
20
  pytest
@@ -46,8 +46,8 @@ test =
46
46
  requests_mock
47
47
  lint =
48
48
  autoflake==2.3.1; python_version >= '3.8'
49
- black==24.8.0; python_version >= '3.8'
50
- pre-commit==3.8.0; python_version >= '3.9'
49
+ black==24.10.0; python_version >= '3.9'
50
+ pre-commit==4.0.1; python_version >= '3.9'
51
51
 
52
52
  [bdist_wheel]
53
53
  universal = 1
@@ -47,7 +47,9 @@ class CastingTestCase(unittest.TestCase):
47
47
  mock.put(gazu.client.get_full_url(path), text=json.dumps(casting))
48
48
  episode = {"id": fakeid("episode-01")}
49
49
  project = {"id": fakeid("project-01")}
50
- casting = gazu.casting.update_episode_casting(project, episode, casting)
50
+ casting = gazu.casting.update_episode_casting(
51
+ project, episode, casting
52
+ )
51
53
  self.assertEqual(casting[0]["asset_id"], fakeid("asset-1"))
52
54
 
53
55
  def test_get_asset_type_casting(self):
@@ -1,5 +1,7 @@
1
1
  import datetime
2
2
  import json
3
+ import random
4
+ import string
3
5
 
4
6
  import unittest
5
7
  import requests_mock
@@ -281,20 +283,36 @@ class BaseFuncTestCase(ClientTestCase):
281
283
  "./tests/fixtures/v1.png",
282
284
  data={"test": True},
283
285
  )
286
+
287
+ error_value = "".join(
288
+ [
289
+ random.choice(
290
+ string.ascii_uppercase + string.ascii_lowercase
291
+ )
292
+ for _ in range(10)
293
+ ]
294
+ )
295
+
284
296
  with requests_mock.Mocker() as mock:
285
- mock_route(
286
- mock,
287
- "POST",
288
- "data/new-file",
289
- text={"message": "Error"},
290
- )
291
- with self.assertRaises(gazu.client.UploadFailedException):
292
- raw.upload(
297
+ for field in ["message", "error"]:
298
+ mock_route(
299
+ mock,
300
+ "POST",
293
301
  "data/new-file",
294
- "./tests/fixtures/v1.png",
295
- data={"test": True},
302
+ text={field: error_value},
296
303
  )
297
304
 
305
+ with self.assertRaises(
306
+ gazu.client.UploadFailedException
307
+ ) as context:
308
+ raw.upload(
309
+ "data/new-file",
310
+ "./tests/fixtures/v1.png",
311
+ data={"test": True},
312
+ )
313
+
314
+ self.assertTrue(str(context.exception) == error_value)
315
+
298
316
  def test_upload_multiple_files(self):
299
317
  with open("./tests/fixtures/v1.png", "rb") as test_file:
300
318
  with requests_mock.Mocker() as mock:
@@ -39,6 +39,26 @@ class FilesTestCase(unittest.TestCase):
39
39
  )
40
40
  self.assertEqual(working_file["id"], 1)
41
41
 
42
+ mock.post(
43
+ gazu.client.get_full_url(path),
44
+ text=json.dumps(
45
+ {"error": "The given working file already exists."}
46
+ ),
47
+ status_code=400,
48
+ )
49
+
50
+ with self.assertRaises(gazu.client.ParameterException) as context:
51
+ gazu.files.new_working_file(
52
+ task,
53
+ person={"id": "person-01"},
54
+ software={"id": "software-1"},
55
+ )
56
+
57
+ self.assertTrue(
58
+ str(context.exception)
59
+ == "The given working file already exists."
60
+ )
61
+
42
62
  def test_new_entity_output_file(self):
43
63
  entity = {"id": "asset-01"}
44
64
  output_type = {"id": "output-type-01"}
@@ -179,7 +179,8 @@ class TaskTestCase(unittest.TestCase):
179
179
  )
180
180
  mock.get(
181
181
  gazu.client.get_full_url(
182
- "data/playlists/entities/%s/preview-files" % fakeid("shot-1")
182
+ "data/playlists/entities/%s/preview-files"
183
+ % fakeid("shot-1")
183
184
  ),
184
185
  text=json.dumps(
185
186
  {fakeid("task-type-1"): [{"id": fakeid("preview-1")}]}
@@ -188,26 +189,33 @@ class TaskTestCase(unittest.TestCase):
188
189
  playlist = {
189
190
  "id": fakeid("playlist-1"),
190
191
  "name": "name_changed",
191
- "shots": []
192
- }
193
- shot = {
194
- "id": fakeid("shot-1"),
195
- "name": "SH01"
192
+ "shots": [],
196
193
  }
194
+ shot = {"id": fakeid("shot-1"), "name": "SH01"}
197
195
  playlist = gazu.playlist.add_entity_to_playlist(playlist, shot)
198
196
  self.assertEqual(playlist["id"], fakeid("playlist-1"))
199
- self.assertEqual(playlist["shots"], [{
200
- "entity_id": fakeid("shot-1"),
201
- "preview_file_id": fakeid("preview-1")
202
- }])
197
+ self.assertEqual(
198
+ playlist["shots"],
199
+ [
200
+ {
201
+ "entity_id": fakeid("shot-1"),
202
+ "preview_file_id": fakeid("preview-1"),
203
+ }
204
+ ],
205
+ )
203
206
  playlist = gazu.playlist.update_entity_preview(
204
- playlist,
205
- shot,
206
- fakeid("preview-2")
207
- )
208
- self.assertEqual(playlist["shots"], [{
209
- "entity_id": fakeid("shot-1"),
210
- "preview_file_id": fakeid("preview-2")
211
- }])
212
- playlist = gazu.playlist.remove_entity_from_playlist(playlist, shot)
207
+ playlist, shot, fakeid("preview-2")
208
+ )
209
+ self.assertEqual(
210
+ playlist["shots"],
211
+ [
212
+ {
213
+ "entity_id": fakeid("shot-1"),
214
+ "preview_file_id": fakeid("preview-2"),
215
+ }
216
+ ],
217
+ )
218
+ playlist = gazu.playlist.remove_entity_from_playlist(
219
+ playlist, shot
220
+ )
213
221
  self.assertEqual(playlist["shots"], [])
@@ -1 +0,0 @@
1
- __version__ = "0.10.15"
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