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/project.py CHANGED
@@ -1,7 +1,12 @@
1
+ from __future__ import annotations
2
+
3
+ from typing_extensions import Literal # Python 3.7 compatibility.
4
+
1
5
  from . import client as raw
2
6
 
3
7
  from .sorting import sort_by_name
4
8
  from .cache import cache
9
+ from .client import KitsuClient
5
10
  from .helpers import (
6
11
  normalize_model_parameter,
7
12
  normalize_list_of_models_for_links,
@@ -11,7 +16,7 @@ default = raw.default_client
11
16
 
12
17
 
13
18
  @cache
14
- def all_project_status(client=default):
19
+ def all_project_status(client: KitsuClient = default) -> list[dict]:
15
20
  """
16
21
  Returns:
17
22
  list: Project status listed in database.
@@ -20,7 +25,9 @@ def all_project_status(client=default):
20
25
 
21
26
 
22
27
  @cache
23
- def get_project_status_by_name(project_status_name, client=default):
28
+ def get_project_status_by_name(
29
+ project_status_name: str, client: KitsuClient = default
30
+ ) -> dict | None:
24
31
  """
25
32
  Args:
26
33
  project_status_name (str): Name of claimed project status.
@@ -34,7 +41,7 @@ def get_project_status_by_name(project_status_name, client=default):
34
41
 
35
42
 
36
43
  @cache
37
- def all_projects(client=default):
44
+ def all_projects(client: KitsuClient = default) -> list[dict]:
38
45
  """
39
46
  Returns:
40
47
  list: Projects stored in the database.
@@ -43,7 +50,7 @@ def all_projects(client=default):
43
50
 
44
51
 
45
52
  @cache
46
- def all_open_projects(client=default):
53
+ def all_open_projects(client: KitsuClient = default) -> list[dict]:
47
54
  """
48
55
  Returns:
49
56
  Open projects stored in the database.
@@ -52,7 +59,7 @@ def all_open_projects(client=default):
52
59
 
53
60
 
54
61
  @cache
55
- def get_project(project_id, client=default):
62
+ def get_project(project_id: str, client: KitsuClient = default) -> dict:
56
63
  """
57
64
  Args:
58
65
  project_id (str): ID of claimed project.
@@ -64,7 +71,9 @@ def get_project(project_id, client=default):
64
71
 
65
72
 
66
73
  @cache
67
- def get_project_url(project, section="assets", client=default):
74
+ def get_project_url(
75
+ project: str | dict, section: str = "assets", client: KitsuClient = default
76
+ ) -> str:
68
77
  """
69
78
  Args:
70
79
  project (str / dict): The project dict or the project ID.
@@ -83,7 +92,9 @@ def get_project_url(project, section="assets", client=default):
83
92
 
84
93
 
85
94
  @cache
86
- def get_project_by_name(project_name, client=default):
95
+ def get_project_by_name(
96
+ project_name: str, client: KitsuClient = default
97
+ ) -> dict | None:
87
98
  """
88
99
  Args:
89
100
  project_name (str): Name of claimed project.
@@ -95,15 +106,15 @@ def get_project_by_name(project_name, client=default):
95
106
 
96
107
 
97
108
  def new_project(
98
- name,
99
- production_type="short",
100
- team=[],
101
- asset_types=[],
102
- task_statuses=[],
103
- task_types=[],
104
- production_style="2d3d",
105
- client=default,
106
- ):
109
+ name: str,
110
+ production_type: str = "short",
111
+ team: list = [],
112
+ asset_types: list = [],
113
+ task_statuses: list = [],
114
+ task_types: list = [],
115
+ production_style: str = "2d3d",
116
+ client: KitsuClient = default,
117
+ ) -> dict:
107
118
  """
108
119
  Creates a new project.
109
120
 
@@ -139,7 +150,9 @@ def new_project(
139
150
  return project
140
151
 
141
152
 
142
- def remove_project(project, force=False, client=default):
153
+ def remove_project(
154
+ project: str | dict, force: bool = False, client: KitsuClient = default
155
+ ) -> str:
143
156
  """
144
157
  Remove given project from database. (Prior to do that, make sure, there
145
158
  is no asset or shot left).
@@ -154,7 +167,7 @@ def remove_project(project, force=False, client=default):
154
167
  return raw.delete(path, client=client)
155
168
 
156
169
 
157
- def update_project(project, client=default):
170
+ def update_project(project: dict, client: KitsuClient = default) -> dict:
158
171
  """
159
172
  Save given project data into the API. Metadata are fully replaced by the
160
173
  ones set on given project.
@@ -182,7 +195,9 @@ def update_project(project, client=default):
182
195
  return raw.put("data/projects/%s" % project["id"], project, client=client)
183
196
 
184
197
 
185
- def update_project_data(project, data={}, client=default):
198
+ def update_project_data(
199
+ project: str | dict, data: dict = {}, client: KitsuClient = default
200
+ ) -> dict:
186
201
  """
187
202
  Update the metadata for the provided project. Keys that are not provided
188
203
  are not changed.
@@ -202,7 +217,7 @@ def update_project_data(project, data={}, client=default):
202
217
  return update_project(project, client=client)
203
218
 
204
219
 
205
- def close_project(project, client=default):
220
+ def close_project(project: str | dict, client: KitsuClient = default) -> dict:
206
221
  """
207
222
  Closes the provided project.
208
223
 
@@ -223,7 +238,9 @@ def close_project(project, client=default):
223
238
  return project
224
239
 
225
240
 
226
- def add_asset_type(project, asset_type, client=default):
241
+ def add_asset_type(
242
+ project: str | dict, asset_type: str | dict, client: KitsuClient = default
243
+ ) -> dict:
227
244
  project = normalize_model_parameter(project)
228
245
  asset_type = normalize_model_parameter(asset_type)
229
246
  data = {"asset_type_id": asset_type["id"]}
@@ -234,7 +251,12 @@ def add_asset_type(project, asset_type, client=default):
234
251
  )
235
252
 
236
253
 
237
- def add_task_type(project, task_type, priority, client=default):
254
+ def add_task_type(
255
+ project: str | dict,
256
+ task_type: str | dict,
257
+ priority: int,
258
+ client: KitsuClient = default,
259
+ ) -> dict:
238
260
  project = normalize_model_parameter(project)
239
261
  task_type = normalize_model_parameter(task_type)
240
262
  data = {"task_type_id": task_type["id"], "priority": priority}
@@ -245,7 +267,9 @@ def add_task_type(project, task_type, priority, client=default):
245
267
  )
246
268
 
247
269
 
248
- def add_task_status(project, task_status, client=default):
270
+ def add_task_status(
271
+ project: str | dict, task_status: str | dict, client: KitsuClient = default
272
+ ) -> dict:
249
273
  project = normalize_model_parameter(project)
250
274
  task_status = normalize_model_parameter(task_status)
251
275
  data = {"task_status_id": task_status["id"]}
@@ -257,15 +281,15 @@ def add_task_status(project, task_status, client=default):
257
281
 
258
282
 
259
283
  def add_metadata_descriptor(
260
- project,
261
- name,
262
- entity_type,
263
- data_type="string",
264
- choices=[],
265
- for_client=False,
266
- departments=[],
267
- client=default,
268
- ):
284
+ project: str | dict,
285
+ name: str,
286
+ entity_type: str,
287
+ data_type: str = "string",
288
+ choices: list[str] = [],
289
+ for_client: bool = False,
290
+ departments: list[str | dict] = [],
291
+ client: KitsuClient = default,
292
+ ) -> dict:
269
293
  """
270
294
  Create a new metadata descriptor for a project.
271
295
 
@@ -296,7 +320,11 @@ def add_metadata_descriptor(
296
320
  )
297
321
 
298
322
 
299
- def get_metadata_descriptor(project, metadata_descriptor_id, client=default):
323
+ def get_metadata_descriptor(
324
+ project: str | dict,
325
+ metadata_descriptor_id: str,
326
+ client: KitsuClient = default,
327
+ ) -> dict:
300
328
  """
301
329
  Retrieve a the metadata descriptor matching given ID.
302
330
 
@@ -316,13 +344,15 @@ def get_metadata_descriptor(project, metadata_descriptor_id, client=default):
316
344
  )
317
345
 
318
346
 
319
- def get_metadata_descriptor_by_field_name(project, field_name, client=default):
347
+ def get_metadata_descriptor_by_field_name(
348
+ project: str | dict, field_name: str, client: KitsuClient = default
349
+ ) -> dict | None:
320
350
  """
321
- Get a metadata descriptor matchind given project and name.
351
+ Get a metadata descriptor matching the given project and name.
322
352
 
323
353
  Args:
324
354
  project (dict / ID): The project dict or id.
325
- metadata_descriptor_id (dict / ID): The metadata descriptor dict or id.
355
+ field_name (str): The name of the metadata field.
326
356
 
327
357
  Returns:
328
358
  dict: The metadata descriptor matchind the ID.
@@ -338,7 +368,9 @@ def get_metadata_descriptor_by_field_name(project, field_name, client=default):
338
368
  )
339
369
 
340
370
 
341
- def all_metadata_descriptors(project, client=default):
371
+ def all_metadata_descriptors(
372
+ project: str | dict, client: KitsuClient = default
373
+ ) -> list[dict]:
342
374
  """
343
375
  Get all the metadata descriptors.
344
376
 
@@ -355,7 +387,11 @@ def all_metadata_descriptors(project, client=default):
355
387
  )
356
388
 
357
389
 
358
- def update_metadata_descriptor(project, metadata_descriptor, client=default):
390
+ def update_metadata_descriptor(
391
+ project: str | dict,
392
+ metadata_descriptor: dict,
393
+ client: KitsuClient = default,
394
+ ) -> dict:
359
395
  """
360
396
  Update a metadata descriptor.
361
397
 
@@ -383,8 +419,11 @@ def update_metadata_descriptor(project, metadata_descriptor, client=default):
383
419
 
384
420
 
385
421
  def remove_metadata_descriptor(
386
- project, metadata_descriptor_id, force=False, client=default
387
- ):
422
+ project: str | dict,
423
+ metadata_descriptor_id: str | dict,
424
+ force: bool = False,
425
+ client: KitsuClient = default,
426
+ ) -> str:
388
427
  """
389
428
  Remove a metadata descriptor.
390
429
 
@@ -405,24 +444,32 @@ def remove_metadata_descriptor(
405
444
  )
406
445
 
407
446
 
408
- def get_team(project, client=default):
447
+ def get_team(project: str | dict, client: KitsuClient = default) -> list[dict]:
409
448
  """
410
449
  Get team for project.
411
450
 
412
451
  Args:
413
452
  project (dict / ID): The project dict or id.
453
+
454
+ Returns:
455
+ list[dict]: The list of user dicts that are part of the project team.
414
456
  """
415
457
  project = normalize_model_parameter(project)
416
458
  return raw.fetch_all("projects/%s/team" % project["id"], client=client)
417
459
 
418
460
 
419
- def add_person_to_team(project, person, client=default):
461
+ def add_person_to_team(
462
+ project: str | dict, person: str | dict, client: KitsuClient = default
463
+ ) -> dict:
420
464
  """
421
465
  Add a person to the team project.
422
466
 
423
467
  Args:
424
468
  project (dict / ID): The project dict or id.
425
469
  person (dict / ID): The person dict or id.
470
+
471
+ Returns:
472
+ dict: The project dictionary.
426
473
  """
427
474
  project = normalize_model_parameter(project)
428
475
  person = normalize_model_parameter(person)
@@ -432,7 +479,9 @@ def add_person_to_team(project, person, client=default):
432
479
  )
433
480
 
434
481
 
435
- def remove_person_from_team(project, person, client=default):
482
+ def remove_person_from_team(
483
+ project: str | dict, person: str | dict, client: KitsuClient = default
484
+ ) -> str:
436
485
  """
437
486
  Remove a person from the team project.
438
487
 
@@ -449,7 +498,9 @@ def remove_person_from_team(project, person, client=default):
449
498
 
450
499
 
451
500
  @cache
452
- def get_project_task_types(project, client=default):
501
+ def get_project_task_types(
502
+ project: str | dict, client: KitsuClient = default
503
+ ) -> list[dict]:
453
504
  """
454
505
  Get task types configured for a project.
455
506
 
@@ -466,7 +517,9 @@ def get_project_task_types(project, client=default):
466
517
 
467
518
 
468
519
  @cache
469
- def get_project_task_statuses(project, client=default):
520
+ def get_project_task_statuses(
521
+ project: str | dict, client: KitsuClient = default
522
+ ) -> list[dict]:
470
523
  """
471
524
  Get task statuses configured for a project.
472
525
 
@@ -483,7 +536,9 @@ def get_project_task_statuses(project, client=default):
483
536
 
484
537
 
485
538
  @cache
486
- def all_status_automations(project, client=default):
539
+ def all_status_automations(
540
+ project: str | dict, client: KitsuClient = default
541
+ ) -> list[dict]:
487
542
  """
488
543
  Get status automations configured for a project.
489
544
 
@@ -500,13 +555,21 @@ def all_status_automations(project, client=default):
500
555
  )
501
556
 
502
557
 
503
- def add_status_automation(project, automation, client=default):
558
+ def add_status_automation(
559
+ project: str | dict,
560
+ automation: dict[Literal["status_automation_id"], str],
561
+ client: KitsuClient = default,
562
+ ) -> dict:
504
563
  """
505
564
  Add a status automation to the project.
506
565
 
507
566
  Args:
508
567
  project (dict / ID): The project dict or id.
509
- automation (dict): The automation payload (e.g. from/to status, task_type, rules).
568
+ automation (dict): A dictionary with a key of "status_automation_id" and
569
+ value of the automation ID.
570
+
571
+ Returns:
572
+ dict: The project dictionary.
510
573
  """
511
574
  project = normalize_model_parameter(project)
512
575
  return raw.post(
@@ -516,7 +579,9 @@ def add_status_automation(project, automation, client=default):
516
579
  )
517
580
 
518
581
 
519
- def remove_status_automation(project, automation, client=default):
582
+ def remove_status_automation(
583
+ project: str | dict, automation: str | dict, client: KitsuClient = default
584
+ ) -> str:
520
585
  """
521
586
  Remove a status automation from the project.
522
587
 
@@ -534,7 +599,9 @@ def remove_status_automation(project, automation, client=default):
534
599
 
535
600
 
536
601
  @cache
537
- def get_preview_background_files(project, client=default):
602
+ def get_preview_background_files(
603
+ project: str | dict, client: KitsuClient = default
604
+ ) -> list[dict]:
538
605
  """
539
606
  Get preview background files configured for a project.
540
607
 
@@ -543,27 +610,43 @@ def get_preview_background_files(project, client=default):
543
610
  """
544
611
  project = normalize_model_parameter(project)
545
612
  return raw.fetch_all(
546
- "projects/%s/preview-background-files" % project["id"], client=client
613
+ "projects/%s/settings/preview-background-files" % project["id"],
614
+ client=client,
547
615
  )
548
616
 
549
617
 
550
- def add_preview_background_file(project, background_file, client=default):
618
+ def add_preview_background_file(
619
+ project: str | dict,
620
+ background_file: dict[Literal["preview_background_file_id"], str],
621
+ client: KitsuClient = default,
622
+ ) -> dict:
551
623
  """
552
624
  Add a preview background file to a project.
553
625
 
626
+ The background_file payload must be a dict in the form:
627
+ {"preview_background_file_id": <background file id>}
628
+
554
629
  Args:
555
630
  project (dict / ID): The project dict or id.
556
- background_file (dict): Payload describing the background file to add.
631
+ background_file (dict): A dict with a key of "preview_background_file_id"
632
+ and value of the ID of the preview background to add.
633
+
634
+ Returns:
635
+ (dict): The project dictionary.
557
636
  """
558
637
  project = normalize_model_parameter(project)
559
638
  return raw.post(
560
- "data/projects/%s/preview-background-files" % project["id"],
639
+ "data/projects/%s/settings/preview-background-files" % project["id"],
561
640
  background_file,
562
641
  client=client,
563
642
  )
564
643
 
565
644
 
566
- def remove_preview_background_file(project, background_file, client=default):
645
+ def remove_preview_background_file(
646
+ project: str | dict,
647
+ background_file: str | dict,
648
+ client: KitsuClient = default,
649
+ ) -> str:
567
650
  """
568
651
  Remove a preview background file from a project.
569
652
 
@@ -574,14 +657,16 @@ def remove_preview_background_file(project, background_file, client=default):
574
657
  project = normalize_model_parameter(project)
575
658
  background_file = normalize_model_parameter(background_file)
576
659
  return raw.delete(
577
- "data/projects/%s/preview-background-files/%s"
660
+ "data/projects/%s/settings/preview-background-files/%s"
578
661
  % (project["id"], background_file["id"]),
579
662
  client=client,
580
663
  )
581
664
 
582
665
 
583
666
  @cache
584
- def get_milestones(project, client=default):
667
+ def get_milestones(
668
+ project: str | dict, client: KitsuClient = default
669
+ ) -> list[dict]:
585
670
  """
586
671
  Get production milestones for a project.
587
672
 
@@ -595,7 +680,9 @@ def get_milestones(project, client=default):
595
680
 
596
681
 
597
682
  @cache
598
- def get_project_quotas(project, client=default):
683
+ def get_project_quotas(
684
+ project: str | dict, client: KitsuClient = default
685
+ ) -> list[dict]:
599
686
  """
600
687
  Get quotas for a project.
601
688
 
@@ -603,13 +690,13 @@ def get_project_quotas(project, client=default):
603
690
  project (dict / ID): The project dict or id.
604
691
  """
605
692
  project = normalize_model_parameter(project)
606
- return raw.fetch_all(
607
- "projects/%s/quotas" % project["id"], client=client
608
- )
693
+ return raw.fetch_all("projects/%s/quotas" % project["id"], client=client)
609
694
 
610
695
 
611
696
  @cache
612
- def get_project_person_quotas(project, person, client=default):
697
+ def get_project_person_quotas(
698
+ project: str | dict, person: str | dict, client: KitsuClient = default
699
+ ) -> list[dict]:
613
700
  """
614
701
  Get quotas for a person within a project.
615
702
 
@@ -627,7 +714,9 @@ def get_project_person_quotas(project, person, client=default):
627
714
 
628
715
 
629
716
  @cache
630
- def get_budgets(project, client=default):
717
+ def get_budgets(
718
+ project: str | dict, client: KitsuClient = default
719
+ ) -> list[dict]:
631
720
  """
632
721
  Get budgets for a project.
633
722
 
@@ -639,15 +728,15 @@ def get_budgets(project, client=default):
639
728
 
640
729
 
641
730
  def create_budget(
642
- project,
643
- name,
644
- description=None,
645
- currency=None,
646
- start_date=None,
647
- end_date=None,
648
- amount=None,
649
- client=default,
650
- ):
731
+ project: str | dict,
732
+ name: str,
733
+ description: str | None = None,
734
+ currency: str | None = None,
735
+ start_date: str | None = None,
736
+ end_date: str | None = None,
737
+ amount: int | float | None = None,
738
+ client: KitsuClient = default,
739
+ ) -> dict:
651
740
  """
652
741
  Create a budget for a project.
653
742
 
@@ -678,7 +767,9 @@ def create_budget(
678
767
 
679
768
 
680
769
  @cache
681
- def get_budget(project, budget, client=default):
770
+ def get_budget(
771
+ project: str | dict, budget: str | dict, client: KitsuClient = default
772
+ ) -> dict:
682
773
  """
683
774
  Get a specific budget.
684
775
 
@@ -693,7 +784,12 @@ def get_budget(project, budget, client=default):
693
784
  )
694
785
 
695
786
 
696
- def update_budget(project, budget, data, client=default):
787
+ def update_budget(
788
+ project: str | dict,
789
+ budget: str | dict,
790
+ data: dict,
791
+ client: KitsuClient = default,
792
+ ) -> dict:
697
793
  """
698
794
  Update a specific budget.
699
795
 
@@ -711,7 +807,9 @@ def update_budget(project, budget, data, client=default):
711
807
  )
712
808
 
713
809
 
714
- def remove_budget(project, budget, client=default):
810
+ def remove_budget(
811
+ project: str | dict, budget: str | dict, client: KitsuClient = default
812
+ ) -> str:
715
813
  """
716
814
  Delete a specific budget.
717
815
 
@@ -728,7 +826,9 @@ def remove_budget(project, budget, client=default):
728
826
 
729
827
 
730
828
  @cache
731
- def get_budget_entries(project, budget, client=default):
829
+ def get_budget_entries(
830
+ project: str | dict, budget: str | dict, client: KitsuClient = default
831
+ ) -> list[dict]:
732
832
  """
733
833
  Get entries for a specific budget.
734
834
 
@@ -745,17 +845,17 @@ def get_budget_entries(project, budget, client=default):
745
845
 
746
846
 
747
847
  def create_budget_entry(
748
- project,
749
- budget,
750
- name,
751
- date=None,
752
- amount=None,
753
- quantity=None,
754
- unit_price=None,
755
- description=None,
756
- category=None,
757
- client=default,
758
- ):
848
+ project: str | dict,
849
+ budget: str | dict,
850
+ name: str,
851
+ date: str | None = None,
852
+ amount: int | float | None = None,
853
+ quantity: int | float | None = None,
854
+ unit_price: int | float | None = None,
855
+ description: str | None = None,
856
+ category: str | None = None,
857
+ client: KitsuClient = default,
858
+ ) -> dict:
759
859
  """
760
860
  Create a budget entry for a specific budget.
761
861
 
@@ -786,15 +886,19 @@ def create_budget_entry(
786
886
  if category is not None:
787
887
  data["category"] = category
788
888
  return raw.post(
789
- "data/projects/%s/budgets/%s/entries"
790
- % (project["id"], budget["id"]),
889
+ "data/projects/%s/budgets/%s/entries" % (project["id"], budget["id"]),
791
890
  data,
792
891
  client=client,
793
892
  )
794
893
 
795
894
 
796
895
  @cache
797
- def get_budget_entry(project, budget, entry, client=default):
896
+ def get_budget_entry(
897
+ project: str | dict,
898
+ budget: str | dict,
899
+ entry: str | dict,
900
+ client: KitsuClient = default,
901
+ ) -> dict:
798
902
  """
799
903
  Get a specific budget entry.
800
904
 
@@ -813,7 +917,13 @@ def get_budget_entry(project, budget, entry, client=default):
813
917
  )
814
918
 
815
919
 
816
- def update_budget_entry(project, budget, entry, data, client=default):
920
+ def update_budget_entry(
921
+ project: str | dict,
922
+ budget: str | dict,
923
+ entry: str | dict,
924
+ data: dict,
925
+ client: KitsuClient = default,
926
+ ) -> dict:
817
927
  """
818
928
  Update a specific budget entry.
819
929
 
@@ -834,7 +944,12 @@ def update_budget_entry(project, budget, entry, data, client=default):
834
944
  )
835
945
 
836
946
 
837
- def remove_budget_entry(project, budget, entry, client=default):
947
+ def remove_budget_entry(
948
+ project: str | dict,
949
+ budget: str | dict,
950
+ entry: str | dict,
951
+ client: KitsuClient = default,
952
+ ) -> str:
838
953
  """
839
954
  Delete a specific budget entry.
840
955
 
gazu/py.typed ADDED
File without changes