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/casting.py CHANGED
@@ -1,22 +1,32 @@
1
+ from __future__ import annotations
2
+
1
3
  from . import client as raw
2
4
 
5
+ from .client import KitsuClient
6
+
3
7
  from .helpers import normalize_model_parameter
4
8
 
5
9
  default = raw.default_client
6
10
 
7
11
 
8
- def update_shot_casting(project, shot, casting, client=default):
12
+ def update_shot_casting(
13
+ project: str | dict,
14
+ shot: str | dict,
15
+ casting: dict,
16
+ client: KitsuClient = default,
17
+ ) -> dict:
9
18
  """
10
19
  Change casting of given shot with given casting (list of asset ids displayed
11
20
  into the shot).
12
21
 
13
22
  Args:
23
+ project (str / dict): The project dictionary or ID.
14
24
  shot (str / dict): The shot dict or the shot ID.
15
25
  casting (dict): The casting description.
16
26
  Ex: `casting = [{"asset_id": "asset-1", "nb_occurences": 3}]`
17
27
 
18
28
  Returns:
19
- dict: Related shot.
29
+ dict: The updated shot dictionary with the new casting information applied.
20
30
  """
21
31
  shot = normalize_model_parameter(shot)
22
32
  project = normalize_model_parameter(project)
@@ -24,17 +34,23 @@ def update_shot_casting(project, shot, casting, client=default):
24
34
  return raw.put(path, casting, client=client)
25
35
 
26
36
 
27
- def update_asset_casting(project, asset, casting, client=default):
37
+ def update_asset_casting(
38
+ project: str | dict,
39
+ asset: str | dict,
40
+ casting: dict,
41
+ client: KitsuClient = default,
42
+ ) -> dict:
28
43
  """
29
44
  Change casting of given asset with given casting (list of asset ids
30
45
  displayed into the asset).
31
46
 
32
47
  Args:
48
+ project (str / dict): The project dict or asset ID.
33
49
  asset (str / dict): The asset dict or the asset ID.
34
50
  casting (dict): The casting description.
35
51
 
36
52
  Returns:
37
- dict: Related asset.
53
+ dict: The updated asset dictionary with the new casting information applied.
38
54
  """
39
55
  asset = normalize_model_parameter(asset)
40
56
  project = normalize_model_parameter(project)
@@ -45,18 +61,23 @@ def update_asset_casting(project, asset, casting, client=default):
45
61
  return raw.put(path, casting, client=client)
46
62
 
47
63
 
48
- def update_episode_casting(project, episode, casting, client=default):
64
+ def update_episode_casting(
65
+ project: str | dict,
66
+ episode: str | dict,
67
+ casting: dict,
68
+ client: KitsuClient = default,
69
+ ) -> dict:
49
70
  """
50
71
  Change casting of given episode with given casting (list of asset ids displayed
51
72
  into the episode).
52
73
 
53
74
  Args:
75
+ project (str / dict): The project dict or ID.
54
76
  episode (str / dict): The episode dict or the episode ID.
55
77
  casting (dict): The casting description.
56
- Ex: `casting = [{"asset_id": "asset-1", "nb_occurences": 3}]`
57
-
78
+ e.g: `casting = [{"asset_id": "asset-1", "nb_occurences": 3}]`
58
79
  Returns:
59
- dict: Related episode.
80
+ dict: The updated episode dictionary with the new casting information applied.
60
81
  """
61
82
  episode = normalize_model_parameter(episode)
62
83
  project = normalize_model_parameter(project)
@@ -67,7 +88,9 @@ def update_episode_casting(project, episode, casting, client=default):
67
88
  return raw.put(path, casting, client=client)
68
89
 
69
90
 
70
- def get_asset_type_casting(project, asset_type, client=default):
91
+ def get_asset_type_casting(
92
+ project: str | dict, asset_type: str | dict, client: KitsuClient = default
93
+ ) -> dict:
71
94
  """
72
95
  Return casting for given asset_type.
73
96
 
@@ -76,7 +99,9 @@ def get_asset_type_casting(project, asset_type, client=default):
76
99
  asset_type (str / dict): The asset_type dict or the asset_type ID.
77
100
 
78
101
  Returns:
79
- dict: Casting of the given asset_type.
102
+ dict: A dictionary mapping asset IDs to their casting lists. Each casting
103
+ list contains dictionaries with "asset_id" and "nb_occurences" keys
104
+ representing which assets are cast in each asset of this type.
80
105
  """
81
106
 
82
107
  project = normalize_model_parameter(project)
@@ -88,7 +113,9 @@ def get_asset_type_casting(project, asset_type, client=default):
88
113
  return raw.get(path, client=client)
89
114
 
90
115
 
91
- def get_sequence_casting(sequence, client=default):
116
+ def get_sequence_casting(
117
+ sequence: dict, client: KitsuClient = default
118
+ ) -> dict:
92
119
  """
93
120
  Return casting for given sequence.
94
121
 
@@ -96,7 +123,9 @@ def get_sequence_casting(sequence, client=default):
96
123
  sequence (dict): The sequence dict
97
124
 
98
125
  Returns:
99
- dict: Casting of the given sequence.
126
+ dict: A dictionary mapping shot IDs to their casting lists. Each casting
127
+ list contains dictionaries with "asset_id" and "nb_occurences" keys
128
+ representing which assets are cast in each shot of the sequence.
100
129
  """
101
130
  path = "/data/projects/%s/sequences/%s/casting" % (
102
131
  sequence["project_id"],
@@ -105,7 +134,7 @@ def get_sequence_casting(sequence, client=default):
105
134
  return raw.get(path, client=client)
106
135
 
107
136
 
108
- def get_shot_casting(shot, client=default):
137
+ def get_shot_casting(shot: dict, client: KitsuClient = default) -> dict:
109
138
  """
110
139
  Return casting for given shot.
111
140
 
@@ -113,7 +142,9 @@ def get_shot_casting(shot, client=default):
113
142
  shot (dict): The shot dict
114
143
 
115
144
  Returns:
116
- dict: Casting of the given shot.
145
+ list[dict]: A list of casting dictionaries, each containing "asset_id"
146
+ and "nb_occurences" keys representing which assets are cast in the shot
147
+ and how many times they appear.
117
148
  """
118
149
  path = "/data/projects/%s/entities/%s/casting" % (
119
150
  shot["project_id"],
@@ -122,15 +153,18 @@ def get_shot_casting(shot, client=default):
122
153
  return raw.get(path, client=client)
123
154
 
124
155
 
125
- def get_asset_casting(asset, client=default):
156
+ def get_asset_casting(asset: dict, client: KitsuClient = default) -> dict:
126
157
  """
127
158
  Return casting for given asset.
128
159
  `[{"asset_id": "asset-1", "nb_occurences": 3}]}`
160
+
129
161
  Args:
130
162
  asset (dict): The asset dict
131
163
 
132
164
  Returns:
133
- dict: Casting for given asset.
165
+ list[dict]: A list of casting dictionaries, each containing "asset_id"
166
+ and "nb_occurences" keys representing which assets are cast in the
167
+ given asset and how many times they appear.
134
168
  """
135
169
  path = "/data/projects/%s/entities/%s/casting" % (
136
170
  asset["project_id"],
@@ -139,15 +173,18 @@ def get_asset_casting(asset, client=default):
139
173
  return raw.get(path, client=client)
140
174
 
141
175
 
142
- def get_episode_casting(episode, client=default):
176
+ def get_episode_casting(episode: dict, client: KitsuClient = default) -> dict:
143
177
  """
144
178
  Return casting for given episode.
145
179
  `[{"episode_id": "episode-1", "nb_occurences": 3}]}`
180
+
146
181
  Args:
147
182
  episode (dict): The episode dict
148
183
 
149
184
  Returns:
150
- dict: Casting for given episode.
185
+ list[dict]: A list of casting dictionaries, each containing "asset_id"
186
+ and "nb_occurences" keys representing which assets are cast in the
187
+ episode and how many times they appear.
151
188
  """
152
189
  path = "/data/projects/%s/entities/%s/casting" % (
153
190
  episode["project_id"],
@@ -156,14 +193,19 @@ def get_episode_casting(episode, client=default):
156
193
  return raw.get(path, client=client)
157
194
 
158
195
 
159
- def get_asset_cast_in(asset, client=default):
196
+ def get_asset_cast_in(
197
+ asset: str | dict, client: KitsuClient = default
198
+ ) -> dict:
160
199
  """
161
200
  Return entity list where given asset is casted.
201
+
162
202
  Args:
163
- asset (dict): The asset dict
203
+ asset (dict): The asset dict or ID.
164
204
 
165
205
  Returns:
166
- dict: Entity list where given asset is casted.
206
+ list[dict]: A list of entity dictionaries (shots, scenes, etc.) where
207
+ the given asset is cast. Each entity dict contains standard entity
208
+ fields like "id", "name", "project_id", etc.
167
209
  """
168
210
  asset = normalize_model_parameter(asset)
169
211
  path = "/data/assets/%s/cast-in" % asset["id"]
@@ -171,14 +213,21 @@ def get_asset_cast_in(asset, client=default):
171
213
 
172
214
 
173
215
  def all_entity_links_for_project(
174
- project, page=None, limit=None, client=default
175
- ):
216
+ project: str | dict,
217
+ page: int | None = None,
218
+ limit: int | None = None,
219
+ client: KitsuClient = default,
220
+ ) -> dict:
176
221
  """
177
222
  Args:
178
- project (dict): The project
223
+ project (dict | str): The project dict or ID.
179
224
 
180
225
  Returns:
181
- dict: Entity links for given project.
226
+ dict: A dictionary containing entity links for the project. If pagination
227
+ is used, contains "data" (list of entity link dicts) and pagination
228
+ metadata. Otherwise, returns a list of entity link dictionaries directly.
229
+ Each entity link dict contains "entity_in_id", "entity_out_id", and
230
+ other link-related fields.
182
231
  """
183
232
  project = normalize_model_parameter(project)
184
233
  path = "/data/projects/%s/entity-links" % project["id"]
@@ -188,3 +237,107 @@ def all_entity_links_for_project(
188
237
  if limit is not None:
189
238
  params["limit"] = limit
190
239
  return raw.get(path, params=params, client=client)
240
+
241
+
242
+ def get_episodes_casting(
243
+ project: str | dict, client: KitsuClient = default
244
+ ) -> dict:
245
+ """
246
+ Return casting for all episodes in given project.
247
+
248
+ Args:
249
+ project (str / dict): The project dict or the project ID.
250
+
251
+ Returns:
252
+ dict: A dictionary mapping episode IDs to their casting lists. Each
253
+ casting list contains dictionaries with "asset_id" and "nb_occurences"
254
+ keys representing which assets are cast in each episode.
255
+ """
256
+ project = normalize_model_parameter(project)
257
+ path = "/data/projects/%s/episodes/casting" % project["id"]
258
+ return raw.get(path, client=client)
259
+
260
+
261
+ def get_sequence_shots_casting(
262
+ project: str | dict, sequence: str | dict, client: KitsuClient = default
263
+ ) -> dict:
264
+ """
265
+ Return casting for all shots in given sequence.
266
+
267
+ Args:
268
+ project (str / dict): The project dict or the project ID.
269
+ sequence (str / dict): The sequence dict or the sequence ID.
270
+
271
+ Returns:
272
+ dict: A dictionary mapping shot IDs to their casting lists. Each casting
273
+ list contains dictionaries with "asset_id" and "nb_occurences" keys
274
+ representing which assets are cast in each shot of the sequence.
275
+ """
276
+ project = normalize_model_parameter(project)
277
+ sequence = normalize_model_parameter(sequence)
278
+ path = "/data/projects/%s/sequences/%s/shots/casting" % (
279
+ project["id"],
280
+ sequence["id"],
281
+ )
282
+ return raw.get(path, client=client)
283
+
284
+
285
+ def get_episode_shots_casting(
286
+ project: str | dict, episode: str | dict, client: KitsuClient = default
287
+ ) -> dict:
288
+ """
289
+ Return casting for all shots in given episode.
290
+
291
+ Args:
292
+ project (str / dict): The project dict or the project ID.
293
+ episode (str / dict): The episode dict or the episode ID.
294
+
295
+ Returns:
296
+ dict: A dictionary mapping shot IDs to their casting lists. Each casting
297
+ list contains dictionaries with "asset_id" and "nb_occurences" keys
298
+ representing which assets are cast in each shot of the episode.
299
+ """
300
+ project = normalize_model_parameter(project)
301
+ episode = normalize_model_parameter(episode)
302
+ path = "/data/projects/%s/episodes/%s/shots/casting" % (
303
+ project["id"],
304
+ episode["id"],
305
+ )
306
+ return raw.get(path, client=client)
307
+
308
+
309
+ def get_project_shots_casting(
310
+ project: str | dict, client: KitsuClient = default
311
+ ) -> dict:
312
+ """
313
+ Return casting for all shots in given project.
314
+
315
+ Args:
316
+ project (str / dict): The project dict or the project ID.
317
+
318
+ Returns:
319
+ dict: A dictionary mapping shot IDs to their casting lists. Each casting
320
+ list contains dictionaries with "asset_id" and "nb_occurences" keys
321
+ representing which assets are cast in each shot of the project.
322
+ """
323
+ project = normalize_model_parameter(project)
324
+ path = "/data/projects/%s/shots/casting" % project["id"]
325
+ return raw.get(path, client=client)
326
+
327
+
328
+ def delete_entity_link(
329
+ entity_link: str | dict, client: KitsuClient = default
330
+ ) -> dict:
331
+ """
332
+ Delete an entity link.
333
+
334
+ Args:
335
+ entity_link (str / dict): The entity link dict or the entity link ID.
336
+
337
+ Returns:
338
+ dict: The deleted entity link.
339
+ """
340
+ entity_link = normalize_model_parameter(entity_link)
341
+ path = "/data/entity-links/%s" % entity_link["id"]
342
+ raw.delete(path, client=client)
343
+ return entity_link