Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

various improvements #310

Merged
merged 2 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions gazu/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import json

from deprecated import deprecated

from gazu.exception import (
TaskStatusNotFoundException,
TaskMustBeADictException,
Expand Down Expand Up @@ -403,20 +405,15 @@ def all_done_tasks_for_person(person, client=default):


@cache
def get_task_by_entity(entity, task_type, client=default):
return get_task_by_name(entity, task_type, client=client)


@cache
def get_task_by_name(entity, task_type, name="main", client=default):
def get_task_by_entity(entity, task_type, name="main", client=default):
"""
Args:
entity (str / dict): The entity dict or the entity ID.
task_type (str / dict): The task type dict or ID.
name (str): Name of the task to look for.

Returns:
Task matching given name for given entity and task type.
Task matching given entity, task type and name.
"""
entity = normalize_model_parameter(entity)
task_type = normalize_model_parameter(task_type)
Expand All @@ -431,6 +428,15 @@ def get_task_by_name(entity, task_type, name="main", client=default):
)


@deprecated(
version="0.9.17",
reason="You should use another function: gazu.task.get_task_by_entity, it will be removed in a future version of Gazu (0.10.0).",
)
@cache
def get_task_by_name(entity, task_type, name="main", client=default):
return get_task_by_entity(entity, task_type, name=name, client=client)


@cache
def get_task_type(task_type_id, client=default):
"""
Expand All @@ -450,6 +456,8 @@ def get_task_type_by_name(
"""
Args:
task_type_name (str): Name of claimed task type.
for_entity (str): The entity type for which the task type is created.
department (str): The department for which the task type is created.

Returns:
dict: Task type object for given name.
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ packages = find:
install_requires =
python-socketio[client]==5.11.0; python_version != '2.7'
requests>=2.25.1
Deprecated==1.2.14

[options.packages.find]
# ignore gazutest directory
Expand Down