gazu 1.0.3__py2.py3-none-any.whl → 1.1.1__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/context.py CHANGED
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  from . import user as gazu_user
2
4
  from . import project as gazu_project
3
5
  from . import asset as gazu_asset
@@ -6,7 +8,7 @@ from . import shot as gazu_shot
6
8
  from . import scene as gazu_scene
7
9
 
8
10
 
9
- def all_open_projects(user_context=False):
11
+ def all_open_projects(user_context: bool = False) -> list[dict]:
10
12
  """
11
13
  Return the list of projects for which the user has a task.
12
14
  """
@@ -16,7 +18,9 @@ def all_open_projects(user_context=False):
16
18
  return gazu_project.all_open_projects()
17
19
 
18
20
 
19
- def all_assets_for_project(project, user_context=False):
21
+ def all_assets_for_project(
22
+ project: str | dict, user_context: bool = False
23
+ ) -> list[dict]:
20
24
  """
21
25
  Return the list of assets for which the user has a task.
22
26
  """
@@ -26,7 +30,9 @@ def all_assets_for_project(project, user_context=False):
26
30
  return gazu_asset.all_assets_for_project(project)
27
31
 
28
32
 
29
- def all_asset_types_for_project(project, user_context=False):
33
+ def all_asset_types_for_project(
34
+ project: str | dict, user_context: bool = False
35
+ ) -> list[dict]:
30
36
  """
31
37
  Return the list of asset types for which the user has a task.
32
38
  """
@@ -37,8 +43,8 @@ def all_asset_types_for_project(project, user_context=False):
37
43
 
38
44
 
39
45
  def all_assets_for_asset_type_and_project(
40
- project, asset_type, user_context=False
41
- ):
46
+ project: str | dict, asset_type: str | dict, user_context: bool = False
47
+ ) -> list[dict]:
42
48
  """
43
49
  Return the list of assets for given project and asset_type and for which
44
50
  the user has a task.
@@ -51,7 +57,9 @@ def all_assets_for_asset_type_and_project(
51
57
  return gazu_asset.all_assets_for_project_and_type(project, asset_type)
52
58
 
53
59
 
54
- def all_task_types_for_asset(asset, user_context=False):
60
+ def all_task_types_for_asset(
61
+ asset: str | dict, user_context: bool = False
62
+ ) -> list[dict]:
55
63
  """
56
64
  Return the list of tasks for given asset and current user.
57
65
  """
@@ -61,7 +69,9 @@ def all_task_types_for_asset(asset, user_context=False):
61
69
  return gazu_task.all_task_types_for_asset(asset)
62
70
 
63
71
 
64
- def all_task_types_for_shot(shot, user_context=False):
72
+ def all_task_types_for_shot(
73
+ shot: str | dict, user_context: bool = False
74
+ ) -> list[dict]:
65
75
  """
66
76
  Return the list of tasks for given shot and current user.
67
77
  """
@@ -71,7 +81,9 @@ def all_task_types_for_shot(shot, user_context=False):
71
81
  return gazu_task.all_task_types_for_shot(shot)
72
82
 
73
83
 
74
- def all_task_types_for_scene(scene, user_context=False):
84
+ def all_task_types_for_scene(
85
+ scene: str | dict, user_context: bool = False
86
+ ) -> list[dict]:
75
87
  """
76
88
  Return the list of tasks for given scene and current user.
77
89
  """
@@ -81,7 +93,9 @@ def all_task_types_for_scene(scene, user_context=False):
81
93
  return gazu_task.all_task_types_for_scene(scene)
82
94
 
83
95
 
84
- def all_task_types_for_sequence(sequence, user_context=False):
96
+ def all_task_types_for_sequence(
97
+ sequence: str | dict, user_context: bool = False
98
+ ) -> list[dict]:
85
99
  """
86
100
  Return the list of tasks for given sequence and current user.
87
101
  """
@@ -91,7 +105,9 @@ def all_task_types_for_sequence(sequence, user_context=False):
91
105
  return gazu_task.all_task_types_for_sequence(sequence)
92
106
 
93
107
 
94
- def all_sequences_for_project(project, user_context=False):
108
+ def all_sequences_for_project(
109
+ project: str | dict, user_context: bool = False
110
+ ) -> list[dict]:
95
111
  """
96
112
  Return the list of sequences for given project and current user.
97
113
  """
@@ -101,7 +117,9 @@ def all_sequences_for_project(project, user_context=False):
101
117
  return gazu_shot.all_sequences_for_project(project)
102
118
 
103
119
 
104
- def all_scenes_for_project(project, user_context=False):
120
+ def all_scenes_for_project(
121
+ project: str | dict, user_context: bool = False
122
+ ) -> list[dict]:
105
123
  """
106
124
  Return the list of scenes for given project and current user.
107
125
  """
@@ -111,7 +129,9 @@ def all_scenes_for_project(project, user_context=False):
111
129
  return gazu_scene.all_scenes(project)
112
130
 
113
131
 
114
- def all_shots_for_sequence(sequence, user_context=False):
132
+ def all_shots_for_sequence(
133
+ sequence: str | dict, user_context: bool = False
134
+ ) -> list[dict]:
115
135
  """
116
136
  Return the list of shots for given sequence and current user.
117
137
  """
@@ -121,7 +141,9 @@ def all_shots_for_sequence(sequence, user_context=False):
121
141
  return gazu_shot.all_shots_for_sequence(sequence)
122
142
 
123
143
 
124
- def all_scenes_for_sequence(sequence, user_context=False):
144
+ def all_scenes_for_sequence(
145
+ sequence: str | dict, user_context: bool = False
146
+ ) -> list[dict]:
125
147
  """
126
148
  Return the list of scenes for given sequence and current user.
127
149
  """
@@ -131,7 +153,9 @@ def all_scenes_for_sequence(sequence, user_context=False):
131
153
  return gazu_scene.all_scenes_for_sequence(sequence)
132
154
 
133
155
 
134
- def all_sequences_for_episode(episode, user_context=False):
156
+ def all_sequences_for_episode(
157
+ episode: str | dict, user_context: bool = False
158
+ ) -> list[dict]:
135
159
  """
136
160
  Return the list of shots for given sequence and current user.
137
161
  """
@@ -141,7 +165,9 @@ def all_sequences_for_episode(episode, user_context=False):
141
165
  return gazu_shot.all_sequences_for_episode(episode)
142
166
 
143
167
 
144
- def all_episodes_for_project(project, user_context=False):
168
+ def all_episodes_for_project(
169
+ project: str | dict, user_context: bool = False
170
+ ) -> list[dict]:
145
171
  """
146
172
  Return the list of shots for given sequence and current user.
147
173
  """
gazu/edit.py CHANGED
@@ -1,6 +1,9 @@
1
+ from __future__ import annotations
2
+
1
3
  from . import client as raw
2
4
 
3
5
  from .cache import cache
6
+ from .client import KitsuClient
4
7
  from .helpers import normalize_model_parameter
5
8
  from gazu.sorting import sort_by_name
6
9
 
@@ -8,7 +11,7 @@ default = raw.default_client
8
11
 
9
12
 
10
13
  @cache
11
- def get_edit(edit_id, client=default):
14
+ def get_edit(edit_id: str, client: KitsuClient = default) -> dict:
12
15
  """
13
16
  Args:
14
17
  edit_id (str): ID of claimed edit.
@@ -20,7 +23,9 @@ def get_edit(edit_id, client=default):
20
23
 
21
24
 
22
25
  @cache
23
- def get_edit_by_name(project, edit_name, client=default):
26
+ def get_edit_by_name(
27
+ project: str | dict, edit_name: str, client: KitsuClient = default
28
+ ) -> dict | None:
24
29
  """
25
30
  Args:
26
31
  project (str / dict): The project dict or the project ID.
@@ -38,7 +43,7 @@ def get_edit_by_name(project, edit_name, client=default):
38
43
 
39
44
 
40
45
  @cache
41
- def get_edit_url(edit, client=default):
46
+ def get_edit_url(edit: str | dict, client: KitsuClient = default) -> str:
42
47
  """
43
48
  Args:
44
49
  edit (str / dict): The edit dict or the edit ID.
@@ -62,7 +67,9 @@ def get_edit_url(edit, client=default):
62
67
 
63
68
 
64
69
  @cache
65
- def all_edits_for_project(project, client=default):
70
+ def all_edits_for_project(
71
+ project: str | dict, client: KitsuClient = default
72
+ ) -> list[dict]:
66
73
  """
67
74
  Args:
68
75
  project (str / dict): The project dict or the project ID.
@@ -76,7 +83,9 @@ def all_edits_for_project(project, client=default):
76
83
 
77
84
 
78
85
  @cache
79
- def all_previews_for_edit(edit, client=default):
86
+ def all_previews_for_edit(
87
+ edit: str | dict, client: KitsuClient = default
88
+ ) -> list[dict]:
80
89
  """
81
90
  Args:
82
91
  edit (str / dict): The edit dict or the edit ID.
@@ -89,13 +98,13 @@ def all_previews_for_edit(edit, client=default):
89
98
 
90
99
 
91
100
  def new_edit(
92
- project,
93
- name,
94
- description=None,
95
- data={},
96
- episode=None,
97
- client=default,
98
- ):
101
+ project: str | dict,
102
+ name: str,
103
+ description: str | None = None,
104
+ data: dict = {},
105
+ episode: str | dict | None = None,
106
+ client: KitsuClient = default,
107
+ ) -> dict:
99
108
  """
100
109
  Create an edit for given project (and episode if given).
101
110
  Allow to set metadata too.
@@ -128,12 +137,20 @@ def new_edit(
128
137
  return edit
129
138
 
130
139
 
131
- def remove_edit(edit, force=False, client=default):
140
+ def remove_edit(
141
+ edit: str | dict, force: bool = False, client: KitsuClient = default
142
+ ) -> str:
132
143
  """
133
144
  Remove given edit from database.
134
145
 
146
+ If the Edit has tasks linked to it, this will by default mark the
147
+ Edit as canceled. Deletion can be forced regardless of task links
148
+ with the `force` parameter.
149
+
135
150
  Args:
136
- edit (dict / str): Edit to remove.
151
+ edit (str / dict): Edit to remove.
152
+ force (bool): Whether to force deletion of the edit regardless of
153
+ whether it has links to tasks.
137
154
  """
138
155
  edit = normalize_model_parameter(edit)
139
156
  path = "data/edits/%s" % edit["id"]
@@ -143,7 +160,7 @@ def remove_edit(edit, force=False, client=default):
143
160
  return raw.delete(path, params, client=client)
144
161
 
145
162
 
146
- def update_edit(edit, client=default):
163
+ def update_edit(edit: dict, client: KitsuClient = default) -> dict:
147
164
  """
148
165
  Save given edit data into the API. Metadata are fully replaced by the ones
149
166
  set on given edit.
@@ -157,13 +174,15 @@ def update_edit(edit, client=default):
157
174
  return raw.put("data/entities/%s" % edit["id"], edit, client=client)
158
175
 
159
176
 
160
- def update_edit_data(edit, data={}, client=default):
177
+ def update_edit_data(
178
+ edit: str | dict, data: dict = {}, client: KitsuClient = default
179
+ ) -> dict:
161
180
  """
162
181
  Update the metadata for the provided edit. Keys that are not provided are
163
182
  not changed.
164
183
 
165
184
  Args:
166
- edit (dict / ID): The edit dict or ID to save in database.
185
+ edit (str / dict): The edit dict or ID to save in database.
167
186
  data (dict): Free field to set metadata of any kind.
168
187
 
169
188
  Returns:
gazu/encoder.py CHANGED
@@ -1,6 +1,8 @@
1
1
  import json
2
2
  import datetime
3
3
 
4
+ from typing import Any
5
+
4
6
 
5
7
  class CustomJSONEncoder(json.JSONEncoder):
6
8
  """
@@ -8,7 +10,7 @@ class CustomJSONEncoder(json.JSONEncoder):
8
10
  The standard does not want to assum how you handle dates.
9
11
  """
10
12
 
11
- def default(self, obj):
13
+ def default(self, obj: Any) -> Any:
12
14
  if isinstance(obj, datetime.datetime):
13
15
  return obj.isoformat()
14
16
 
gazu/entity.py CHANGED
@@ -1,6 +1,9 @@
1
+ from __future__ import annotations
2
+
1
3
  from . import client as raw
2
4
 
3
5
  from .cache import cache
6
+ from .client import KitsuClient
4
7
  from .sorting import sort_by_name
5
8
  from .helpers import normalize_model_parameter
6
9
 
@@ -8,7 +11,7 @@ default = raw.default_client
8
11
 
9
12
 
10
13
  @cache
11
- def all_entities(client=default):
14
+ def all_entities(client: KitsuClient = default) -> list[dict]:
12
15
  """
13
16
  Returns:
14
17
  list: Retrieve all entities
@@ -17,7 +20,7 @@ def all_entities(client=default):
17
20
 
18
21
 
19
22
  @cache
20
- def all_entity_types(client=default):
23
+ def all_entity_types(client: KitsuClient = default) -> list[dict]:
21
24
  """
22
25
  Returns:
23
26
  list: Entity types listed in database.
@@ -26,7 +29,7 @@ def all_entity_types(client=default):
26
29
 
27
30
 
28
31
  @cache
29
- def get_entity(entity_id, client=default):
32
+ def get_entity(entity_id: str, client: KitsuClient = default) -> dict:
30
33
  """
31
34
  Args:
32
35
  entity_id (str): ID of claimed entity.
@@ -39,11 +42,15 @@ def get_entity(entity_id, client=default):
39
42
 
40
43
 
41
44
  @cache
42
- def get_entity_by_name(entity_name, project=None, client=default):
45
+ def get_entity_by_name(
46
+ entity_name: str,
47
+ project: str | dict | None = None,
48
+ client: KitsuClient = default,
49
+ ) -> dict | None:
43
50
  """
44
51
  Args:
45
- name (str): The name of the claimed entity.
46
- project (str, dict): Project ID or dict.
52
+ entity_name (str): The name of the claimed entity.
53
+ project (str / dict): Project ID or dict.
47
54
 
48
55
  Returns:
49
56
  Retrieve entity matching given name (and project if given).
@@ -56,10 +63,13 @@ def get_entity_by_name(entity_name, project=None, client=default):
56
63
 
57
64
 
58
65
  @cache
59
- def get_entity_type(entity_type_id, client=default):
66
+ def get_entity_type(
67
+ entity_type_id: str, client: KitsuClient = default
68
+ ) -> dict:
60
69
  """
61
70
  Args:
62
71
  entity_type_id (str): ID of claimed entity type.
72
+
63
73
  Returns:
64
74
  Retrieve entity type matching given ID (It can be an entity type of any
65
75
  kind).
@@ -68,7 +78,9 @@ def get_entity_type(entity_type_id, client=default):
68
78
 
69
79
 
70
80
  @cache
71
- def get_entity_type_by_name(entity_type_name, client=default):
81
+ def get_entity_type_by_name(
82
+ entity_type_name: str, client: KitsuClient = default
83
+ ) -> dict | None:
72
84
  """
73
85
  Args:
74
86
  entity_type_name (str): The name of the claimed entity type
@@ -82,17 +94,17 @@ def get_entity_type_by_name(entity_type_name, client=default):
82
94
 
83
95
 
84
96
  @cache
85
- def guess_from_path(project_id, path, sep="/"):
97
+ def guess_from_path(project_id: str, path: str, sep: str = "/") -> list[dict]:
86
98
  """
87
99
  Get list of possible project file tree templates matching a file path
88
100
  and data ids corresponding to template tokens.
89
101
 
90
102
  Args:
91
103
  project_id (str): Project id of given file
92
- file_path (str): Path to a file
104
+ path (str): Path to a file
93
105
  sep (str): File path separator, defaults to "/"
94
106
  Returns:
95
- list: dictionnaries with the corresponding entities and template name.
107
+ list: dictionaries with the corresponding entities and template name.
96
108
  """
97
109
  return raw.post(
98
110
  "/data/entities/guess_from_path",
@@ -100,38 +112,52 @@ def guess_from_path(project_id, path, sep="/"):
100
112
  )
101
113
 
102
114
 
103
- def new_entity_type(name, client=default):
115
+ def new_entity_type(name: str, client: KitsuClient = default) -> dict:
104
116
  """
105
117
  Creates an entity type with the given name.
106
118
 
107
119
  Args:
108
- name (str, client=default): The name of the entity type
120
+ name (str): The name of the entity type
109
121
 
110
122
  Returns:
111
123
  dict: The created entity type
124
+
125
+ Raises:
126
+ gazu.exception.ParameterException:
127
+ If an entity type with that name already exists.
112
128
  """
113
129
  data = {"name": name}
114
130
  return raw.create("entity-types", data, client=client)
115
131
 
116
132
 
117
- def remove_entity_type(entity_type, client=default):
133
+ def remove_entity_type(
134
+ entity_type: str | dict, client: KitsuClient = default
135
+ ) -> str:
118
136
  """
119
137
  Remove given entity type from database.
120
138
 
121
139
  Args:
122
- entity_type (dict / str): Entity type to remove.
140
+ entity_type (str / dict): Entity type to remove.
123
141
  """
124
142
  entity_type = normalize_model_parameter(entity_type)
125
143
  path = "data/entity-types/%s" % entity_type["id"]
126
144
  return raw.delete(path, client=client)
127
145
 
128
146
 
129
- def remove_entity(entity, force=False, client=default):
147
+ def remove_entity(
148
+ entity: str | dict, force: bool = False, client: KitsuClient = default
149
+ ) -> str:
130
150
  """
131
151
  Remove given entity from database.
132
152
 
153
+ If the Entity has tasks linked to it, this will by default mark the
154
+ Entity as canceled. Deletion can be forced regardless of task links
155
+ with the `force` parameter.
156
+
133
157
  Args:
134
158
  entity (dict): Entity to remove.
159
+ force (bool): Whether to force deletion of the entity regardless of
160
+ whether it has links to tasks.
135
161
  """
136
162
  entity = normalize_model_parameter(entity)
137
163
  path = "data/entities/%s" % entity["id"]
@@ -141,10 +167,13 @@ def remove_entity(entity, force=False, client=default):
141
167
  return raw.delete(path, params, client=client)
142
168
 
143
169
 
144
- def all_entities_with_tasks_linked_to_entity(entity, client=default):
170
+ def all_entities_with_tasks_linked_to_entity(
171
+ entity: str | dict, client: KitsuClient = default
172
+ ) -> list[dict]:
145
173
  """
146
174
  Args:
147
- entity (dict): Entity to get linked entities.
175
+ entity (str / dict): Entity to get linked entities.
176
+
148
177
  Returns:
149
178
  list: Retrieve all entities linked to given entity.
150
179
  """
gazu/events.py CHANGED
@@ -4,10 +4,17 @@ import inspect
4
4
  import signal
5
5
  import socketio
6
6
 
7
+ from typing import Any, Callable
8
+
7
9
  from engineio.base_client import signal_handler
8
10
  from .exception import AuthFailedException
9
11
 
10
- from .client import default_client, get_event_host, make_auth_header
12
+ from .client import (
13
+ default_client,
14
+ get_event_host,
15
+ KitsuClient,
16
+ make_auth_header,
17
+ )
11
18
 
12
19
 
13
20
  if os.name == "nt":
@@ -25,23 +32,23 @@ if os.name == "nt":
25
32
 
26
33
 
27
34
  class EventsNamespace(socketio.ClientNamespace):
28
- def on_connect(self):
35
+ def on_connect(self) -> None:
29
36
  pass
30
37
 
31
- def on_disconnect(self):
38
+ def on_disconnect(self) -> None:
32
39
  pass
33
40
 
34
- def on_error(self, data):
41
+ def on_error(self, data: str) -> str:
35
42
  return connect_error(data)
36
43
 
37
44
 
38
45
  def init(
39
- client=default_client,
40
- ssl_verify=False,
41
- reconnection=True,
42
- logger=False,
43
- **kwargs
44
- ):
46
+ client: KitsuClient = default_client,
47
+ ssl_verify: bool = False,
48
+ reconnection: bool = True,
49
+ logger: bool = False,
50
+ **kwargs: Any
51
+ ) -> socketio.Client:
45
52
  """
46
53
  Init configuration for SocketIO client.
47
54
 
@@ -61,13 +68,15 @@ def init(
61
68
  return event_client
62
69
 
63
70
 
64
- def connect_error(data):
71
+ def connect_error(data: str) -> str:
65
72
  print("The connection failed!")
66
73
  print(data)
67
74
  return data
68
75
 
69
76
 
70
- def add_listener(event_client, event_name, event_handler):
77
+ def add_listener(
78
+ event_client: socketio.Client, event_name: str, event_handler: Callable
79
+ ) -> socketio.Client:
71
80
  """
72
81
  Set a listener that reacts to a given event.
73
82
  """
@@ -75,7 +84,7 @@ def add_listener(event_client, event_name, event_handler):
75
84
  return event_client
76
85
 
77
86
 
78
- def run_client(event_client):
87
+ def run_client(event_client: socketio.Client) -> socketio.Client:
79
88
  """
80
89
  Run event client (it blocks current thread). It listens to all events
81
90
  configured.