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/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,11 +610,16 @@ 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/settings/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
 
@@ -558,7 +630,7 @@ def add_preview_background_file(project, background_file, client=default):
558
630
  project (dict / ID): The project dict or id.
559
631
  background_file (dict): A dict with a key of "preview_background_file_id"
560
632
  and value of the ID of the preview background to add.
561
-
633
+
562
634
  Returns:
563
635
  (dict): The project dictionary.
564
636
  """
@@ -570,7 +642,11 @@ def add_preview_background_file(project, background_file, client=default):
570
642
  )
571
643
 
572
644
 
573
- 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:
574
650
  """
575
651
  Remove a preview background file from a project.
576
652
 
@@ -588,7 +664,9 @@ def remove_preview_background_file(project, background_file, client=default):
588
664
 
589
665
 
590
666
  @cache
591
- def get_milestones(project, client=default):
667
+ def get_milestones(
668
+ project: str | dict, client: KitsuClient = default
669
+ ) -> list[dict]:
592
670
  """
593
671
  Get production milestones for a project.
594
672
 
@@ -602,7 +680,9 @@ def get_milestones(project, client=default):
602
680
 
603
681
 
604
682
  @cache
605
- def get_project_quotas(project, client=default):
683
+ def get_project_quotas(
684
+ project: str | dict, client: KitsuClient = default
685
+ ) -> list[dict]:
606
686
  """
607
687
  Get quotas for a project.
608
688
 
@@ -610,13 +690,13 @@ def get_project_quotas(project, client=default):
610
690
  project (dict / ID): The project dict or id.
611
691
  """
612
692
  project = normalize_model_parameter(project)
613
- return raw.fetch_all(
614
- "projects/%s/quotas" % project["id"], client=client
615
- )
693
+ return raw.fetch_all("projects/%s/quotas" % project["id"], client=client)
616
694
 
617
695
 
618
696
  @cache
619
- 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]:
620
700
  """
621
701
  Get quotas for a person within a project.
622
702
 
@@ -634,7 +714,9 @@ def get_project_person_quotas(project, person, client=default):
634
714
 
635
715
 
636
716
  @cache
637
- def get_budgets(project, client=default):
717
+ def get_budgets(
718
+ project: str | dict, client: KitsuClient = default
719
+ ) -> list[dict]:
638
720
  """
639
721
  Get budgets for a project.
640
722
 
@@ -646,15 +728,15 @@ def get_budgets(project, client=default):
646
728
 
647
729
 
648
730
  def create_budget(
649
- project,
650
- name,
651
- description=None,
652
- currency=None,
653
- start_date=None,
654
- end_date=None,
655
- amount=None,
656
- client=default,
657
- ):
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:
658
740
  """
659
741
  Create a budget for a project.
660
742
 
@@ -685,7 +767,9 @@ def create_budget(
685
767
 
686
768
 
687
769
  @cache
688
- def get_budget(project, budget, client=default):
770
+ def get_budget(
771
+ project: str | dict, budget: str | dict, client: KitsuClient = default
772
+ ) -> dict:
689
773
  """
690
774
  Get a specific budget.
691
775
 
@@ -700,7 +784,12 @@ def get_budget(project, budget, client=default):
700
784
  )
701
785
 
702
786
 
703
- 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:
704
793
  """
705
794
  Update a specific budget.
706
795
 
@@ -718,7 +807,9 @@ def update_budget(project, budget, data, client=default):
718
807
  )
719
808
 
720
809
 
721
- def remove_budget(project, budget, client=default):
810
+ def remove_budget(
811
+ project: str | dict, budget: str | dict, client: KitsuClient = default
812
+ ) -> str:
722
813
  """
723
814
  Delete a specific budget.
724
815
 
@@ -735,7 +826,9 @@ def remove_budget(project, budget, client=default):
735
826
 
736
827
 
737
828
  @cache
738
- 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]:
739
832
  """
740
833
  Get entries for a specific budget.
741
834
 
@@ -752,17 +845,17 @@ def get_budget_entries(project, budget, client=default):
752
845
 
753
846
 
754
847
  def create_budget_entry(
755
- project,
756
- budget,
757
- name,
758
- date=None,
759
- amount=None,
760
- quantity=None,
761
- unit_price=None,
762
- description=None,
763
- category=None,
764
- client=default,
765
- ):
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:
766
859
  """
767
860
  Create a budget entry for a specific budget.
768
861
 
@@ -793,15 +886,19 @@ def create_budget_entry(
793
886
  if category is not None:
794
887
  data["category"] = category
795
888
  return raw.post(
796
- "data/projects/%s/budgets/%s/entries"
797
- % (project["id"], budget["id"]),
889
+ "data/projects/%s/budgets/%s/entries" % (project["id"], budget["id"]),
798
890
  data,
799
891
  client=client,
800
892
  )
801
893
 
802
894
 
803
895
  @cache
804
- 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:
805
902
  """
806
903
  Get a specific budget entry.
807
904
 
@@ -820,7 +917,13 @@ def get_budget_entry(project, budget, entry, client=default):
820
917
  )
821
918
 
822
919
 
823
- 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:
824
927
  """
825
928
  Update a specific budget entry.
826
929
 
@@ -841,7 +944,12 @@ def update_budget_entry(project, budget, entry, data, client=default):
841
944
  )
842
945
 
843
946
 
844
- 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:
845
953
  """
846
954
  Delete a specific budget entry.
847
955
 
gazu/py.typed ADDED
File without changes