gazu 0.10.14__py2.py3-none-any.whl → 0.10.16__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/__version__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.10.14"
1
+ __version__ = "0.10.16"
gazu/casting.py CHANGED
@@ -45,6 +45,28 @@ def update_asset_casting(project, asset, casting, client=default):
45
45
  return raw.put(path, casting, client=client)
46
46
 
47
47
 
48
+ def update_episode_casting(project, episode, casting, client=default):
49
+ """
50
+ Change casting of given episode with given casting (list of asset ids displayed
51
+ into the episode).
52
+
53
+ Args:
54
+ episode (str / dict): The episode dict or the episode ID.
55
+ casting (dict): The casting description.
56
+ Ex: `casting = [{"asset_id": "asset-1", "nb_occurences": 3}]`
57
+
58
+ Returns:
59
+ dict: Related episode.
60
+ """
61
+ episode = normalize_model_parameter(episode)
62
+ project = normalize_model_parameter(project)
63
+ path = "data/projects/%s/entities/%s/casting" % (
64
+ project["id"],
65
+ episode["id"],
66
+ )
67
+ return raw.put(path, casting, client=client)
68
+
69
+
48
70
  def get_asset_type_casting(project, asset_type, client=default):
49
71
  """
50
72
  Return casting for given asset_type.
@@ -117,6 +139,23 @@ def get_asset_casting(asset, client=default):
117
139
  return raw.get(path, client=client)
118
140
 
119
141
 
142
+ def get_episode_casting(episode, client=default):
143
+ """
144
+ Return casting for given episode.
145
+ `[{"episode_id": "episode-1", "nb_occurences": 3}]}`
146
+ Args:
147
+ episode (dict): The episode dict
148
+
149
+ Returns:
150
+ dict: Casting for given episode.
151
+ """
152
+ path = "/data/projects/%s/entities/%s/casting" % (
153
+ episode["project_id"],
154
+ episode["id"],
155
+ )
156
+ return raw.get(path, client=client)
157
+
158
+
120
159
  def get_asset_cast_in(asset, client=default):
121
160
  """
122
161
  Return entity list where given asset is casted.
gazu/exception.py CHANGED
@@ -75,3 +75,15 @@ class TaskMustBeADictException(Exception):
75
75
  """
76
76
  Error raised when a task should be a dict.
77
77
  """
78
+
79
+
80
+ class FileDoesntExistException(Exception):
81
+ """
82
+ Error raised when a file should be existed when we submit a preview.
83
+ """
84
+
85
+
86
+ class ProjectDoesntExistException(Exception):
87
+ """
88
+ Error raised when a project isn't available.
89
+ """
gazu/playlist.py CHANGED
@@ -151,3 +151,105 @@ def update_playlist(playlist, client=default):
151
151
  return raw.put(
152
152
  "data/playlists/%s" % playlist["id"], playlist, client=client
153
153
  )
154
+
155
+
156
+ def get_entity_preview_files(entity, client=default):
157
+ """
158
+ Get all preview files grouped by task type for a given entity.
159
+
160
+ Args:
161
+ entity (str / dict): The entity to retrieve files from or its ID.
162
+
163
+ Returns:
164
+ dict: A dict where keys are task type IDs and value array of revisions.
165
+ """
166
+ entity = normalize_model_parameter(entity)
167
+ return raw.get(
168
+ "data/playlists/entities/%s/preview-files" % entity["id"],
169
+ client=client,
170
+ )
171
+
172
+
173
+ def add_entity_to_playlist(
174
+ playlist, entity, preview_file=None, persist=True, client=default
175
+ ):
176
+ """
177
+ Add an entity to the playlist, use the last uploaded preview as revision
178
+ to review.
179
+
180
+ Args:
181
+ playlist (dict): Playlist object to modify.
182
+ entity (str / dict): The entity to add or its ID.
183
+ preview_file (str / dict): Set it to force a give revision to review.
184
+ persist (bool): Set it to True to save the result to the API.
185
+
186
+ Returns:
187
+ dict: Updated playlist.
188
+ """
189
+ entity = normalize_model_parameter(entity)
190
+
191
+ if preview_file is None:
192
+ preview_files = get_entity_preview_files(entity)
193
+ for task_type_id in preview_files.keys():
194
+ task_type_files = preview_files[task_type_id]
195
+ first_file = task_type_files[0]
196
+ if (
197
+ preview_file is None
198
+ or preview_file["created_at"] < first_file["created_at"]
199
+ ):
200
+ preview_file = first_file
201
+
202
+ preview_file = normalize_model_parameter(preview_file)
203
+ playlist["shots"].append(
204
+ {"entity_id": entity["id"], "preview_file_id": preview_file["id"]}
205
+ )
206
+ if persist:
207
+ update_playlist(playlist, client=client)
208
+ return playlist
209
+
210
+
211
+ def remove_entity_from_playlist(
212
+ playlist, entity, persist=True, client=default
213
+ ):
214
+ """
215
+ Remove all occurences of a given entity from a playlist.
216
+
217
+ Args:
218
+ playlist (dict): Playlist object to modify
219
+ entity (str / dict): the entity to remove or its ID
220
+
221
+ Returns:
222
+ dict: Updated playlist.
223
+ """
224
+ entity = normalize_model_parameter(entity)
225
+ playlist["shots"] = [
226
+ entry
227
+ for entry in playlist["shots"]
228
+ if entry["entity_id"] != entity["id"]
229
+ ]
230
+ if persist:
231
+ update_playlist(playlist, client=client)
232
+ return playlist
233
+
234
+
235
+ def update_entity_preview(
236
+ playlist, entity, preview_file, persist=True, client=default
237
+ ):
238
+ """
239
+ Remove all occurences of a given entity from a playlist.
240
+
241
+ Args:
242
+ playlist (dict): Playlist object to modify
243
+ entity (str / dict): the entity to add or its ID
244
+
245
+ Returns:
246
+ dict: Updated playlist.
247
+ """
248
+ entity = normalize_model_parameter(entity)
249
+ preview_file = normalize_model_parameter(preview_file)
250
+ for entry in playlist["shots"]:
251
+ if entry["entity_id"] == entity["id"]:
252
+ entry["preview_file_id"] = preview_file["id"]
253
+ if persist:
254
+ update_playlist(playlist, client=client)
255
+ return playlist
gazu/sync.py CHANGED
@@ -56,6 +56,7 @@ def import_entities(entities, client=default):
56
56
  """
57
57
  Import entities from another instance to target instance (keep id and audit
58
58
  dates).
59
+
59
60
  Args:
60
61
  entities (list): Entities to import.
61
62
 
@@ -69,6 +70,7 @@ def import_tasks(tasks, client=default):
69
70
  """
70
71
  Import tasks from another instance to target instance (keep id and audit
71
72
  dates).
73
+
72
74
  Args:
73
75
  tasks (list): Tasks to import.
74
76
 
@@ -82,6 +84,7 @@ def import_entity_links(links, client=default):
82
84
  """
83
85
  Import enitity links from another instance to target instance (keep id and
84
86
  audit dates).
87
+
85
88
  Args:
86
89
  links (list): Entity links to import.
87
90
 
@@ -292,7 +295,8 @@ def get_sync_person_id_map(source_client, target_client):
292
295
  def push_assets(project_source, project_target, client_source, client_target):
293
296
  """
294
297
  Copy assets from source to target and preserve audit fields (`id`,
295
- `created_at`, and `updated_at`)
298
+ `created_at`, and `updated_at`).
299
+
296
300
  Args:
297
301
  project_source (dict): The project to get assets from
298
302
  project_target (dict): The project to push assets to
@@ -321,6 +325,7 @@ def push_episodes(
321
325
  """
322
326
  Copy episodes from source to target and preserve audit fields (`id`,
323
327
  `created_at`, and `updated_at`)
328
+
324
329
  Args:
325
330
  project_source (dict): The project to get episodes from
326
331
  project_target (dict): The project to push episodes to
@@ -344,6 +349,7 @@ def push_sequences(
344
349
  """
345
350
  Copy sequences from source to target and preserve audit fields (`id`,
346
351
  `created_at`, and `updated_at`)
352
+
347
353
  Args:
348
354
  project_source (dict): The project to get sequences from
349
355
  project_target (dict): The project to push sequences to
@@ -364,7 +370,8 @@ def push_sequences(
364
370
  def push_shots(project_source, project_target, client_source, client_target):
365
371
  """
366
372
  Copy shots from source to target and preserve audit fields (`id`,
367
- `created_at`, and `updated_at`)
373
+ `created_at`, and `updated_at`).
374
+
368
375
  Args:
369
376
  project_source (dict): The project to get shots from
370
377
  project_target (dict): The project to push shots to
@@ -386,8 +393,9 @@ def push_entity_links(
386
393
  project_source, project_target, client_source, client_target
387
394
  ):
388
395
  """
389
- Copy assets from source to target and preserve audit fields (`id`,
390
- `created_at`, and `updated_at`)
396
+ Copy entity links (breakdown, concepts) from source to target and preserve
397
+ audit fields (`id`, `created_at`, and `updated_at`).
398
+
391
399
  Args:
392
400
  project_source (dict): The project to get assets from
393
401
  project_target (dict): The project to push assets to
@@ -408,7 +416,8 @@ def push_project_entities(
408
416
  ):
409
417
  """
410
418
  Copy assets, episodes, sequences, shots and entity links from source to
411
- target and preserve audit fields (`id`, `created_at`, and `updated_at`)
419
+ target and preserve audit fields (`id`, `created_at`, and `updated_at`).
420
+
412
421
  Args:
413
422
  project_source (dict): The project to get assets from
414
423
  project_target (dict): The project to push assets to
@@ -445,6 +454,7 @@ def push_tasks(
445
454
  Copy tasks from source to target and preserve audit fields (`id`,
446
455
  `created_at`, and `updated_at`)
447
456
  Attachments and previews are created too.
457
+
448
458
  Args:
449
459
  project_source (dict): The project to get assets from
450
460
  project_target (dict): The project to push assets to
@@ -479,6 +489,7 @@ def push_tasks_comments(project_source, client_source, client_target):
479
489
  Create a new comment into target api for each comment in source project
480
490
  but preserve only `created_at` field.
481
491
  Attachments and previews are created too.
492
+
482
493
  Args:
483
494
  project_source (dict): The project to get assets from
484
495
  project_target (dict): The project to push assets to
@@ -508,6 +519,7 @@ def push_task_comments(
508
519
  Create a new comment into target api for each comment in source task
509
520
  but preserve only `created_at` field.
510
521
  Attachments and previews are created too.
522
+
511
523
  Args:
512
524
  project_source (dict): The project to get assets from
513
525
  project_target (dict): The project to push assets to
@@ -547,6 +559,7 @@ def push_task_comment(
547
559
  Create a new comment into target api for each comment in source task
548
560
  but preserve only `created_at` field.
549
561
  Attachments and previews are created too.
562
+
550
563
  Args:
551
564
  project_source (dict): The project to get assets from
552
565
  project_target (dict): The project to push assets to
gazu/task.py CHANGED
@@ -257,25 +257,26 @@ 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(project, task_type, client=default):
260
+ def all_tasks_for_task_type(project, task_type, episode=None, client=default):
261
261
  """
262
262
  Args:
263
263
  project (str / dict): The project dict or the project ID.
264
264
  task_type (str / dict): The task type dict or ID.
265
+ episode_id (str / dict): The episode dict or ID.
265
266
 
266
267
  Returns:
267
268
  list: Tasks for given project and task type.
268
269
  """
269
270
  project = normalize_model_parameter(project)
270
271
  task_type = normalize_model_parameter(task_type)
271
- return raw.fetch_all(
272
- "tasks",
273
- {
274
- "project_id": project["id"],
275
- "task_type_id": task_type["id"],
276
- },
277
- client=client,
278
- )
272
+ params = {
273
+ "project_id": project["id"],
274
+ "task_type_id": task_type["id"],
275
+ }
276
+ if episode is not None:
277
+ episode = normalize_model_parameter(episode)
278
+ params["episode_id"] = episode["id"]
279
+ return raw.fetch_all("tasks", params, client=client)
279
280
 
280
281
 
281
282
  @cache
@@ -526,18 +527,6 @@ def get_task_status_by_name(name, client=default):
526
527
  return raw.fetch_first("task-status", {"name": name}, client=client)
527
528
 
528
529
 
529
- @cache
530
- def get_default_task_status(client=default):
531
- """
532
- Args:
533
- name (str / dict): The name of claimed task status.
534
-
535
- Returns:
536
- dict: Task status matching given name.
537
- """
538
- return raw.fetch_first("task-status", {"is_default": True}, client=client)
539
-
540
-
541
530
  @cache
542
531
  def get_task_status_by_short_name(task_status_short_name, client=default):
543
532
  """
@@ -655,7 +644,7 @@ def new_task(
655
644
  entity = normalize_model_parameter(entity)
656
645
  task_type = normalize_model_parameter(task_type)
657
646
  if task_status is None:
658
- task_status = get_default_task_status()
647
+ task_status = get_default_task_status(client=client)
659
648
 
660
649
  data = {
661
650
  "project_id": entity["project_id"],
@@ -1260,17 +1249,28 @@ def get_task_url(task, client=default):
1260
1249
  )
1261
1250
 
1262
1251
 
1263
- def all_tasks_for_project(project, client=default):
1252
+ def all_tasks_for_project(
1253
+ project, task_type=None, episode=None, client=default
1254
+ ):
1264
1255
  """
1265
1256
  Args:
1266
- project (str / dict): The project
1257
+ project (str / dict): The project (or its ID) to get tasks from.
1258
+ task_type (str / dict): The task type (or its ID) to filter tasks.
1259
+ episode (str / dict): The episode (or its ID) to filter tasks.
1267
1260
 
1268
1261
  Returns:
1269
1262
  dict: Tasks related to given project.
1270
1263
  """
1271
1264
  project = normalize_model_parameter(project)
1272
1265
  path = "/data/projects/%s/tasks" % project["id"]
1273
- return raw.get(path, client=client)
1266
+ params = {}
1267
+ if task_type is not None:
1268
+ task_type = normalize_model_parameter(task_type)
1269
+ params["task_type_id"] = task_type["id"]
1270
+ if episode is not None:
1271
+ episode = normalize_model_parameter(episode)
1272
+ params["episode_id"] = episode["id"]
1273
+ return raw.get(path, params=params, client=client)
1274
1274
 
1275
1275
 
1276
1276
  def update_comment(comment, client=default):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gazu
3
- Version: 0.10.14
3
+ Version: 0.10.16
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
@@ -32,8 +32,8 @@ Provides-Extra: dev
32
32
  Requires-Dist: wheel ; extra == 'dev'
33
33
  Provides-Extra: lint
34
34
  Requires-Dist: autoflake ==2.3.1 ; (python_version >= "3.8") and extra == 'lint'
35
- Requires-Dist: black ==24.8.0 ; (python_version >= "3.8") and extra == 'lint'
36
- Requires-Dist: pre-commit ==3.8.0 ; (python_version >= "3.9") and extra == 'lint'
35
+ Requires-Dist: black ==24.10.0 ; (python_version >= "3.9") and extra == 'lint'
36
+ Requires-Dist: pre-commit ==4.0.1 ; (python_version >= "3.9") and extra == 'lint'
37
37
  Provides-Extra: test
38
38
  Requires-Dist: pytest ; extra == 'test'
39
39
  Requires-Dist: pytest-cov ; extra == 'test'
@@ -1,8 +1,8 @@
1
1
  gazu/__init__.py,sha256=gVhtpZsvDiPuqvsEbCrgm6fKw8hluUhqspmlgGNIAvQ,3020
2
- gazu/__version__.py,sha256=pxrMEZK-Yqtv_P8vFxygBdkn1agAyjjzQFKamP7hRcg,24
2
+ gazu/__version__.py,sha256=42JGoIUYC3OTcHv48Vyebrqa1zvt0Ul05GgS6njtjLQ,24
3
3
  gazu/asset.py,sha256=GWwam0yqHna_b9_5g5r0-O2zhMb7KlhfbIC17IOXKkY,14488
4
4
  gazu/cache.py,sha256=MnxrnfYN7wHNTTL7qzkEpYCYzWcolT56fqQ0_RegMbE,5879
5
- gazu/casting.py,sha256=5xmGMoU3MFgv1br8_5xyTx-Z7wo9r51wRisiblqcr94,3945
5
+ gazu/casting.py,sha256=0LTdsHaCTHSKEflBWFeuraSaYNYetGkMHAIdg6Lv81U,5059
6
6
  gazu/client.py,sha256=YRIxX7u095XTe28JM0tMZ05WoTcYexJGS2jrxXSAQvs,14640
7
7
  gazu/concept.py,sha256=GcOPEmkbtZcSwlX8tnUj9Q5DTPBprSxtmXhlq7ioPwk,3727
8
8
  gazu/context.py,sha256=iUyug8EUz3kkF-kmYlH5JuLp66TUqR3uhAq7CouVd_U,4349
@@ -10,20 +10,20 @@ gazu/edit.py,sha256=sPSsnzykGr1Htl6ceKulUSVHGhoQLGLeWDni3Pul7BE,4609
10
10
  gazu/encoder.py,sha256=dj8U5mlGVy0GeaA7HIIdPSRdKswUQ8h4DzjFKLhwvR0,394
11
11
  gazu/entity.py,sha256=Pbc_sbgo8RhQV88nksP1whHyWL4hVyHR3CZ0sVplPY4,3670
12
12
  gazu/events.py,sha256=GRjWsw-jeZrcBq6U8EcxiGJ8HNTdPUuamhJa0uRHeeg,1715
13
- gazu/exception.py,sha256=hWa4UQe5V36td4_jYwQSMNCJM9aDHR3P7N90Nq4fPOM,1633
13
+ gazu/exception.py,sha256=Y0kVNm6h-uXLEU1sNIbMSUep7Zxk738uYHOIVs2waM8,1880
14
14
  gazu/files.py,sha256=L82d5Bx3TkcaNczQ5t9s8DTKAcYXiqGaKUrag2cKjqI,39645
15
15
  gazu/helpers.py,sha256=Qa4JlZitiXsfYMJGGuwVaedLvHQVMbIwcqEZ099EjMw,3916
16
16
  gazu/person.py,sha256=BFh54J_R6_pIgYxAF_yAxFzjsO98hTLeBAKiZxewiK0,11098
17
- gazu/playlist.py,sha256=n7LwOF5ZvHDzP_fng-soYUESfb-S2ATmZJHGBh8cRLo,3739
17
+ gazu/playlist.py,sha256=fzrhVY0fhxp5rSlvrowZPWEOqdl4rEYD4TKmnuvyKHg,6740
18
18
  gazu/project.py,sha256=fssI_Bf5UqqRd9bfM68oyfkhjxwWvjdiAcYvvUhI5LY,12649
19
19
  gazu/scene.py,sha256=bYsy7zKdQfDTfeqNAlgaqGMs2Hhxdy40NGt6TX_FBdA,5307
20
20
  gazu/shot.py,sha256=mHg-8B7xk3PXMqbPo0oCx2X7br2sGCBmuM7hEhpXRas,18942
21
21
  gazu/sorting.py,sha256=qSIO0pOHkj0Tl4gm9BJrYrcifWGGGmsW68Pl86zB_bg,266
22
- gazu/sync.py,sha256=OMsbQDROTdEwlukazUXPGnlC29QcaaHvsmqv3WsSexo,21582
23
- gazu/task.py,sha256=623td4cjNAqXQgQrD9opvxt2P8okv6rHNx-NYsGjVKg,35999
22
+ gazu/sync.py,sha256=0ZJ5Z7Nuh5Kj4cswZCXLpXTLf8zQRcXsBLnurMw-i_E,21627
23
+ gazu/task.py,sha256=rnOKunR-vXLQPkD5nOufPhppYLLkgAWZS9tYlutCMp0,36412
24
24
  gazu/user.py,sha256=GyJf6mrynHvLllw3Hsiv-6wjaYTHO_PBNkJzyJjJA1A,9556
25
- gazu-0.10.14.dist-info/LICENSE,sha256=2n6rt7r999OuXp8iOqW9we7ORaxWncIbOwN1ILRGR2g,7651
26
- gazu-0.10.14.dist-info/METADATA,sha256=LRU9C0EJ10NXRe3C2VE3nsnaga6k9jn3NDS-z9xpZgs,5263
27
- gazu-0.10.14.dist-info/WHEEL,sha256=XRxW4r1PNiVhMpP4bT9oWtu3HyndxpJ84SkubFgzp_Y,109
28
- gazu-0.10.14.dist-info/top_level.txt,sha256=nv7fRIVpYYyIlk_66hBmMyvWcSC7UU-r-GE8uC1u1Go,5
29
- gazu-0.10.14.dist-info/RECORD,,
25
+ gazu-0.10.16.dist-info/LICENSE,sha256=2n6rt7r999OuXp8iOqW9we7ORaxWncIbOwN1ILRGR2g,7651
26
+ gazu-0.10.16.dist-info/METADATA,sha256=izhNmWl2_06y8RzzDu1iLROBuFhKJU3R8_HJX0Rb3-Y,5264
27
+ gazu-0.10.16.dist-info/WHEEL,sha256=AHX6tWk3qWuce7vKLrj7lnulVHEdWoltgauo8bgCXgU,109
28
+ gazu-0.10.16.dist-info/top_level.txt,sha256=nv7fRIVpYYyIlk_66hBmMyvWcSC7UU-r-GE8uC1u1Go,5
29
+ gazu-0.10.16.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (72.1.0)
2
+ Generator: setuptools (75.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py2-none-any
5
5
  Tag: py3-none-any