gazu 1.0.2__py2.py3-none-any.whl → 1.1.0__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/shot.py CHANGED
@@ -1,14 +1,23 @@
1
+ from __future__ import annotations
2
+
3
+ from typing_extensions import Literal
4
+
5
+ import requests
6
+
1
7
  from . import client as raw
2
8
 
3
9
  from .sorting import sort_by_name
4
10
  from .cache import cache
11
+ from .client import KitsuClient
5
12
  from .helpers import normalize_model_parameter
6
13
 
7
14
  default = raw.default_client
8
15
 
9
16
 
10
17
  @cache
11
- def all_previews_for_shot(shot, client=default):
18
+ def all_previews_for_shot(
19
+ shot: str | dict, client: KitsuClient = default
20
+ ) -> list[dict]:
12
21
  """
13
22
  Args:
14
23
  shot (str / dict): The shot dict or the shot ID.
@@ -21,7 +30,9 @@ def all_previews_for_shot(shot, client=default):
21
30
 
22
31
 
23
32
  @cache
24
- def all_shots_for_project(project, client=default):
33
+ def all_shots_for_project(
34
+ project: str | dict, client: KitsuClient = default
35
+ ) -> list[dict]:
25
36
  """
26
37
  Args:
27
38
  project (str / dict): The project dict or the project ID.
@@ -35,7 +46,9 @@ def all_shots_for_project(project, client=default):
35
46
 
36
47
 
37
48
  @cache
38
- def all_shots_for_episode(episode, client=default):
49
+ def all_shots_for_episode(
50
+ episode: str | dict, client: KitsuClient = default
51
+ ) -> list[dict]:
39
52
  """
40
53
  Args:
41
54
  episode (str / dict): The episode dict or the episode ID.
@@ -50,7 +63,9 @@ def all_shots_for_episode(episode, client=default):
50
63
 
51
64
 
52
65
  @cache
53
- def all_shots_for_sequence(sequence, client=default):
66
+ def all_shots_for_sequence(
67
+ sequence: str | dict, client: KitsuClient = default
68
+ ) -> list[dict]:
54
69
  """
55
70
  Args:
56
71
  sequence (str / dict): The sequence dict or the sequence ID.
@@ -65,7 +80,9 @@ def all_shots_for_sequence(sequence, client=default):
65
80
 
66
81
 
67
82
  @cache
68
- def all_sequences_for_project(project, client=default):
83
+ def all_sequences_for_project(
84
+ project: str | dict, client: KitsuClient = default
85
+ ) -> list[dict]:
69
86
  """
70
87
  Args:
71
88
  sequence (str / dict): The project dict or the project ID.
@@ -80,10 +97,12 @@ def all_sequences_for_project(project, client=default):
80
97
 
81
98
 
82
99
  @cache
83
- def all_sequences_for_episode(episode, client=default):
100
+ def all_sequences_for_episode(
101
+ episode: str | dict, client: KitsuClient = default
102
+ ) -> list[dict]:
84
103
  """
85
104
  Args:
86
- sequence (str / dict): The episode dict or the episode ID.
105
+ episode (str / dict): The episode dict or the episode ID.
87
106
 
88
107
  Returns:
89
108
  list: Sequences which are children of given episode.
@@ -95,7 +114,9 @@ def all_sequences_for_episode(episode, client=default):
95
114
 
96
115
 
97
116
  @cache
98
- def all_episodes_for_project(project, client=default):
117
+ def all_episodes_for_project(
118
+ project: str | dict, client: KitsuClient = default
119
+ ) -> list[dict]:
99
120
  """
100
121
  Args:
101
122
  project (str / dict): The project dict or the project ID.
@@ -110,7 +131,7 @@ def all_episodes_for_project(project, client=default):
110
131
 
111
132
 
112
133
  @cache
113
- def get_episode(episode_id, client=default):
134
+ def get_episode(episode_id: str, client: KitsuClient = default) -> dict:
114
135
  """
115
136
  Args:
116
137
  episode_id (str): ID of claimed episode.
@@ -122,7 +143,9 @@ def get_episode(episode_id, client=default):
122
143
 
123
144
 
124
145
  @cache
125
- def get_episode_by_name(project, episode_name, client=default):
146
+ def get_episode_by_name(
147
+ project: str | dict, episode_name: str, client: KitsuClient = default
148
+ ) -> dict | None:
126
149
  """
127
150
  Args:
128
151
  project (str / dict): The project dict or the project ID.
@@ -140,7 +163,9 @@ def get_episode_by_name(project, episode_name, client=default):
140
163
 
141
164
 
142
165
  @cache
143
- def get_episode_from_sequence(sequence, client=default):
166
+ def get_episode_from_sequence(
167
+ sequence: dict, client: KitsuClient = default
168
+ ) -> dict | None:
144
169
  """
145
170
  Args:
146
171
  sequence (dict): The sequence dict.
@@ -155,7 +180,7 @@ def get_episode_from_sequence(sequence, client=default):
155
180
 
156
181
 
157
182
  @cache
158
- def get_sequence(sequence_id, client=default):
183
+ def get_sequence(sequence_id: str, client: KitsuClient = default) -> dict:
159
184
  """
160
185
  Args:
161
186
  sequence_id (str): ID of claimed sequence.
@@ -167,7 +192,12 @@ def get_sequence(sequence_id, client=default):
167
192
 
168
193
 
169
194
  @cache
170
- def get_sequence_by_name(project, sequence_name, episode=None, client=default):
195
+ def get_sequence_by_name(
196
+ project: str | dict,
197
+ sequence_name: str,
198
+ episode: str | dict | None = None,
199
+ client: KitsuClient = default,
200
+ ) -> dict | None:
171
201
  """
172
202
  Args:
173
203
  project (str / dict): The project dict or the project ID.
@@ -188,10 +218,10 @@ def get_sequence_by_name(project, sequence_name, episode=None, client=default):
188
218
 
189
219
 
190
220
  @cache
191
- def get_sequence_from_shot(shot, client=default):
221
+ def get_sequence_from_shot(shot: dict, client: KitsuClient = default) -> dict:
192
222
  """
193
223
  Args:
194
- shot (str / dict): The shot dict or the shot ID.
224
+ shot (dict): The shot dict.
195
225
 
196
226
  Returns:
197
227
  dict: Sequence which is parent of given shot.
@@ -201,7 +231,7 @@ def get_sequence_from_shot(shot, client=default):
201
231
 
202
232
 
203
233
  @cache
204
- def get_shot(shot_id, client=default):
234
+ def get_shot(shot_id: str, client: KitsuClient = default) -> dict:
205
235
  """
206
236
  Args:
207
237
  shot_id (str): ID of claimed shot.
@@ -213,7 +243,9 @@ def get_shot(shot_id, client=default):
213
243
 
214
244
 
215
245
  @cache
216
- def get_shot_by_name(sequence, shot_name, client=default):
246
+ def get_shot_by_name(
247
+ sequence: str | dict, shot_name: str, client: KitsuClient = default
248
+ ) -> dict | None:
217
249
  """
218
250
  Args:
219
251
  sequence (str / dict): The sequence dict or the sequence ID.
@@ -231,7 +263,7 @@ def get_shot_by_name(sequence, shot_name, client=default):
231
263
 
232
264
 
233
265
  @cache
234
- def get_episode_url(episode, client=default):
266
+ def get_episode_url(episode: str | dict, client: KitsuClient = default) -> str:
235
267
  """
236
268
  Args:
237
269
  episode (str / dict): The episode dict or the episode ID.
@@ -250,7 +282,7 @@ def get_episode_url(episode, client=default):
250
282
 
251
283
 
252
284
  @cache
253
- def get_shot_url(shot, client=default):
285
+ def get_shot_url(shot: str | dict, client: KitsuClient = default) -> str:
254
286
  """
255
287
  Args:
256
288
  shot (str / dict): The shot dict or the shot ID.
@@ -273,7 +305,12 @@ def get_shot_url(shot, client=default):
273
305
  )
274
306
 
275
307
 
276
- def new_sequence(project, name, episode=None, client=default):
308
+ def new_sequence(
309
+ project: str | dict,
310
+ name: str,
311
+ episode: str | dict | None = None,
312
+ client: KitsuClient = default,
313
+ ) -> dict:
277
314
  """
278
315
  Create a sequence for given project and episode.
279
316
 
@@ -283,7 +320,7 @@ def new_sequence(project, name, episode=None, client=default):
283
320
  name (str): The name of the sequence to create.
284
321
 
285
322
  Returns:
286
- Created sequence.
323
+ dict: Created sequence.
287
324
  """
288
325
  project = normalize_model_parameter(project)
289
326
  data = {"name": name}
@@ -303,16 +340,16 @@ def new_sequence(project, name, episode=None, client=default):
303
340
 
304
341
 
305
342
  def new_shot(
306
- project,
307
- sequence,
308
- name,
309
- nb_frames=None,
310
- frame_in=None,
311
- frame_out=None,
312
- description=None,
313
- data={},
314
- client=default,
315
- ):
343
+ project: str | dict,
344
+ sequence: str | dict,
345
+ name: str,
346
+ nb_frames: int | None = None,
347
+ frame_in: int | None = None,
348
+ frame_out: int | None = None,
349
+ description: str | None = None,
350
+ data: dict = {},
351
+ client: KitsuClient = default,
352
+ ) -> dict:
316
353
  """
317
354
  Create a shot for given sequence and project. Add frame in and frame out
318
355
  parameters to shot extra data. Allow to set metadata too.
@@ -321,12 +358,12 @@ def new_shot(
321
358
  project (str / dict): The project dict or the project ID.
322
359
  sequence (str / dict): The sequence dict or the sequence ID.
323
360
  name (str): The name of the shot to create.
324
- frame_in (int):
325
- frame_out (int):
361
+ frame_in (int): Frame in value for the shot.
362
+ frame_out (int): Frame out value for the shot.
326
363
  data (dict): Free field to set metadata of any kind.
327
364
 
328
365
  Returns:
329
- Created shot.
366
+ dict: Created shot.
330
367
  """
331
368
  project = normalize_model_parameter(project)
332
369
  sequence = normalize_model_parameter(sequence)
@@ -351,7 +388,7 @@ def new_shot(
351
388
  return shot
352
389
 
353
390
 
354
- def update_shot(shot, client=default):
391
+ def update_shot(shot: dict, client: KitsuClient = default) -> dict:
355
392
  """
356
393
  Save given shot data into the API. Metadata are fully replaced by the ones
357
394
  set on given shot.
@@ -365,7 +402,7 @@ def update_shot(shot, client=default):
365
402
  return raw.put("data/entities/%s" % shot["id"], shot, client=client)
366
403
 
367
404
 
368
- def update_sequence(sequence, client=default):
405
+ def update_sequence(sequence: dict, client: KitsuClient = default) -> dict:
369
406
  """
370
407
  Save given sequence data into the API. Metadata are fully replaced by the
371
408
  ones set on given sequence.
@@ -382,7 +419,9 @@ def update_sequence(sequence, client=default):
382
419
 
383
420
 
384
421
  @cache
385
- def get_asset_instances_for_shot(shot, client=default):
422
+ def get_asset_instances_for_shot(
423
+ shot: str | dict, client: KitsuClient = default
424
+ ) -> list[dict]:
386
425
  """
387
426
  Return the list of asset instances linked to given shot.
388
427
  """
@@ -390,13 +429,15 @@ def get_asset_instances_for_shot(shot, client=default):
390
429
  return raw.get("data/shots/%s/asset-instances" % shot["id"], client=client)
391
430
 
392
431
 
393
- def update_shot_data(shot, data={}, client=default):
432
+ def update_shot_data(
433
+ shot: str | dict, data: dict = {}, client: KitsuClient = default
434
+ ) -> dict:
394
435
  """
395
436
  Update the metadata for the provided shot. Keys that are not provided are
396
437
  not changed.
397
438
 
398
439
  Args:
399
- shot (dict / ID): The shot dict or ID to save in database.
440
+ shot (str / dict): The shot dict or ID to save in database.
400
441
  data (dict): Free field to set metadata of any kind.
401
442
 
402
443
  Returns:
@@ -412,13 +453,15 @@ def update_shot_data(shot, data={}, client=default):
412
453
  return update_shot(updated_shot, client=client)
413
454
 
414
455
 
415
- def update_sequence_data(sequence, data={}, client=default):
456
+ def update_sequence_data(
457
+ sequence: str | dict, data: dict = {}, client: KitsuClient = default
458
+ ) -> dict:
416
459
  """
417
460
  Update the metadata for the provided sequence. Keys that are not provided
418
461
  are not changed.
419
462
 
420
463
  Args:
421
- sequence (dict / ID): The sequence dicto or ID to save in database.
464
+ sequence (str / dict): The sequence dicto or ID to save in database.
422
465
  data (dict): Free field to set metadata of any kind.
423
466
 
424
467
  Returns:
@@ -438,12 +481,20 @@ def update_sequence_data(sequence, data={}, client=default):
438
481
  return update_sequence(updated_sequence, client)
439
482
 
440
483
 
441
- def remove_shot(shot, force=False, client=default):
484
+ def remove_shot(
485
+ shot: str | dict, force: bool = False, client: KitsuClient = default
486
+ ) -> str:
442
487
  """
443
488
  Remove given shot from database.
444
489
 
490
+ If the Shot has tasks linked to it, this will by default mark the
491
+ Shot as canceled. Deletion can be forced regardless of task links
492
+ with the `force` parameter.
493
+
445
494
  Args:
446
- shot (dict / str): Shot to remove.
495
+ shot (str / dict): Shot to remove.
496
+ force (bool): Whether to force deletion of the asset regardless of
497
+ whether it has links to tasks.
447
498
  """
448
499
  shot = normalize_model_parameter(shot)
449
500
  path = "data/shots/%s" % shot["id"]
@@ -453,12 +504,12 @@ def remove_shot(shot, force=False, client=default):
453
504
  return raw.delete(path, params, client=client)
454
505
 
455
506
 
456
- def restore_shot(shot, client=default):
507
+ def restore_shot(shot: str | dict, client: KitsuClient = default) -> dict:
457
508
  """
458
509
  Restore given shot into database (uncancel it).
459
510
 
460
511
  Args:
461
- shot (dict / str): Shot to restore.
512
+ shot (str / dict): Shot to restore.
462
513
  """
463
514
  shot = normalize_model_parameter(shot)
464
515
  path = "data/shots/%s" % shot["id"]
@@ -466,7 +517,9 @@ def restore_shot(shot, client=default):
466
517
  return raw.put(path, data, client=client)
467
518
 
468
519
 
469
- def new_episode(project, name, client=default):
520
+ def new_episode(
521
+ project: str | dict, name: str, client: KitsuClient = default
522
+ ) -> dict:
470
523
  """
471
524
  Create an episode for given project.
472
525
 
@@ -488,7 +541,7 @@ def new_episode(project, name, client=default):
488
541
  return episode
489
542
 
490
543
 
491
- def update_episode(episode, client=default):
544
+ def update_episode(episode: dict, client: KitsuClient = default) -> dict:
492
545
  """
493
546
  Save given episode data into the API. Metadata are fully replaced by the
494
547
  ones set on given episode.
@@ -502,13 +555,15 @@ def update_episode(episode, client=default):
502
555
  return raw.put("data/entities/%s" % episode["id"], episode, client=client)
503
556
 
504
557
 
505
- def update_episode_data(episode, data={}, client=default):
558
+ def update_episode_data(
559
+ episode: str | dict, data: dict = {}, client: KitsuClient = default
560
+ ) -> dict:
506
561
  """
507
562
  Update the metadata for the provided episode. Keys that are not provided
508
563
  are not changed.
509
564
 
510
565
  Args:
511
- episode (dict / ID): The episode dict or ID to save in database.
566
+ episode (str / dict): The episode dict or ID to save in database.
512
567
  data (dict): Free field to set metadata of any kind.
513
568
 
514
569
  Returns:
@@ -524,12 +579,27 @@ def update_episode_data(episode, data={}, client=default):
524
579
  return update_episode(updated_episode, client=client)
525
580
 
526
581
 
527
- def remove_episode(episode, force=False, client=default):
582
+ def remove_episode(
583
+ episode: str | dict, force: bool = False, client: KitsuClient = default
584
+ ) -> str:
528
585
  """
529
586
  Remove given episode and related from database.
530
587
 
588
+ If the `force` paramter is True, all records linked to the Episode will
589
+ also be deleted - including all linked Sequences, Shots, Assets, Playlists
590
+ and Tasks.
591
+
592
+ Otherwise, it will attempt to only delete the Episode entity. If the
593
+ Episode has any linked records the operation will fail.
594
+
531
595
  Args:
532
- episode (dict / str): Episode to remove.
596
+ episode (str / dict): Episode to remove.
597
+ force (bool): Whether to delete all data linked to the Episode as well.
598
+
599
+ Raises:
600
+ ParameterException:
601
+ If the Episode has linked entities and the force=True parameter
602
+ has not been provided.
533
603
  """
534
604
  episode = normalize_model_parameter(episode)
535
605
  path = "data/episodes/%s" % episode["id"]
@@ -539,12 +609,26 @@ def remove_episode(episode, force=False, client=default):
539
609
  return raw.delete(path, params=params, client=client)
540
610
 
541
611
 
542
- def remove_sequence(sequence, force=False, client=default):
612
+ def remove_sequence(
613
+ sequence: str | dict, force: bool = False, client: KitsuClient = default
614
+ ) -> str:
543
615
  """
544
616
  Remove given sequence and related from database.
545
617
 
618
+ If the `force` paramter is True, all records linked to the Sequence will
619
+ also be deleted - including all linked Shots and Tasks.
620
+
621
+ Otherwise, it will attempt to only delete the Sequence entity. If the
622
+ Sequence has any linked records the operation will fail.
623
+
546
624
  Args:
547
- sequence (dict / str): Sequence to remove.
625
+ sequence (str / dict): Sequence to remove.
626
+ force (bool): Whether to delete all data linked to the Sequence as well.
627
+
628
+ Raises:
629
+ ParameterException:
630
+ If the Sequence has linked entities and the force=True parameter
631
+ has not been provided.
548
632
  """
549
633
  sequence = normalize_model_parameter(sequence)
550
634
  path = "data/sequences/%s" % sequence["id"]
@@ -555,7 +639,9 @@ def remove_sequence(sequence, force=False, client=default):
555
639
 
556
640
 
557
641
  @cache
558
- def all_asset_instances_for_shot(shot, client=default):
642
+ def all_asset_instances_for_shot(
643
+ shot: str | dict, client: KitsuClient = default
644
+ ) -> list[dict]:
559
645
  """
560
646
  Args:
561
647
  shot (str / dict): The shot dict or the shot ID.
@@ -567,7 +653,9 @@ def all_asset_instances_for_shot(shot, client=default):
567
653
  return raw.get("data/shots/%s/asset-instances" % shot["id"], client=client)
568
654
 
569
655
 
570
- def add_asset_instance_to_shot(shot, asset_instance, client=default):
656
+ def add_asset_instance_to_shot(
657
+ shot: str | dict, asset_instance: str | dict, client: KitsuClient = default
658
+ ) -> dict:
571
659
  """
572
660
  Link a new asset instance to given shot.
573
661
 
@@ -585,7 +673,9 @@ def add_asset_instance_to_shot(shot, asset_instance, client=default):
585
673
  return raw.post(path, data, client=client)
586
674
 
587
675
 
588
- def remove_asset_instance_from_shot(shot, asset_instance, client=default):
676
+ def remove_asset_instance_from_shot(
677
+ shot: str | dict, asset_instance: str | dict, client: KitsuClient = default
678
+ ) -> str:
589
679
  """
590
680
  Remove link between an asset instance and given shot.
591
681
 
@@ -602,13 +692,20 @@ def remove_asset_instance_from_shot(shot, asset_instance, client=default):
602
692
  return raw.delete(path, client=client)
603
693
 
604
694
 
605
- def import_shots_with_csv(project, csv_file_path, client=default):
695
+ def import_shots_with_csv(
696
+ project: str | dict, csv_file_path: str, client: KitsuClient = default
697
+ ) -> list[dict]:
606
698
  """
607
- Import shots from a csv file.
699
+ Import the Shots from a previously exported CSV file into the given
700
+ project.
608
701
 
609
702
  Args:
610
- project (str / dict): The project dict or the project ID.
611
- csv_file_path (str): The csv file path.
703
+ project (str / dict): The project to import the Shots into, as an ID
704
+ string or model dict.
705
+ csv_file_path (str): The path on disk to the CSV file.
706
+
707
+ Returns:
708
+ list[dict]: the Shot dicts created by the import.
612
709
  """
613
710
  project = normalize_model_parameter(project)
614
711
  return raw.upload(
@@ -619,13 +716,13 @@ def import_shots_with_csv(project, csv_file_path, client=default):
619
716
 
620
717
 
621
718
  def import_otio(
622
- project,
623
- otio_file_path,
624
- episode=None,
625
- naming_convention=None,
626
- match_case=True,
627
- client=default,
628
- ):
719
+ project: str | dict,
720
+ otio_file_path: str,
721
+ episode: str | dict | None = None,
722
+ naming_convention: str | None = None,
723
+ match_case: bool = True,
724
+ client: KitsuClient = default,
725
+ ) -> dict[Literal["created_shots", "updated_shots"], list[dict]]:
629
726
  """
630
727
  Import shots from an OpenTimelineIO file (works also for every OTIO
631
728
  adapters).
@@ -634,6 +731,12 @@ def import_otio(
634
731
  project (str / dict): The project dict or the project ID.
635
732
  otio_file_path (str): The OTIO file path.
636
733
  episode (str / dict): The episode dict or the episode ID.
734
+ naming_convention (str): Template for matching shot names from the file.
735
+ match_case (bool): Whether to match shot names case-sensitively.
736
+
737
+ Returns:
738
+ dict: A dictionary with keys "created_shots" and "updated_shots", each
739
+ mapping to a list of altered entity records from the import.
637
740
  """
638
741
  if naming_convention is None:
639
742
  if episode is not None:
@@ -659,16 +762,32 @@ def import_otio(
659
762
 
660
763
 
661
764
  def export_shots_with_csv(
662
- project, csv_file_path, episode=None, assigned_to=None, client=default
663
- ):
664
- """
665
- Export shots in a csv file.
765
+ project: str | dict,
766
+ csv_file_path: str,
767
+ episode: str | dict | None = None,
768
+ assigned_to: str | dict | None = None,
769
+ client: KitsuClient = default,
770
+ ) -> requests.Response:
771
+ """
772
+ Export the Assets data for a project to a CSV file on disk.
773
+
774
+ Args:
775
+ project (str / dict):
776
+ The ID or dict for the project to export.
777
+ csv_file_path (str):
778
+ The path on disk to write the CSV file to. If the path already
779
+ exists it will be overwritten.
780
+ episode (str | dict | None):
781
+ Only export Shots that are linked to the given Episode, which can
782
+ be provided as an ID string or model dict. If None, all assets will
783
+ be exported.
784
+ assigned_to (str | dict | None):
785
+ Only export Shots that have one or more Tasks assigned to the
786
+ given Person, specified as an ID string or model dict. If None,
787
+ no filtering is put in place.
666
788
 
667
- Args:
668
- project (str / dict): The project dict or the project ID.
669
- csv_file_path (str): The csv file path.
670
- episode (str / dict): The episode dict or the episode ID (optional).
671
- assigned_to (str / dict): The user dict or the user ID (optional).
789
+ Returns:
790
+ (requests.Response): the response from the API server.
672
791
  """
673
792
  project = normalize_model_parameter(project)
674
793
  episode = normalize_model_parameter(episode)
gazu/sorting.py CHANGED
@@ -1,4 +1,7 @@
1
- def sort_by_name(dicts):
1
+ from __future__ import annotations
2
+
3
+
4
+ def sort_by_name(dicts: list[dict]) -> list[dict]:
2
5
  """
3
6
  Sorting of a list of dicts. The sorting is based on the name field.
4
7