gazu 1.0.3__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/__version__.py +1 -1
- gazu/asset.py +157 -51
- gazu/cache.py +25 -17
- gazu/casting.py +178 -25
- gazu/client.py +124 -71
- gazu/concept.py +35 -17
- gazu/context.py +41 -15
- gazu/edit.py +36 -17
- gazu/encoder.py +3 -1
- gazu/entity.py +47 -18
- gazu/events.py +22 -13
- gazu/files.py +616 -220
- gazu/helpers.py +13 -5
- gazu/person.py +194 -86
- gazu/playlist.py +107 -53
- gazu/project.py +198 -90
- gazu/py.typed +0 -0
- gazu/scene.py +57 -17
- gazu/search.py +10 -3
- gazu/shot.py +195 -76
- gazu/sorting.py +4 -1
- gazu/sync.py +167 -97
- gazu/task.py +544 -186
- gazu/user.py +127 -63
- {gazu-1.0.3.dist-info → gazu-1.1.0.dist-info}/METADATA +2 -1
- gazu-1.1.0.dist-info/RECORD +31 -0
- gazu-1.0.3.dist-info/RECORD +0 -30
- {gazu-1.0.3.dist-info → gazu-1.1.0.dist-info}/WHEEL +0 -0
- {gazu-1.0.3.dist-info → gazu-1.1.0.dist-info}/licenses/LICENSE +0 -0
- {gazu-1.0.3.dist-info → gazu-1.1.0.dist-info}/top_level.txt +0 -0
gazu/files.py
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
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 .cache import cache
|
|
10
|
+
from .client import KitsuClient
|
|
4
11
|
from .helpers import normalize_model_parameter
|
|
5
12
|
|
|
6
13
|
default = raw.default_client
|
|
7
14
|
|
|
8
15
|
|
|
9
16
|
@cache
|
|
10
|
-
def all_output_types(client=default):
|
|
17
|
+
def all_output_types(client: KitsuClient = default) -> list[dict]:
|
|
11
18
|
"""
|
|
12
19
|
Returns:
|
|
13
20
|
list: Output types listed in database.
|
|
@@ -16,7 +23,9 @@ def all_output_types(client=default):
|
|
|
16
23
|
|
|
17
24
|
|
|
18
25
|
@cache
|
|
19
|
-
def all_output_types_for_entity(
|
|
26
|
+
def all_output_types_for_entity(
|
|
27
|
+
entity: str | dict, client: KitsuClient = default
|
|
28
|
+
) -> list[dict]:
|
|
20
29
|
"""
|
|
21
30
|
Args:
|
|
22
31
|
entity (str / dict): The entity dict or the entity ID.
|
|
@@ -32,8 +41,8 @@ def all_output_types_for_entity(entity, client=default):
|
|
|
32
41
|
|
|
33
42
|
@cache
|
|
34
43
|
def all_output_types_for_asset_instance(
|
|
35
|
-
asset_instance, temporal_entity, client=default
|
|
36
|
-
):
|
|
44
|
+
asset_instance: dict, temporal_entity: dict, client: KitsuClient = default
|
|
45
|
+
) -> list[dict]:
|
|
37
46
|
"""
|
|
38
47
|
Returns:
|
|
39
48
|
list: Output types for given asset instance and entity (shot or scene).
|
|
@@ -46,7 +55,9 @@ def all_output_types_for_asset_instance(
|
|
|
46
55
|
|
|
47
56
|
|
|
48
57
|
@cache
|
|
49
|
-
def get_output_type(
|
|
58
|
+
def get_output_type(
|
|
59
|
+
output_type_id: str, client: KitsuClient = default
|
|
60
|
+
) -> dict:
|
|
50
61
|
"""
|
|
51
62
|
Args:
|
|
52
63
|
output_type_id (str): ID of claimed output type.
|
|
@@ -58,7 +69,9 @@ def get_output_type(output_type_id, client=default):
|
|
|
58
69
|
|
|
59
70
|
|
|
60
71
|
@cache
|
|
61
|
-
def get_output_type_by_name(
|
|
72
|
+
def get_output_type_by_name(
|
|
73
|
+
output_type_name: str, client: KitsuClient = default
|
|
74
|
+
) -> dict | None:
|
|
62
75
|
"""
|
|
63
76
|
Args:
|
|
64
77
|
output_type_name (str): name of claimed output type.
|
|
@@ -71,7 +84,9 @@ def get_output_type_by_name(output_type_name, client=default):
|
|
|
71
84
|
)
|
|
72
85
|
|
|
73
86
|
|
|
74
|
-
def new_output_type(
|
|
87
|
+
def new_output_type(
|
|
88
|
+
name: str, short_name: str, client: KitsuClient = default
|
|
89
|
+
) -> dict:
|
|
75
90
|
"""
|
|
76
91
|
Create a new output type in database.
|
|
77
92
|
|
|
@@ -91,7 +106,9 @@ def new_output_type(name, short_name, client=default):
|
|
|
91
106
|
|
|
92
107
|
|
|
93
108
|
@cache
|
|
94
|
-
def get_output_file(
|
|
109
|
+
def get_output_file(
|
|
110
|
+
output_file_id: str, client: KitsuClient = default
|
|
111
|
+
) -> dict:
|
|
95
112
|
"""
|
|
96
113
|
Args:
|
|
97
114
|
output_file_id (str): ID of claimed output file.
|
|
@@ -104,21 +121,26 @@ def get_output_file(output_file_id, client=default):
|
|
|
104
121
|
|
|
105
122
|
|
|
106
123
|
@cache
|
|
107
|
-
def get_output_file_by_path(
|
|
124
|
+
def get_output_file_by_path(
|
|
125
|
+
path: str, client: KitsuClient = default
|
|
126
|
+
) -> dict | None:
|
|
108
127
|
"""
|
|
109
128
|
Args:
|
|
110
129
|
path (str): Path of claimed output file.
|
|
111
130
|
|
|
112
131
|
Returns:
|
|
113
|
-
dict: Output file matching given path.
|
|
132
|
+
dict: Output file matching given path, or None if there are no matches.
|
|
114
133
|
"""
|
|
115
134
|
return raw.fetch_first("output-files", {"path": path}, client=client)
|
|
116
135
|
|
|
117
136
|
|
|
118
137
|
@cache
|
|
119
138
|
def get_all_working_files_for_entity(
|
|
120
|
-
entity
|
|
121
|
-
|
|
139
|
+
entity: str | dict,
|
|
140
|
+
task: str | dict | None = None,
|
|
141
|
+
name: str | None = None,
|
|
142
|
+
client: KitsuClient = default,
|
|
143
|
+
) -> list[dict]:
|
|
122
144
|
"""
|
|
123
145
|
Retrieves all the working files of a given entity and specied parameters
|
|
124
146
|
"""
|
|
@@ -136,7 +158,9 @@ def get_all_working_files_for_entity(
|
|
|
136
158
|
|
|
137
159
|
|
|
138
160
|
@cache
|
|
139
|
-
def get_preview_file(
|
|
161
|
+
def get_preview_file(
|
|
162
|
+
preview_file_id: str, client: KitsuClient = default
|
|
163
|
+
) -> dict:
|
|
140
164
|
"""
|
|
141
165
|
Args:
|
|
142
166
|
preview_file_id (str): ID of claimed preview file.
|
|
@@ -147,12 +171,23 @@ def get_preview_file(preview_file_id, client=default):
|
|
|
147
171
|
return raw.fetch_one("preview-files", preview_file_id, client=client)
|
|
148
172
|
|
|
149
173
|
|
|
150
|
-
def remove_preview_file(
|
|
174
|
+
def remove_preview_file(
|
|
175
|
+
preview_file: str | dict,
|
|
176
|
+
force: bool = False,
|
|
177
|
+
client: KitsuClient = default,
|
|
178
|
+
) -> str:
|
|
151
179
|
"""
|
|
152
180
|
Remove given preview file from database.
|
|
153
181
|
|
|
182
|
+
Depending on the configuration of the Kitsu server, the stored files linked
|
|
183
|
+
to the preview file may or may not be removed on deletion of a preview file.
|
|
184
|
+
The `force=True` parameter can be used to force deletion of the files
|
|
185
|
+
regardless of server config.
|
|
186
|
+
|
|
154
187
|
Args:
|
|
155
188
|
preview_file (str / dict): The preview_file dict or ID.
|
|
189
|
+
force (bool): Whether to force deletion of the files linked to the
|
|
190
|
+
preview file in storage.
|
|
156
191
|
"""
|
|
157
192
|
preview_file = normalize_model_parameter(preview_file)
|
|
158
193
|
params = {}
|
|
@@ -166,12 +201,14 @@ def remove_preview_file(preview_file, force=False, client=default):
|
|
|
166
201
|
|
|
167
202
|
|
|
168
203
|
@cache
|
|
169
|
-
def get_all_preview_files_for_task(
|
|
204
|
+
def get_all_preview_files_for_task(
|
|
205
|
+
task: str | dict, client: KitsuClient = default
|
|
206
|
+
) -> list[dict]:
|
|
170
207
|
"""
|
|
171
208
|
Retrieves all the preview files for a given task.
|
|
172
209
|
|
|
173
210
|
Args:
|
|
174
|
-
task (str
|
|
211
|
+
task (str / dict): Target task, as ID string or model dict.
|
|
175
212
|
"""
|
|
176
213
|
task = normalize_model_parameter(task)
|
|
177
214
|
return raw.fetch_all(
|
|
@@ -180,12 +217,14 @@ def get_all_preview_files_for_task(task, client=default):
|
|
|
180
217
|
|
|
181
218
|
|
|
182
219
|
@cache
|
|
183
|
-
def get_all_attachment_files_for_task(
|
|
220
|
+
def get_all_attachment_files_for_task(
|
|
221
|
+
task: str | dict, client: KitsuClient = default
|
|
222
|
+
) -> list[dict]:
|
|
184
223
|
"""
|
|
185
224
|
Retrieves all the attachment files for a given task.
|
|
186
225
|
|
|
187
226
|
Args:
|
|
188
|
-
task (str
|
|
227
|
+
task (str / dict): Target task, as ID string or model dict.
|
|
189
228
|
"""
|
|
190
229
|
task = normalize_model_parameter(task)
|
|
191
230
|
return raw.fetch_all(
|
|
@@ -193,15 +232,33 @@ def get_all_attachment_files_for_task(task, client=default):
|
|
|
193
232
|
)
|
|
194
233
|
|
|
195
234
|
|
|
235
|
+
def get_all_attachment_files_for_project(
|
|
236
|
+
project: str | dict, client: KitsuClient = default
|
|
237
|
+
) -> list[dict]:
|
|
238
|
+
"""
|
|
239
|
+
Retrieves all the attachment files for a given project.
|
|
240
|
+
|
|
241
|
+
Args:
|
|
242
|
+
project (str / dict): Target project, as ID string or model dict.
|
|
243
|
+
|
|
244
|
+
Returns:
|
|
245
|
+
list: Attachment files for the project.
|
|
246
|
+
"""
|
|
247
|
+
project = normalize_model_parameter(project)
|
|
248
|
+
return raw.fetch_all(
|
|
249
|
+
"projects/%s/attachment-files" % project["id"], client=client
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
|
|
196
253
|
def all_output_files_for_entity(
|
|
197
|
-
entity,
|
|
198
|
-
output_type=None,
|
|
199
|
-
task_type=None,
|
|
200
|
-
name=None,
|
|
201
|
-
representation=None,
|
|
202
|
-
file_status=None,
|
|
203
|
-
client=default,
|
|
204
|
-
):
|
|
254
|
+
entity: str | dict,
|
|
255
|
+
output_type: str | dict | None = None,
|
|
256
|
+
task_type: str | dict | None = None,
|
|
257
|
+
name: str | None = None,
|
|
258
|
+
representation: str | None = None,
|
|
259
|
+
file_status: str | dict | None = None,
|
|
260
|
+
client: KitsuClient = default,
|
|
261
|
+
) -> list[dict]:
|
|
205
262
|
"""
|
|
206
263
|
Args:
|
|
207
264
|
entity (str / dict): The entity dict or ID.
|
|
@@ -239,15 +296,15 @@ def all_output_files_for_entity(
|
|
|
239
296
|
|
|
240
297
|
@cache
|
|
241
298
|
def all_output_files_for_asset_instance(
|
|
242
|
-
asset_instance,
|
|
243
|
-
temporal_entity=None,
|
|
244
|
-
task_type=None,
|
|
245
|
-
output_type=None,
|
|
246
|
-
name=None,
|
|
247
|
-
representation=None,
|
|
248
|
-
file_status=None,
|
|
249
|
-
client=default,
|
|
250
|
-
):
|
|
299
|
+
asset_instance: str | dict,
|
|
300
|
+
temporal_entity: str | dict | None = None,
|
|
301
|
+
task_type: str | dict | None = None,
|
|
302
|
+
output_type: str | dict | None = None,
|
|
303
|
+
name: str | None = None,
|
|
304
|
+
representation: str | None = None,
|
|
305
|
+
file_status: str | dict | None = None,
|
|
306
|
+
client: KitsuClient = default,
|
|
307
|
+
) -> list[dict]:
|
|
251
308
|
"""
|
|
252
309
|
Args:
|
|
253
310
|
asset_instance (str / dict): The instance dict or ID.
|
|
@@ -289,17 +346,17 @@ def all_output_files_for_asset_instance(
|
|
|
289
346
|
|
|
290
347
|
|
|
291
348
|
def all_output_files_for_project(
|
|
292
|
-
project,
|
|
293
|
-
output_type=None,
|
|
294
|
-
task_type=None,
|
|
295
|
-
name=None,
|
|
296
|
-
representation=None,
|
|
297
|
-
file_status=None,
|
|
298
|
-
client=default,
|
|
299
|
-
):
|
|
349
|
+
project: str | dict,
|
|
350
|
+
output_type: str | dict | None = None,
|
|
351
|
+
task_type: str | dict | None = None,
|
|
352
|
+
name: str | None = None,
|
|
353
|
+
representation: str | None = None,
|
|
354
|
+
file_status: str | dict | None = None,
|
|
355
|
+
client: KitsuClient = default,
|
|
356
|
+
) -> list[dict]:
|
|
300
357
|
"""
|
|
301
358
|
Args:
|
|
302
|
-
|
|
359
|
+
project (str / dict): The project dict or ID.
|
|
303
360
|
output_type (str / dict): The output type dict or ID.
|
|
304
361
|
task_type (str / dict): The task type dict or ID.
|
|
305
362
|
name (str): The file name
|
|
@@ -335,16 +392,16 @@ def all_output_files_for_project(
|
|
|
335
392
|
|
|
336
393
|
|
|
337
394
|
@cache
|
|
338
|
-
def all_softwares(client=default):
|
|
395
|
+
def all_softwares(client: KitsuClient = default) -> list[dict]:
|
|
339
396
|
"""
|
|
340
397
|
Returns:
|
|
341
|
-
dict: Software versions listed in database.
|
|
398
|
+
list[dict]: Software versions listed in database.
|
|
342
399
|
"""
|
|
343
400
|
return raw.fetch_all("softwares", client=client)
|
|
344
401
|
|
|
345
402
|
|
|
346
403
|
@cache
|
|
347
|
-
def get_software(software_id, client=default):
|
|
404
|
+
def get_software(software_id: str, client: KitsuClient = default) -> dict:
|
|
348
405
|
"""
|
|
349
406
|
Args:
|
|
350
407
|
software_id (str): ID of claimed output type.
|
|
@@ -356,7 +413,9 @@ def get_software(software_id, client=default):
|
|
|
356
413
|
|
|
357
414
|
|
|
358
415
|
@cache
|
|
359
|
-
def get_software_by_name(
|
|
416
|
+
def get_software_by_name(
|
|
417
|
+
software_name: str, client: KitsuClient = default
|
|
418
|
+
) -> dict | None:
|
|
360
419
|
"""
|
|
361
420
|
Args:
|
|
362
421
|
software_name (str): Name of claimed output type.
|
|
@@ -367,7 +426,12 @@ def get_software_by_name(software_name, client=default):
|
|
|
367
426
|
return raw.fetch_first("softwares", {"name": software_name}, client=client)
|
|
368
427
|
|
|
369
428
|
|
|
370
|
-
def new_software(
|
|
429
|
+
def new_software(
|
|
430
|
+
name: str,
|
|
431
|
+
short_name: str,
|
|
432
|
+
file_extension: str,
|
|
433
|
+
client: KitsuClient = default,
|
|
434
|
+
) -> dict:
|
|
371
435
|
"""
|
|
372
436
|
Create a new software in datatabase.
|
|
373
437
|
|
|
@@ -393,23 +457,23 @@ def new_software(name, short_name, file_extension, client=default):
|
|
|
393
457
|
|
|
394
458
|
@cache
|
|
395
459
|
def build_working_file_path(
|
|
396
|
-
task,
|
|
397
|
-
name="main",
|
|
398
|
-
mode="working",
|
|
399
|
-
software=None,
|
|
400
|
-
revision=1,
|
|
401
|
-
sep="/",
|
|
402
|
-
client=default,
|
|
403
|
-
):
|
|
460
|
+
task: str | dict,
|
|
461
|
+
name: str = "main",
|
|
462
|
+
mode: str = "working",
|
|
463
|
+
software: str | dict | None = None,
|
|
464
|
+
revision: int = 1,
|
|
465
|
+
sep: str = "/",
|
|
466
|
+
client: KitsuClient = default,
|
|
467
|
+
) -> str:
|
|
404
468
|
"""
|
|
405
469
|
From the file path template configured at the project level and arguments,
|
|
406
470
|
it builds a file path location where to store related DCC file.
|
|
407
471
|
|
|
408
472
|
Args:
|
|
409
|
-
task (str /
|
|
473
|
+
task (str / dict): Task related to working file.
|
|
410
474
|
name (str): Additional suffix for the working file name.
|
|
411
475
|
mode (str): Allow to select a template inside the template.
|
|
412
|
-
software (str /
|
|
476
|
+
software (str / dict): Software at the origin of the file.
|
|
413
477
|
revision (int): File revision.
|
|
414
478
|
sep (str): OS separator.
|
|
415
479
|
|
|
@@ -433,30 +497,30 @@ def build_working_file_path(
|
|
|
433
497
|
|
|
434
498
|
@cache
|
|
435
499
|
def build_entity_output_file_path(
|
|
436
|
-
entity,
|
|
437
|
-
output_type,
|
|
438
|
-
task_type,
|
|
439
|
-
name="main",
|
|
440
|
-
mode="output",
|
|
441
|
-
representation="",
|
|
442
|
-
revision=0,
|
|
443
|
-
nb_elements=1,
|
|
444
|
-
sep="/",
|
|
445
|
-
client=default,
|
|
446
|
-
):
|
|
500
|
+
entity: str | dict,
|
|
501
|
+
output_type: str | dict,
|
|
502
|
+
task_type: str | dict,
|
|
503
|
+
name: str = "main",
|
|
504
|
+
mode: str = "output",
|
|
505
|
+
representation: str = "",
|
|
506
|
+
revision: int = 0,
|
|
507
|
+
nb_elements: int = 1,
|
|
508
|
+
sep: str = "/",
|
|
509
|
+
client: KitsuClient = default,
|
|
510
|
+
) -> str:
|
|
447
511
|
"""
|
|
448
512
|
From the file path template configured at the project level and arguments,
|
|
449
513
|
it builds a file path location where to store related DCC output file.
|
|
450
514
|
|
|
451
515
|
Args:
|
|
452
|
-
entity (str /
|
|
453
|
-
output_type (str /
|
|
454
|
-
task_type (str /
|
|
516
|
+
entity (str / dict): Entity for which an output file is needed.
|
|
517
|
+
output_type (str / dict): Output type of the generated file.
|
|
518
|
+
task_type (str / dict): Task type related to output file.
|
|
455
519
|
name (str): Additional suffix for the working file name.
|
|
456
520
|
mode (str): Allow to select a template inside the template.
|
|
457
521
|
representation (str): Allow to select a template inside the template.
|
|
458
522
|
revision (int): File revision.
|
|
459
|
-
nb_elements (
|
|
523
|
+
nb_elements (int): To represent an image sequence, the amount of file is
|
|
460
524
|
needed.
|
|
461
525
|
sep (str): OS separator.
|
|
462
526
|
|
|
@@ -489,32 +553,32 @@ def build_entity_output_file_path(
|
|
|
489
553
|
|
|
490
554
|
@cache
|
|
491
555
|
def build_asset_instance_output_file_path(
|
|
492
|
-
asset_instance,
|
|
493
|
-
temporal_entity,
|
|
494
|
-
output_type,
|
|
495
|
-
task_type,
|
|
496
|
-
name="main",
|
|
497
|
-
representation="",
|
|
498
|
-
mode="output",
|
|
499
|
-
revision=0,
|
|
500
|
-
nb_elements=1,
|
|
501
|
-
sep="/",
|
|
502
|
-
client=default,
|
|
503
|
-
):
|
|
556
|
+
asset_instance: str | dict,
|
|
557
|
+
temporal_entity: str | dict,
|
|
558
|
+
output_type: str | dict,
|
|
559
|
+
task_type: str | dict,
|
|
560
|
+
name: str = "main",
|
|
561
|
+
representation: str = "",
|
|
562
|
+
mode: str = "output",
|
|
563
|
+
revision: int = 0,
|
|
564
|
+
nb_elements: int = 1,
|
|
565
|
+
sep: str = "/",
|
|
566
|
+
client: KitsuClient = default,
|
|
567
|
+
) -> str:
|
|
504
568
|
"""
|
|
505
569
|
From the file path template configured at the project level and arguments,
|
|
506
570
|
it builds a file path location where to store related DCC output file.
|
|
507
571
|
|
|
508
572
|
Args:
|
|
509
|
-
asset_instance_id entity (str /
|
|
573
|
+
asset_instance_id entity (str / dict): Asset instance for which a file
|
|
510
574
|
is required.
|
|
511
|
-
temporal entity (str /
|
|
575
|
+
temporal entity (str / dict): Temporal entity scene or shot in which
|
|
512
576
|
the asset instance appeared.
|
|
513
|
-
output_type (str /
|
|
514
|
-
task_type (str /
|
|
577
|
+
output_type (str / dict): Output type of the generated file.
|
|
578
|
+
task_type (str / dict): Task type related to output file.
|
|
515
579
|
name (str): Additional suffix for the working file name.
|
|
516
|
-
mode (str): Allow to select a template inside the template.
|
|
517
580
|
representation (str): Allow to select a template inside the template.
|
|
581
|
+
mode (str): Allow to select a template inside the template.
|
|
518
582
|
revision (int): File revision.
|
|
519
583
|
nb_elements (str): To represent an image sequence, the amount of file is
|
|
520
584
|
needed.
|
|
@@ -551,28 +615,28 @@ def build_asset_instance_output_file_path(
|
|
|
551
615
|
|
|
552
616
|
|
|
553
617
|
def new_working_file(
|
|
554
|
-
task,
|
|
555
|
-
name="main",
|
|
556
|
-
mode="working",
|
|
557
|
-
software=None,
|
|
558
|
-
comment="",
|
|
559
|
-
person=None,
|
|
560
|
-
revision=0,
|
|
561
|
-
sep="/",
|
|
562
|
-
client=default,
|
|
563
|
-
):
|
|
618
|
+
task: str | dict,
|
|
619
|
+
name: str = "main",
|
|
620
|
+
mode: str = "working",
|
|
621
|
+
software: str | dict | None = None,
|
|
622
|
+
comment: str = "",
|
|
623
|
+
person: str | dict | None = None,
|
|
624
|
+
revision: int = 0,
|
|
625
|
+
sep: str = "/",
|
|
626
|
+
client: KitsuClient = default,
|
|
627
|
+
) -> dict:
|
|
564
628
|
"""
|
|
565
629
|
Create a new working_file for given task. It generates and store the
|
|
566
630
|
expected path for given task and options. It sets a revision number
|
|
567
631
|
(last revision + 1).
|
|
568
632
|
|
|
569
633
|
Args:
|
|
570
|
-
task (str /
|
|
634
|
+
task (str / dict): Task related to working file.
|
|
571
635
|
name (str): Additional suffix for the working file name.
|
|
572
636
|
mode (str): Allow to select a template inside the template.
|
|
573
|
-
software (str /
|
|
637
|
+
software (str / dict): Software at the origin of the file.
|
|
574
638
|
comment (str): Comment related to created revision.
|
|
575
|
-
person (str /
|
|
639
|
+
person (str / dict): Author of the file.
|
|
576
640
|
revision (int): File revision.
|
|
577
641
|
sep (str): OS separator.
|
|
578
642
|
|
|
@@ -600,38 +664,38 @@ def new_working_file(
|
|
|
600
664
|
|
|
601
665
|
|
|
602
666
|
def new_entity_output_file(
|
|
603
|
-
entity,
|
|
604
|
-
output_type,
|
|
605
|
-
task_type,
|
|
606
|
-
comment,
|
|
607
|
-
working_file=None,
|
|
608
|
-
person=None,
|
|
609
|
-
name="main",
|
|
610
|
-
mode="output",
|
|
611
|
-
revision=0,
|
|
612
|
-
nb_elements=1,
|
|
613
|
-
representation="",
|
|
614
|
-
sep="/",
|
|
615
|
-
file_status_id=None,
|
|
616
|
-
client=default,
|
|
617
|
-
):
|
|
667
|
+
entity: str | dict,
|
|
668
|
+
output_type: str | dict,
|
|
669
|
+
task_type: str | dict,
|
|
670
|
+
comment: str,
|
|
671
|
+
working_file: str | dict | None = None,
|
|
672
|
+
person: str | dict | None = None,
|
|
673
|
+
name: str = "main",
|
|
674
|
+
mode: str = "output",
|
|
675
|
+
revision: int = 0,
|
|
676
|
+
nb_elements: int = 1,
|
|
677
|
+
representation: str = "",
|
|
678
|
+
sep: str = "/",
|
|
679
|
+
file_status_id: str | None = None,
|
|
680
|
+
client: KitsuClient = default,
|
|
681
|
+
) -> dict:
|
|
618
682
|
"""
|
|
619
683
|
Create a new output file for given entity, task type and output type.
|
|
620
684
|
It generates and store the expected path and sets a revision number
|
|
621
685
|
(last revision + 1).
|
|
622
686
|
|
|
623
687
|
Args:
|
|
624
|
-
entity (str /
|
|
625
|
-
output_type (str /
|
|
626
|
-
task_type (str /
|
|
688
|
+
entity (str / dict): Entity for which an output file is needed.
|
|
689
|
+
output_type (str / dict): Output type of the generated file.
|
|
690
|
+
task_type (str / dict): Task type related to output file.
|
|
627
691
|
comment (str): Comment related to created revision.
|
|
628
|
-
working_file (str /
|
|
692
|
+
working_file (str / dict): Working file which is the source of the
|
|
629
693
|
generated file.
|
|
630
|
-
person (str /
|
|
694
|
+
person (str / dict): Author of the file.
|
|
631
695
|
name (str): Additional suffix for the working file name.
|
|
632
696
|
mode (str): Allow to select a template inside the template.
|
|
633
697
|
revision (int): File revision.
|
|
634
|
-
nb_elements (
|
|
698
|
+
nb_elements (int): To represent an image sequence, the amount of file is
|
|
635
699
|
needed.
|
|
636
700
|
representation (str): Differientate file extensions. It can be useful
|
|
637
701
|
to build folders based on extensions like abc, jpg, etc.
|
|
@@ -639,7 +703,7 @@ def new_entity_output_file(
|
|
|
639
703
|
file_status_id (id): The id of the file status to set at creation
|
|
640
704
|
|
|
641
705
|
Returns:
|
|
642
|
-
Created output file.
|
|
706
|
+
dict: Created output file.
|
|
643
707
|
"""
|
|
644
708
|
entity = normalize_model_parameter(entity)
|
|
645
709
|
output_type = normalize_model_parameter(output_type)
|
|
@@ -671,42 +735,45 @@ def new_entity_output_file(
|
|
|
671
735
|
|
|
672
736
|
|
|
673
737
|
def new_asset_instance_output_file(
|
|
674
|
-
asset_instance,
|
|
675
|
-
temporal_entity,
|
|
676
|
-
output_type,
|
|
677
|
-
task_type,
|
|
678
|
-
comment,
|
|
679
|
-
name="master",
|
|
680
|
-
mode="output",
|
|
681
|
-
working_file=None,
|
|
682
|
-
person=None,
|
|
683
|
-
revision=0,
|
|
684
|
-
nb_elements=1,
|
|
685
|
-
representation="",
|
|
686
|
-
sep="/",
|
|
687
|
-
file_status_id=None,
|
|
688
|
-
client=default,
|
|
689
|
-
):
|
|
738
|
+
asset_instance: str | dict,
|
|
739
|
+
temporal_entity: str | dict,
|
|
740
|
+
output_type: str | dict,
|
|
741
|
+
task_type: str | dict,
|
|
742
|
+
comment: str,
|
|
743
|
+
name: str = "master",
|
|
744
|
+
mode: str = "output",
|
|
745
|
+
working_file: str | dict | None = None,
|
|
746
|
+
person: str | dict | None = None,
|
|
747
|
+
revision: int = 0,
|
|
748
|
+
nb_elements: int = 1,
|
|
749
|
+
representation: str = "",
|
|
750
|
+
sep: str = "/",
|
|
751
|
+
file_status_id: str | dict | None = None,
|
|
752
|
+
client: KitsuClient = default,
|
|
753
|
+
) -> dict:
|
|
690
754
|
"""
|
|
691
755
|
Create a new output file for given asset instance, temporal entity, task
|
|
692
756
|
type and output type. It generates and store the expected path and sets a
|
|
693
757
|
revision number (last revision + 1).
|
|
694
758
|
|
|
695
759
|
Args:
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
760
|
+
asset_instance (str / dict): Asset instance for which an output file
|
|
761
|
+
is needed.
|
|
762
|
+
temporal_entity (str / dict): Temporal entity for which an output file
|
|
763
|
+
is needed.
|
|
764
|
+
output_type (str / dict): Output type of the generated file.
|
|
765
|
+
task_type (str / dict): Task type related to output file.
|
|
699
766
|
comment (str): Comment related to created revision.
|
|
700
|
-
working_file (str /
|
|
701
|
-
|
|
702
|
-
person (str /
|
|
767
|
+
working_file (str / dict): Working file which is the source of the
|
|
768
|
+
generated file.
|
|
769
|
+
person (str / dict): Author of the file.
|
|
703
770
|
name (str): Additional suffix for the working file name.
|
|
704
771
|
mode (str): Allow to select a template inside the template.
|
|
705
772
|
revision (int): File revision.
|
|
706
|
-
nb_elements (
|
|
707
|
-
|
|
708
|
-
representation (str):
|
|
709
|
-
|
|
773
|
+
nb_elements (int): To represent an image sequence, the amount of file
|
|
774
|
+
needed.
|
|
775
|
+
representation (str): Differentiate file extensions. It can be useful
|
|
776
|
+
to build folders based on extensions like abc, jpg, cetc.
|
|
710
777
|
sep (str): OS separator.
|
|
711
778
|
file_status_id (id): The id of the file status to set at creation
|
|
712
779
|
|
|
@@ -747,19 +814,26 @@ def new_asset_instance_output_file(
|
|
|
747
814
|
|
|
748
815
|
|
|
749
816
|
def get_next_entity_output_revision(
|
|
750
|
-
entity
|
|
751
|
-
|
|
817
|
+
entity: str | dict,
|
|
818
|
+
output_type: str | dict,
|
|
819
|
+
task_type: str | dict,
|
|
820
|
+
name: str = "main",
|
|
821
|
+
client: KitsuClient = default,
|
|
822
|
+
) -> int:
|
|
752
823
|
"""
|
|
753
824
|
Args:
|
|
754
825
|
entity (str / dict): The entity dict or ID.
|
|
755
826
|
output_type (str / dict): The entity dict or ID.
|
|
756
827
|
task_type (str / dict): The entity dict or ID.
|
|
828
|
+
name (str): Get version for output file with the given name.
|
|
757
829
|
|
|
758
830
|
Returns:
|
|
759
|
-
int: Next revision of
|
|
831
|
+
int: Next revision of output files available for given entity, output
|
|
760
832
|
type and task type.
|
|
761
833
|
"""
|
|
762
834
|
entity = normalize_model_parameter(entity)
|
|
835
|
+
output_type = normalize_model_parameter(output_type)
|
|
836
|
+
task_type = normalize_model_parameter(task_type)
|
|
763
837
|
path = "data/entities/%s/output-files/next-revision" % entity["id"]
|
|
764
838
|
data = {
|
|
765
839
|
"name": name,
|
|
@@ -771,13 +845,13 @@ def get_next_entity_output_revision(
|
|
|
771
845
|
|
|
772
846
|
|
|
773
847
|
def get_next_asset_instance_output_revision(
|
|
774
|
-
asset_instance,
|
|
775
|
-
temporal_entity,
|
|
776
|
-
output_type,
|
|
777
|
-
task_type,
|
|
778
|
-
name="master",
|
|
779
|
-
client=default,
|
|
780
|
-
):
|
|
848
|
+
asset_instance: str | dict,
|
|
849
|
+
temporal_entity: str | dict,
|
|
850
|
+
output_type: str | dict,
|
|
851
|
+
task_type: str | dict,
|
|
852
|
+
name: str = "master",
|
|
853
|
+
client: KitsuClient = default,
|
|
854
|
+
) -> int:
|
|
781
855
|
"""
|
|
782
856
|
Args:
|
|
783
857
|
asset_instance (str / dict): The asset instance dict or ID.
|
|
@@ -806,14 +880,18 @@ def get_next_asset_instance_output_revision(
|
|
|
806
880
|
|
|
807
881
|
|
|
808
882
|
def get_last_entity_output_revision(
|
|
809
|
-
entity
|
|
810
|
-
|
|
883
|
+
entity: str | dict,
|
|
884
|
+
output_type: str | dict,
|
|
885
|
+
task_type: str | dict,
|
|
886
|
+
name: str = "master",
|
|
887
|
+
client: KitsuClient = default,
|
|
888
|
+
) -> int:
|
|
811
889
|
"""
|
|
812
890
|
Args:
|
|
813
|
-
entity (str / dict
|
|
814
|
-
output_type (str / dict
|
|
815
|
-
task_type (str / dict
|
|
816
|
-
name (str
|
|
891
|
+
entity (str / dict): The entity dict or ID.
|
|
892
|
+
output_type (str / dict): The entity dict or ID.
|
|
893
|
+
task_type (str / dict): The entity dict or ID.
|
|
894
|
+
name (str): The output name
|
|
817
895
|
|
|
818
896
|
Returns:
|
|
819
897
|
int: Last revision of ouput files for given entity, output type and task
|
|
@@ -831,13 +909,13 @@ def get_last_entity_output_revision(
|
|
|
831
909
|
|
|
832
910
|
|
|
833
911
|
def get_last_asset_instance_output_revision(
|
|
834
|
-
asset_instance,
|
|
835
|
-
temporal_entity,
|
|
836
|
-
output_type,
|
|
837
|
-
task_type,
|
|
838
|
-
name="master",
|
|
839
|
-
client=default,
|
|
840
|
-
):
|
|
912
|
+
asset_instance: str | dict,
|
|
913
|
+
temporal_entity: str | dict,
|
|
914
|
+
output_type: str | dict,
|
|
915
|
+
task_type: str | dict,
|
|
916
|
+
name: str = "master",
|
|
917
|
+
client: KitsuClient = default,
|
|
918
|
+
) -> int:
|
|
841
919
|
"""
|
|
842
920
|
Generate last output revision for given asset instance.
|
|
843
921
|
"""
|
|
@@ -860,14 +938,14 @@ def get_last_asset_instance_output_revision(
|
|
|
860
938
|
|
|
861
939
|
@cache
|
|
862
940
|
def get_last_output_files_for_entity(
|
|
863
|
-
entity,
|
|
864
|
-
output_type=None,
|
|
865
|
-
task_type=None,
|
|
866
|
-
name=None,
|
|
867
|
-
representation=None,
|
|
868
|
-
file_status=None,
|
|
869
|
-
client=default,
|
|
870
|
-
):
|
|
941
|
+
entity: str | dict,
|
|
942
|
+
output_type: str | dict | None = None,
|
|
943
|
+
task_type: str | dict | None = None,
|
|
944
|
+
name: str | None = None,
|
|
945
|
+
representation: str | None = None,
|
|
946
|
+
file_status: str | dict | None = None,
|
|
947
|
+
client: KitsuClient = default,
|
|
948
|
+
) -> list[dict]:
|
|
871
949
|
"""
|
|
872
950
|
Args:
|
|
873
951
|
entity (str / dict): The entity dict or ID.
|
|
@@ -907,15 +985,15 @@ def get_last_output_files_for_entity(
|
|
|
907
985
|
|
|
908
986
|
@cache
|
|
909
987
|
def get_last_output_files_for_asset_instance(
|
|
910
|
-
asset_instance,
|
|
911
|
-
temporal_entity,
|
|
912
|
-
task_type=None,
|
|
913
|
-
output_type=None,
|
|
914
|
-
name=None,
|
|
915
|
-
representation=None,
|
|
916
|
-
file_status=None,
|
|
917
|
-
client=default,
|
|
918
|
-
):
|
|
988
|
+
asset_instance: str | dict,
|
|
989
|
+
temporal_entity: str | dict,
|
|
990
|
+
task_type: str | dict | None = None,
|
|
991
|
+
output_type: str | dict | None = None,
|
|
992
|
+
name: str | None = None,
|
|
993
|
+
representation: str | None = None,
|
|
994
|
+
file_status: str | dict | None = None,
|
|
995
|
+
client: KitsuClient = default,
|
|
996
|
+
) -> list[dict]:
|
|
919
997
|
"""
|
|
920
998
|
Args:
|
|
921
999
|
asset_instance (str / dict): The asset instance dict or ID.
|
|
@@ -959,7 +1037,9 @@ def get_last_output_files_for_asset_instance(
|
|
|
959
1037
|
|
|
960
1038
|
|
|
961
1039
|
@cache
|
|
962
|
-
def get_working_files_for_task(
|
|
1040
|
+
def get_working_files_for_task(
|
|
1041
|
+
task: str | dict, client: KitsuClient = default
|
|
1042
|
+
) -> list[dict]:
|
|
963
1043
|
"""
|
|
964
1044
|
Args:
|
|
965
1045
|
task (str / dict): The task dict or the task ID.
|
|
@@ -973,7 +1053,9 @@ def get_working_files_for_task(task, client=default):
|
|
|
973
1053
|
|
|
974
1054
|
|
|
975
1055
|
@cache
|
|
976
|
-
def get_last_working_files(
|
|
1056
|
+
def get_last_working_files(
|
|
1057
|
+
task: str | dict, client: KitsuClient = default
|
|
1058
|
+
) -> dict:
|
|
977
1059
|
"""
|
|
978
1060
|
Args:
|
|
979
1061
|
task (str / dict): The task dict or the task ID.
|
|
@@ -988,7 +1070,9 @@ def get_last_working_files(task, client=default):
|
|
|
988
1070
|
|
|
989
1071
|
|
|
990
1072
|
@cache
|
|
991
|
-
def get_last_working_file_revision(
|
|
1073
|
+
def get_last_working_file_revision(
|
|
1074
|
+
task: str | dict, name: str = "main", client: KitsuClient = default
|
|
1075
|
+
) -> dict:
|
|
992
1076
|
"""
|
|
993
1077
|
Args:
|
|
994
1078
|
task (str / dict): The task dict or the task ID.
|
|
@@ -996,7 +1080,7 @@ def get_last_working_file_revision(task, name="main", client=default):
|
|
|
996
1080
|
|
|
997
1081
|
Returns:
|
|
998
1082
|
dict: Last revisions stored in the API for given task and given file
|
|
999
|
-
name
|
|
1083
|
+
name suffix.
|
|
1000
1084
|
"""
|
|
1001
1085
|
task = normalize_model_parameter(task)
|
|
1002
1086
|
path = "data/tasks/%s/working-files/last-revisions" % task["id"]
|
|
@@ -1005,7 +1089,9 @@ def get_last_working_file_revision(task, name="main", client=default):
|
|
|
1005
1089
|
|
|
1006
1090
|
|
|
1007
1091
|
@cache
|
|
1008
|
-
def get_working_file(
|
|
1092
|
+
def get_working_file(
|
|
1093
|
+
working_file_id: str, client: KitsuClient = default
|
|
1094
|
+
) -> dict:
|
|
1009
1095
|
"""
|
|
1010
1096
|
Args:
|
|
1011
1097
|
working_file_id (str): ID of claimed working file.
|
|
@@ -1016,7 +1102,9 @@ def get_working_file(working_file_id, client=default):
|
|
|
1016
1102
|
return raw.fetch_one("working-files", working_file_id, client=client)
|
|
1017
1103
|
|
|
1018
1104
|
|
|
1019
|
-
def update_comment(
|
|
1105
|
+
def update_comment(
|
|
1106
|
+
working_file: str | dict, comment: str, client: KitsuClient = default
|
|
1107
|
+
) -> dict:
|
|
1020
1108
|
"""
|
|
1021
1109
|
Update the file comment in database for given working file.
|
|
1022
1110
|
|
|
@@ -1034,7 +1122,9 @@ def update_comment(working_file, comment, client=default):
|
|
|
1034
1122
|
)
|
|
1035
1123
|
|
|
1036
1124
|
|
|
1037
|
-
def update_modification_date(
|
|
1125
|
+
def update_modification_date(
|
|
1126
|
+
working_file: str | dict, client: KitsuClient = default
|
|
1127
|
+
) -> dict:
|
|
1038
1128
|
"""
|
|
1039
1129
|
Update modification date of given working file with current time (now).
|
|
1040
1130
|
|
|
@@ -1051,12 +1141,15 @@ def update_modification_date(working_file, client=default):
|
|
|
1051
1141
|
)
|
|
1052
1142
|
|
|
1053
1143
|
|
|
1054
|
-
def update_output_file(
|
|
1144
|
+
def update_output_file(
|
|
1145
|
+
output_file: str | dict, data: dict, client: KitsuClient = default
|
|
1146
|
+
) -> dict:
|
|
1055
1147
|
"""
|
|
1056
1148
|
Update the data of given output file.
|
|
1057
1149
|
|
|
1058
1150
|
Args:
|
|
1059
1151
|
output_file (str / dict): The output file dict or ID.
|
|
1152
|
+
data (dict): Data to update on the output file.
|
|
1060
1153
|
|
|
1061
1154
|
Returns:
|
|
1062
1155
|
dict: Modified output file
|
|
@@ -1066,7 +1159,9 @@ def update_output_file(output_file, data, client=default):
|
|
|
1066
1159
|
return raw.put(path, data, client=client)
|
|
1067
1160
|
|
|
1068
1161
|
|
|
1069
|
-
def set_project_file_tree(
|
|
1162
|
+
def set_project_file_tree(
|
|
1163
|
+
project: str | dict, file_tree_name: str, client: KitsuClient = default
|
|
1164
|
+
) -> dict:
|
|
1070
1165
|
"""
|
|
1071
1166
|
(Deprecated) Set given file tree template on given project. This template
|
|
1072
1167
|
will be used to generate file paths. The template is selected from sources.
|
|
@@ -1085,7 +1180,9 @@ def set_project_file_tree(project, file_tree_name, client=default):
|
|
|
1085
1180
|
return raw.post(path, data, client=client)
|
|
1086
1181
|
|
|
1087
1182
|
|
|
1088
|
-
def update_project_file_tree(
|
|
1183
|
+
def update_project_file_tree(
|
|
1184
|
+
project: str | dict, file_tree: dict, client: KitsuClient = default
|
|
1185
|
+
) -> dict:
|
|
1089
1186
|
"""
|
|
1090
1187
|
Set given dict as file tree template on given project. This template
|
|
1091
1188
|
will be used to generate file paths.
|
|
@@ -1103,20 +1200,29 @@ def update_project_file_tree(project, file_tree, client=default):
|
|
|
1103
1200
|
return raw.put(path, data, client=client)
|
|
1104
1201
|
|
|
1105
1202
|
|
|
1106
|
-
def upload_working_file(
|
|
1203
|
+
def upload_working_file(
|
|
1204
|
+
working_file: str | dict, file_path: str, client: KitsuClient = default
|
|
1205
|
+
) -> dict:
|
|
1107
1206
|
"""
|
|
1108
1207
|
Save given file in working file storage.
|
|
1109
1208
|
|
|
1110
1209
|
Args:
|
|
1111
1210
|
working_file (str / dict): The working file dict or ID.
|
|
1112
1211
|
file_path (str): Location on hard drive where to save the file.
|
|
1212
|
+
|
|
1213
|
+
Returns:
|
|
1214
|
+
(dict): the working file model dictionary.
|
|
1113
1215
|
"""
|
|
1114
1216
|
working_file = normalize_model_parameter(working_file)
|
|
1115
1217
|
url_path = "/data/working-files/%s/file" % working_file["id"]
|
|
1116
1218
|
return raw.upload(url_path, file_path, client=client)
|
|
1117
1219
|
|
|
1118
1220
|
|
|
1119
|
-
def download_working_file(
|
|
1221
|
+
def download_working_file(
|
|
1222
|
+
working_file: str | dict,
|
|
1223
|
+
file_path: str | None = None,
|
|
1224
|
+
client: KitsuClient = default,
|
|
1225
|
+
) -> requests.Response:
|
|
1120
1226
|
"""
|
|
1121
1227
|
Download given working file and save it at given location.
|
|
1122
1228
|
|
|
@@ -1137,7 +1243,9 @@ def download_working_file(working_file, file_path=None, client=default):
|
|
|
1137
1243
|
)
|
|
1138
1244
|
|
|
1139
1245
|
|
|
1140
|
-
def download_preview_file(
|
|
1246
|
+
def download_preview_file(
|
|
1247
|
+
preview_file: str | dict, file_path: str, client: KitsuClient = default
|
|
1248
|
+
) -> requests.Response:
|
|
1141
1249
|
"""
|
|
1142
1250
|
Download given preview file and save it at given location.
|
|
1143
1251
|
|
|
@@ -1152,7 +1260,9 @@ def download_preview_file(preview_file, file_path, client=default):
|
|
|
1152
1260
|
)
|
|
1153
1261
|
|
|
1154
1262
|
|
|
1155
|
-
def get_preview_file_url(
|
|
1263
|
+
def get_preview_file_url(
|
|
1264
|
+
preview_file: str | dict, client: KitsuClient = default
|
|
1265
|
+
) -> str:
|
|
1156
1266
|
"""
|
|
1157
1267
|
Return given preview file URL
|
|
1158
1268
|
|
|
@@ -1171,7 +1281,9 @@ def get_preview_file_url(preview_file, client=default):
|
|
|
1171
1281
|
)
|
|
1172
1282
|
|
|
1173
1283
|
|
|
1174
|
-
def get_attachment_file(
|
|
1284
|
+
def get_attachment_file(
|
|
1285
|
+
attachment_file_id: str, client: KitsuClient = default
|
|
1286
|
+
) -> dict:
|
|
1175
1287
|
"""
|
|
1176
1288
|
Return attachment file object corresponding to given ID.
|
|
1177
1289
|
|
|
@@ -1181,7 +1293,9 @@ def get_attachment_file(attachment_file_id, client=default):
|
|
|
1181
1293
|
return raw.fetch_one("attachment-files", attachment_file_id, client=client)
|
|
1182
1294
|
|
|
1183
1295
|
|
|
1184
|
-
def download_attachment_file(
|
|
1296
|
+
def download_attachment_file(
|
|
1297
|
+
attachment_file: str | dict, file_path: str, client: KitsuClient = default
|
|
1298
|
+
) -> requests.Response:
|
|
1185
1299
|
"""
|
|
1186
1300
|
Download given attachment file and save it at given location.
|
|
1187
1301
|
|
|
@@ -1199,7 +1313,9 @@ def download_attachment_file(attachment_file, file_path, client=default):
|
|
|
1199
1313
|
)
|
|
1200
1314
|
|
|
1201
1315
|
|
|
1202
|
-
def download_preview_file_thumbnail(
|
|
1316
|
+
def download_preview_file_thumbnail(
|
|
1317
|
+
preview_file: str | dict, file_path: str, client: KitsuClient = default
|
|
1318
|
+
) -> requests.Response:
|
|
1203
1319
|
"""
|
|
1204
1320
|
Download given preview file thumbnail and save it at given location.
|
|
1205
1321
|
|
|
@@ -1216,7 +1332,9 @@ def download_preview_file_thumbnail(preview_file, file_path, client=default):
|
|
|
1216
1332
|
)
|
|
1217
1333
|
|
|
1218
1334
|
|
|
1219
|
-
def download_preview_file_cover(
|
|
1335
|
+
def download_preview_file_cover(
|
|
1336
|
+
preview_file: str | dict, file_path: str, client: KitsuClient = default
|
|
1337
|
+
) -> requests.Response:
|
|
1220
1338
|
"""
|
|
1221
1339
|
Download given preview file cover and save it at given location.
|
|
1222
1340
|
Args:
|
|
@@ -1231,9 +1349,12 @@ def download_preview_file_cover(preview_file, file_path, client=default):
|
|
|
1231
1349
|
)
|
|
1232
1350
|
|
|
1233
1351
|
|
|
1234
|
-
def download_person_avatar(
|
|
1352
|
+
def download_person_avatar(
|
|
1353
|
+
person: str | dict, file_path: str, client: KitsuClient = default
|
|
1354
|
+
) -> requests.Response:
|
|
1235
1355
|
"""
|
|
1236
1356
|
Download given person's avatar and save it at given location.
|
|
1357
|
+
|
|
1237
1358
|
Args:
|
|
1238
1359
|
person (str / dict): The person dict or ID.
|
|
1239
1360
|
file_path (str): Location on hard drive where to save the file.
|
|
@@ -1246,13 +1367,19 @@ def download_person_avatar(person, file_path, client=default):
|
|
|
1246
1367
|
)
|
|
1247
1368
|
|
|
1248
1369
|
|
|
1249
|
-
def upload_person_avatar(
|
|
1370
|
+
def upload_person_avatar(
|
|
1371
|
+
person: str | dict, file_path: str, client: KitsuClient = default
|
|
1372
|
+
) -> dict[Literal["thumbnail_path"], str]:
|
|
1250
1373
|
"""
|
|
1251
1374
|
Upload given file as person avatar.
|
|
1252
1375
|
|
|
1253
1376
|
Args:
|
|
1254
1377
|
person (str / dict): The person dict or the person ID.
|
|
1255
1378
|
file_path (str): Path of the file to upload as avatar.
|
|
1379
|
+
|
|
1380
|
+
Returns:
|
|
1381
|
+
dict: Dictionary with a key of 'thumbnail_path' and a value of the
|
|
1382
|
+
path to the static image file, relative to the host url.
|
|
1256
1383
|
"""
|
|
1257
1384
|
path = (
|
|
1258
1385
|
"/pictures/thumbnails/persons/%s"
|
|
@@ -1261,9 +1388,12 @@ def upload_person_avatar(person, file_path, client=default):
|
|
|
1261
1388
|
return raw.upload(path, file_path, client=client)
|
|
1262
1389
|
|
|
1263
1390
|
|
|
1264
|
-
def download_project_avatar(
|
|
1391
|
+
def download_project_avatar(
|
|
1392
|
+
project: str | dict, file_path: str, client: KitsuClient = default
|
|
1393
|
+
) -> requests.Response:
|
|
1265
1394
|
"""
|
|
1266
1395
|
Download given project's avatar and save it at given location.
|
|
1396
|
+
|
|
1267
1397
|
Args:
|
|
1268
1398
|
project (str / dict): The project dict or ID.
|
|
1269
1399
|
file_path (str): Location on hard drive where to save the file.
|
|
@@ -1276,13 +1406,19 @@ def download_project_avatar(project, file_path, client=default):
|
|
|
1276
1406
|
)
|
|
1277
1407
|
|
|
1278
1408
|
|
|
1279
|
-
def upload_project_avatar(
|
|
1409
|
+
def upload_project_avatar(
|
|
1410
|
+
project: str | dict, file_path: str, client: KitsuClient = default
|
|
1411
|
+
) -> dict[Literal["thumbnail_path"], str]:
|
|
1280
1412
|
"""
|
|
1281
1413
|
Upload given file as project avatar.
|
|
1282
1414
|
|
|
1283
1415
|
Args:
|
|
1284
1416
|
project (str / dict): The project dict or ID.
|
|
1285
1417
|
file_path (str): Path of the file to upload as avatar.
|
|
1418
|
+
|
|
1419
|
+
Returns:
|
|
1420
|
+
dict: Dictionary with a key of 'thumbnail_path' and a value of the
|
|
1421
|
+
path to the static image file, relative to the host url.
|
|
1286
1422
|
"""
|
|
1287
1423
|
path = (
|
|
1288
1424
|
"/pictures/thumbnails/projects/%s"
|
|
@@ -1291,9 +1427,12 @@ def upload_project_avatar(project, file_path, client=default):
|
|
|
1291
1427
|
return raw.upload(path, file_path, client=client)
|
|
1292
1428
|
|
|
1293
1429
|
|
|
1294
|
-
def download_organisation_avatar(
|
|
1430
|
+
def download_organisation_avatar(
|
|
1431
|
+
organisation: str | dict, file_path: str, client: KitsuClient = default
|
|
1432
|
+
) -> requests.Response:
|
|
1295
1433
|
"""
|
|
1296
1434
|
Download given organisation's avatar and save it at given location.
|
|
1435
|
+
|
|
1297
1436
|
Args:
|
|
1298
1437
|
organisation (str / dict): The organisation dict or ID.
|
|
1299
1438
|
file_path (str): Location on hard drive where to save the file.
|
|
@@ -1306,13 +1445,19 @@ def download_organisation_avatar(organisation, file_path, client=default):
|
|
|
1306
1445
|
)
|
|
1307
1446
|
|
|
1308
1447
|
|
|
1309
|
-
def upload_organisation_avatar(
|
|
1448
|
+
def upload_organisation_avatar(
|
|
1449
|
+
organisation: str | dict, file_path: str, client: KitsuClient = default
|
|
1450
|
+
) -> dict[Literal["thumbnail_path"], str]:
|
|
1310
1451
|
"""
|
|
1311
1452
|
Upload given file as organisation avatar.
|
|
1312
1453
|
|
|
1313
1454
|
Args:
|
|
1314
1455
|
organisation (str / dict): The organisation dict or ID.
|
|
1315
1456
|
file_path (str): Path of the file to upload as avatar.
|
|
1457
|
+
|
|
1458
|
+
Returns:
|
|
1459
|
+
dict: Dictionary with a key of 'thumbnail_path' and a value of the
|
|
1460
|
+
path to the static image file, relative to the host url.
|
|
1316
1461
|
"""
|
|
1317
1462
|
path = (
|
|
1318
1463
|
"/pictures/thumbnails/organisations/%s"
|
|
@@ -1321,12 +1466,15 @@ def upload_organisation_avatar(organisation, file_path, client=default):
|
|
|
1321
1466
|
return raw.upload(path, file_path, client=client)
|
|
1322
1467
|
|
|
1323
1468
|
|
|
1324
|
-
def update_preview(
|
|
1469
|
+
def update_preview(
|
|
1470
|
+
preview_file: str | dict, data: dict, client: KitsuClient = default
|
|
1471
|
+
) -> dict:
|
|
1325
1472
|
"""
|
|
1326
1473
|
Update the data of given preview file.
|
|
1327
1474
|
|
|
1328
1475
|
Args:
|
|
1329
1476
|
preview_file (str / dict): The preview file dict or ID.
|
|
1477
|
+
data (dict): Data to update on the prevew file.
|
|
1330
1478
|
|
|
1331
1479
|
Returns:
|
|
1332
1480
|
dict: Modified preview file
|
|
@@ -1336,9 +1484,255 @@ def update_preview(preview_file, data, client=default):
|
|
|
1336
1484
|
return raw.put(path, data, client=client)
|
|
1337
1485
|
|
|
1338
1486
|
|
|
1339
|
-
|
|
1487
|
+
@cache
|
|
1488
|
+
def get_running_preview_files(client: KitsuClient = default) -> list[dict]:
|
|
1489
|
+
"""
|
|
1490
|
+
Get all preview files currently being processed.
|
|
1491
|
+
|
|
1492
|
+
Returns:
|
|
1493
|
+
list: Preview files that are currently running/processing.
|
|
1494
|
+
"""
|
|
1495
|
+
return raw.fetch_all("preview-files/running", client=client)
|
|
1496
|
+
|
|
1497
|
+
|
|
1498
|
+
def get_preview_movie_url(
|
|
1499
|
+
preview_file: str | dict,
|
|
1500
|
+
lowdef: bool = False,
|
|
1501
|
+
client: KitsuClient = default,
|
|
1502
|
+
) -> str:
|
|
1503
|
+
"""
|
|
1504
|
+
Get the URL for the preview movie file.
|
|
1505
|
+
|
|
1506
|
+
Args:
|
|
1507
|
+
preview_file (str / dict): The preview file dict or ID.
|
|
1508
|
+
lowdef (bool): If True, returns the low-definition version URL.
|
|
1509
|
+
If False, returns the original/high-definition version URL.
|
|
1510
|
+
|
|
1511
|
+
Returns:
|
|
1512
|
+
str: URL to the preview movie file.
|
|
1513
|
+
"""
|
|
1514
|
+
preview_file = normalize_model_parameter(preview_file)
|
|
1515
|
+
preview_file = raw.fetch_one(
|
|
1516
|
+
"preview-files", preview_file["id"], client=client
|
|
1517
|
+
)
|
|
1518
|
+
if lowdef:
|
|
1519
|
+
path_prefix = "movies/lowdef"
|
|
1520
|
+
else:
|
|
1521
|
+
path_prefix = "movies/originals"
|
|
1522
|
+
return "%s/preview-files/%s.%s" % (
|
|
1523
|
+
path_prefix,
|
|
1524
|
+
preview_file["id"],
|
|
1525
|
+
preview_file["extension"],
|
|
1526
|
+
)
|
|
1527
|
+
|
|
1528
|
+
|
|
1529
|
+
def download_preview_movie(
|
|
1530
|
+
preview_file: str | dict, file_path: str, client: KitsuClient = default
|
|
1531
|
+
) -> requests.Response:
|
|
1532
|
+
"""
|
|
1533
|
+
Download the preview movie file.
|
|
1534
|
+
|
|
1535
|
+
Args:
|
|
1536
|
+
preview_file (str / dict): The preview file dict or ID.
|
|
1537
|
+
file_path (str): Location on hard drive where to save the file.
|
|
1538
|
+
|
|
1539
|
+
Returns:
|
|
1540
|
+
requests.Response: Response object from the download request.
|
|
1541
|
+
"""
|
|
1542
|
+
preview_file = normalize_model_parameter(preview_file)
|
|
1543
|
+
url = get_preview_movie_url(preview_file, lowdef=False, client=client)
|
|
1544
|
+
return raw.download(url, file_path, client=client)
|
|
1545
|
+
|
|
1546
|
+
|
|
1547
|
+
def get_preview_lowdef_movie_url(
|
|
1548
|
+
preview_file: str | dict, client: KitsuClient = default
|
|
1549
|
+
) -> str:
|
|
1550
|
+
"""
|
|
1551
|
+
Get the URL for the low-definition preview movie file.
|
|
1552
|
+
|
|
1553
|
+
Args:
|
|
1554
|
+
preview_file (str / dict): The preview file dict or ID.
|
|
1555
|
+
|
|
1556
|
+
Returns:
|
|
1557
|
+
str: URL to the low-definition preview movie file.
|
|
1558
|
+
"""
|
|
1559
|
+
return get_preview_movie_url(preview_file, lowdef=True, client=client)
|
|
1560
|
+
|
|
1561
|
+
|
|
1562
|
+
def download_preview_lowdef_movie(
|
|
1563
|
+
preview_file: str | dict, file_path: str, client: KitsuClient = default
|
|
1564
|
+
) -> requests.Response:
|
|
1565
|
+
"""
|
|
1566
|
+
Download the low-definition preview movie file.
|
|
1567
|
+
|
|
1568
|
+
Args:
|
|
1569
|
+
preview_file (str / dict): The preview file dict or ID.
|
|
1570
|
+
file_path (str): Location on hard drive where to save the file.
|
|
1571
|
+
|
|
1572
|
+
Returns:
|
|
1573
|
+
requests.Response: Response object from the download request.
|
|
1574
|
+
"""
|
|
1575
|
+
preview_file = normalize_model_parameter(preview_file)
|
|
1576
|
+
url = get_preview_movie_url(preview_file, lowdef=True, client=client)
|
|
1577
|
+
return raw.download(url, file_path, client=client)
|
|
1578
|
+
|
|
1579
|
+
|
|
1580
|
+
def get_attachment_thumbnail_url(
|
|
1581
|
+
attachment_file: str | dict, client: KitsuClient = default
|
|
1582
|
+
) -> str:
|
|
1583
|
+
"""
|
|
1584
|
+
Get the URL for the attachment file thumbnail.
|
|
1585
|
+
|
|
1586
|
+
Args:
|
|
1587
|
+
attachment_file (str / dict): The attachment file dict or ID.
|
|
1588
|
+
|
|
1589
|
+
Returns:
|
|
1590
|
+
str: URL to the attachment thumbnail.
|
|
1591
|
+
"""
|
|
1592
|
+
attachment_file = normalize_model_parameter(attachment_file)
|
|
1593
|
+
return "pictures/thumbnails/attachment-files/%s.png" % attachment_file["id"]
|
|
1594
|
+
|
|
1595
|
+
|
|
1596
|
+
def download_attachment_thumbnail(
|
|
1597
|
+
attachment_file: str | dict, file_path: str, client: KitsuClient = default
|
|
1598
|
+
) -> requests.Response:
|
|
1599
|
+
"""
|
|
1600
|
+
Download the attachment file thumbnail.
|
|
1601
|
+
|
|
1602
|
+
Args:
|
|
1603
|
+
attachment_file (str / dict): The attachment file dict or ID.
|
|
1604
|
+
file_path (str): Location on hard drive where to save the file.
|
|
1605
|
+
|
|
1606
|
+
Returns:
|
|
1607
|
+
requests.Response: Response object from the download request.
|
|
1608
|
+
"""
|
|
1609
|
+
attachment_file = normalize_model_parameter(attachment_file)
|
|
1610
|
+
url = get_attachment_thumbnail_url(attachment_file, client=client)
|
|
1611
|
+
return raw.download(url, file_path, client=client)
|
|
1612
|
+
|
|
1613
|
+
|
|
1614
|
+
def extract_frame_from_preview(
|
|
1615
|
+
preview_file: str | dict,
|
|
1616
|
+
frame_number: int,
|
|
1617
|
+
file_path: str | None = None,
|
|
1618
|
+
client: KitsuClient = default,
|
|
1619
|
+
) -> requests.Response:
|
|
1620
|
+
"""
|
|
1621
|
+
Extract a specific frame from a preview file.
|
|
1622
|
+
|
|
1623
|
+
Args:
|
|
1624
|
+
preview_file (str / dict): The preview file dict or ID.
|
|
1625
|
+
frame_number (int): The frame number to extract.
|
|
1626
|
+
file_path (str): Optional location on hard drive where to save the frame.
|
|
1627
|
+
If not provided, returns the response without saving.
|
|
1628
|
+
|
|
1629
|
+
Returns:
|
|
1630
|
+
requests.Response: Response object containing the extracted frame.
|
|
1631
|
+
"""
|
|
1632
|
+
preview_file = normalize_model_parameter(preview_file)
|
|
1633
|
+
url = "pictures/preview-files/%s/extract-frame/%s" % (
|
|
1634
|
+
preview_file["id"],
|
|
1635
|
+
frame_number,
|
|
1636
|
+
)
|
|
1637
|
+
return raw.download(url, file_path, client=client)
|
|
1638
|
+
|
|
1639
|
+
|
|
1640
|
+
def update_preview_position(
|
|
1641
|
+
preview_file: str | dict,
|
|
1642
|
+
position: float,
|
|
1643
|
+
client: KitsuClient = default,
|
|
1644
|
+
) -> dict:
|
|
1645
|
+
"""
|
|
1646
|
+
Update the position of a preview file (the displayed order for a single
|
|
1647
|
+
revision).
|
|
1648
|
+
|
|
1649
|
+
Args:
|
|
1650
|
+
preview_file (str / dict): The preview file dict or ID.
|
|
1651
|
+
position (float): The new position value.
|
|
1652
|
+
|
|
1653
|
+
Returns:
|
|
1654
|
+
dict: Updated preview file.
|
|
1655
|
+
"""
|
|
1656
|
+
preview_file = normalize_model_parameter(preview_file)
|
|
1657
|
+
path = "data/preview-files/%s/position" % preview_file["id"]
|
|
1658
|
+
return raw.put(path, {"position": position}, client=client)
|
|
1659
|
+
|
|
1660
|
+
|
|
1661
|
+
def update_preview_annotations(
|
|
1662
|
+
preview_file: str | dict,
|
|
1663
|
+
additions: list[dict] | None = None,
|
|
1664
|
+
updates: list[dict] | None = None,
|
|
1665
|
+
deletions: list[str] | None = None,
|
|
1666
|
+
client: KitsuClient = default,
|
|
1667
|
+
) -> dict:
|
|
1668
|
+
"""
|
|
1669
|
+
Update annotations on a preview file.
|
|
1670
|
+
|
|
1671
|
+
Allow to modify the annotations stored at the preview level. Modifications
|
|
1672
|
+
are applied via three fields: additions to give all the annotations that
|
|
1673
|
+
need to be added, updates that list annotations that need to be modified,
|
|
1674
|
+
and deletions to list the IDs of annotations that need to be removed.
|
|
1675
|
+
|
|
1676
|
+
Args:
|
|
1677
|
+
preview_file (str / dict): The preview file dict or ID.
|
|
1678
|
+
additions (list[dict]): Annotations to add. Each annotation should be
|
|
1679
|
+
a dict with properties like 'x', 'y', 'type', etc.
|
|
1680
|
+
Example: [{"x": 100, "y": 200, "type": "drawing"}]
|
|
1681
|
+
updates (list[dict]): Annotations to update. Each annotation should
|
|
1682
|
+
include an 'id' field along with the fields to update.
|
|
1683
|
+
Example: [{"id": "uuid", "x": 150, "y": 250}]
|
|
1684
|
+
deletions (list[str]): Annotation IDs to remove.
|
|
1685
|
+
Example: ["a24a6ea4-ce75-4665-a070-57453082c25"]
|
|
1686
|
+
|
|
1687
|
+
Returns:
|
|
1688
|
+
dict: Updated preview file with the updated annotations array.
|
|
1689
|
+
"""
|
|
1690
|
+
preview_file = normalize_model_parameter(preview_file)
|
|
1691
|
+
path = "actions/preview-files/%s/update-annotations" % preview_file["id"]
|
|
1692
|
+
data = {}
|
|
1693
|
+
if additions is not None:
|
|
1694
|
+
data["additions"] = additions
|
|
1695
|
+
if updates is not None:
|
|
1696
|
+
data["updates"] = updates
|
|
1697
|
+
if deletions is not None:
|
|
1698
|
+
data["deletions"] = deletions
|
|
1699
|
+
return raw.put(path, data, client=client)
|
|
1700
|
+
|
|
1701
|
+
|
|
1702
|
+
def extract_tile_from_preview(
|
|
1703
|
+
preview_file: str | dict,
|
|
1704
|
+
file_path: str | None = None,
|
|
1705
|
+
client: KitsuClient = default,
|
|
1706
|
+
) -> requests.Response:
|
|
1707
|
+
"""
|
|
1708
|
+
Extract a tile from a preview file.
|
|
1709
|
+
|
|
1710
|
+
Args:
|
|
1711
|
+
preview_file (str / dict): The preview file dict or ID.
|
|
1712
|
+
file_path (str): Optional location on hard drive where to save the tile.
|
|
1713
|
+
If not provided, returns the response without saving.
|
|
1714
|
+
|
|
1715
|
+
Returns:
|
|
1716
|
+
requests.Response: Response object containing the extracted tile.
|
|
1717
|
+
"""
|
|
1718
|
+
preview_file = normalize_model_parameter(preview_file)
|
|
1719
|
+
url = "pictures/preview-files/%s/extract-tile" % (
|
|
1720
|
+
preview_file["id"]
|
|
1721
|
+
)
|
|
1722
|
+
return raw.download(url, file_path, client=client)
|
|
1723
|
+
|
|
1724
|
+
|
|
1725
|
+
def new_file_status(
|
|
1726
|
+
name: str, color: str, client: KitsuClient = default
|
|
1727
|
+
) -> dict:
|
|
1340
1728
|
"""
|
|
1341
1729
|
Create a new file status if not existing yet.
|
|
1730
|
+
|
|
1731
|
+
If the file status already exists, the existing record will be returned.
|
|
1732
|
+
|
|
1733
|
+
Args:
|
|
1734
|
+
name (str): the name of the status to create.
|
|
1735
|
+
color (str): The color for the status as a Hex string, e.g "#00FF00".
|
|
1342
1736
|
"""
|
|
1343
1737
|
data = {"name": name, "color": color}
|
|
1344
1738
|
status = get_file_status_by_name(name, client=client)
|
|
@@ -1349,7 +1743,7 @@ def new_file_status(name, color, client=default):
|
|
|
1349
1743
|
|
|
1350
1744
|
|
|
1351
1745
|
@cache
|
|
1352
|
-
def get_file_status(status_id, client=default):
|
|
1746
|
+
def get_file_status(status_id: str, client: KitsuClient = default) -> dict:
|
|
1353
1747
|
"""
|
|
1354
1748
|
Return file status object corresponding to given ID.
|
|
1355
1749
|
|
|
@@ -1360,7 +1754,9 @@ def get_file_status(status_id, client=default):
|
|
|
1360
1754
|
|
|
1361
1755
|
|
|
1362
1756
|
@cache
|
|
1363
|
-
def get_file_status_by_name(
|
|
1757
|
+
def get_file_status_by_name(
|
|
1758
|
+
name: str, client: KitsuClient = default
|
|
1759
|
+
) -> dict | None:
|
|
1364
1760
|
"""
|
|
1365
1761
|
Return file status object corresponding to given name
|
|
1366
1762
|
|