diff --git a/gazu/sync.py b/gazu/sync.py index bc6a9f47..225a4ca7 100644 --- a/gazu/sync.py +++ b/gazu/sync.py @@ -56,6 +56,7 @@ def import_entities(entities, client=default): """ Import entities from another instance to target instance (keep id and audit dates). + Args: entities (list): Entities to import. @@ -69,6 +70,7 @@ def import_tasks(tasks, client=default): """ Import tasks from another instance to target instance (keep id and audit dates). + Args: tasks (list): Tasks to import. @@ -82,6 +84,7 @@ def import_entity_links(links, client=default): """ Import enitity links from another instance to target instance (keep id and audit dates). + Args: links (list): Entity links to import. @@ -292,7 +295,8 @@ def get_sync_person_id_map(source_client, target_client): def push_assets(project_source, project_target, client_source, client_target): """ Copy assets from source to target and preserve audit fields (`id`, - `created_at`, and `updated_at`) + `created_at`, and `updated_at`). + Args: project_source (dict): The project to get assets from project_target (dict): The project to push assets to @@ -321,6 +325,7 @@ def push_episodes( """ Copy episodes from source to target and preserve audit fields (`id`, `created_at`, and `updated_at`) + Args: project_source (dict): The project to get episodes from project_target (dict): The project to push episodes to @@ -344,6 +349,7 @@ def push_sequences( """ Copy sequences from source to target and preserve audit fields (`id`, `created_at`, and `updated_at`) + Args: project_source (dict): The project to get sequences from project_target (dict): The project to push sequences to @@ -364,7 +370,8 @@ def push_sequences( def push_shots(project_source, project_target, client_source, client_target): """ Copy shots from source to target and preserve audit fields (`id`, - `created_at`, and `updated_at`) + `created_at`, and `updated_at`). + Args: project_source (dict): The project to get shots from project_target (dict): The project to push shots to @@ -386,8 +393,9 @@ def push_entity_links( project_source, project_target, client_source, client_target ): """ - Copy assets from source to target and preserve audit fields (`id`, - `created_at`, and `updated_at`) + Copy entity links (breakdown, concepts) from source to target and preserve + audit fields (`id`, `created_at`, and `updated_at`). + Args: project_source (dict): The project to get assets from project_target (dict): The project to push assets to @@ -408,7 +416,8 @@ def push_project_entities( ): """ Copy assets, episodes, sequences, shots and entity links from source to - target and preserve audit fields (`id`, `created_at`, and `updated_at`) + target and preserve audit fields (`id`, `created_at`, and `updated_at`). + Args: project_source (dict): The project to get assets from project_target (dict): The project to push assets to @@ -445,6 +454,7 @@ def push_tasks( Copy tasks from source to target and preserve audit fields (`id`, `created_at`, and `updated_at`) Attachments and previews are created too. + Args: project_source (dict): The project to get assets from project_target (dict): The project to push assets to @@ -479,6 +489,7 @@ def push_tasks_comments(project_source, client_source, client_target): Create a new comment into target api for each comment in source project but preserve only `created_at` field. Attachments and previews are created too. + Args: project_source (dict): The project to get assets from project_target (dict): The project to push assets to @@ -508,6 +519,7 @@ def push_task_comments( Create a new comment into target api for each comment in source task but preserve only `created_at` field. Attachments and previews are created too. + Args: project_source (dict): The project to get assets from project_target (dict): The project to push assets to @@ -547,6 +559,7 @@ def push_task_comment( Create a new comment into target api for each comment in source task but preserve only `created_at` field. Attachments and previews are created too. + Args: project_source (dict): The project to get assets from project_target (dict): The project to push assets to diff --git a/gazu/task.py b/gazu/task.py index ece39327..f7db2aaa 100644 --- a/gazu/task.py +++ b/gazu/task.py @@ -257,25 +257,31 @@ def all_tasks_for_task_status(project, task_type, task_status, client=default): @cache -def all_tasks_for_task_type(project, task_type, client=default): +def all_tasks_for_task_type( + project, + task_type, + episode=None, + client=default +): """ Args: project (str / dict): The project dict or the project ID. task_type (str / dict): The task type dict or ID. + episode_id (str / dict): The episode dict or ID. Returns: list: Tasks for given project and task type. """ project = normalize_model_parameter(project) task_type = normalize_model_parameter(task_type) - return raw.fetch_all( - "tasks", - { - "project_id": project["id"], - "task_type_id": task_type["id"], - }, - client=client, - ) + params = { + "project_id": project["id"], + "task_type_id": task_type["id"], + } + if episode is not None: + episode = normalize_model_parameter(episode) + params["episode_id"] = episode["id"] + return raw.fetch_all("tasks", params, client=client) @cache @@ -1260,17 +1266,31 @@ def get_task_url(task, client=default): ) -def all_tasks_for_project(project, client=default): +def all_tasks_for_project( + project, + task_type=None, + episode=None, + client=default +): """ Args: - project (str / dict): The project + project (str / dict): The project (or its ID) to get tasks from. + task_type (str / dict): The task type (or its ID) to filter tasks. + episode (str / dict): The episode (or its ID) to filter tasks. Returns: dict: Tasks related to given project. """ project = normalize_model_parameter(project) path = "/data/projects/%s/tasks" % project["id"] - return raw.get(path, client=client) + params = {} + if task_type is not None: + task_type = normalize_model_parameter(task_type) + params["task_type_id"] = task_type["id"] + if episode is not None: + episode = normalize_model_parameter(episode) + params["episode_id"] = episode["id"] + return raw.get(path, params=params, client=client) def update_comment(comment, client=default):