File: __init__.py

package info (click to toggle)
python-bioblend 1.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,096 kB
  • sloc: python: 7,596; sh: 219; makefile: 158
file content (131 lines) | stat: -rw-r--r-- 5,643 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
"""
Interaction with a Tool Shed instance categories
"""
from typing import (
    Any,
    Dict,
    List,
    TYPE_CHECKING,
)

from typing_extensions import Literal

from bioblend.galaxy.client import Client

if TYPE_CHECKING:
    from bioblend.toolshed import ToolShedInstance


class ToolShedCategoryClient(Client):
    module = "categories"

    def __init__(self, toolshed_instance: "ToolShedInstance") -> None:
        super().__init__(toolshed_instance)

    def get_categories(self, deleted: bool = False) -> List[Dict[str, Any]]:
        """
        Returns a list of dictionaries that contain descriptions of the
        repository categories found on the given Tool Shed instance.

        :type deleted: bool
        :param deleted: whether to show deleted categories. Requires
          administrator access to the Tool Shed instance.

        :rtype: list
        :return: A list of dictionaries containing information about
          repository categories present in the Tool Shed.
          For example::

            [{'deleted': False,
              'description': 'Tools for manipulating data',
              'id': '175812cd7caaf439',
              'model_class': 'Category',
              'name': 'Text Manipulation',
              'url': '/api/categories/175812cd7caaf439'}]

        .. versionadded:: 0.5.2
        """
        return self._get(deleted=deleted)

    def show_category(self, category_id: str) -> Dict[str, Any]:
        """
        Get details of a given category.

        :type category_id: str
        :param category_id: Encoded category ID

        :rtype: dict
        :return: details of the given category
        """
        return self._get(id=category_id)

    def get_repositories(
        self, category_id: str, sort_key: Literal["name", "owner"] = "name", sort_order: Literal["asc", "desc"] = "asc"
    ) -> Dict[str, Any]:
        """
        Returns a dictionary of information for a repository category including
        a list of repositories belonging to the category.

        :type category_id: str
        :param category_id: Encoded category ID

        :type  sort_key: str
        :param sort_key: key for sorting. Options are 'name' or 'owner' (default 'name').

        :type  sort_order: str
        :param sort_order: ordering of sorted output. Options are 'asc' or 'desc' (default 'asc').

        :rtype: dict
        :return: A dict containing information about the category
          including a list of repository dicts.
          For example::

            {'deleted': False,
             'description': 'Tools for constructing and analyzing 3-dimensional shapes and '
                            'their properties',
             'id': '589548af7e391bcf',
             'model_class': 'Category',
             'name': 'Constructive Solid Geometry',
             'repositories': [{'create_time': '2016-08-23T18:53:23.845013',
                               'deleted': False,
                               'deprecated': False,
                               'description': 'Adds a surface field to a selected shape '
                                              'based on a given mathematical expression',
                               'homepage_url': 'https://github.com/gregvonkuster/galaxy-csg',
                               'id': 'af2ccc53697b064c',
                               'metadata': {'0:e12b55e960de': {'changeset_revision': 'e12b55e960de',
                                                               'downloadable': True,
                                                               'has_repository_dependencies': False,
                                                               'id': 'dfe022067783215f',
                                                               'includes_datatypes': False,
                                                               'includes_tool_dependencies': False,
                                                               'includes_tools': True,
                                                               'includes_tools_for_display_in_tool_panel': True,
                                                               'includes_workflows': False,
                                                               'malicious': False,
                                                               'missing_test_components': False,
                                                               'model_class': 'RepositoryMetadata',
                                                               'numeric_revision': 0,
                                                               'repository_id': 'af2ccc53697b064c'}},
                               'model_class': 'Repository',
                               'name': 'icqsol_add_surface_field_from_expression',
                               'owner': 'iuc',
                               'private': False,
                               'remote_repository_url': 'https://github.com/gregvonkuster/galaxy-csg',
                               'times_downloaded': 152,
                               'type': 'unrestricted',
                               'user_id': 'b563abc230aa8fd0'},
                              # ...
                              ],
             'repository_count': 11,
             'url': '/api/categories/589548af7e391bcf'}
        """

        params: Dict[str, Any] = {}
        if sort_key:
            params.update({"sort_key": sort_key})
        if sort_order:
            params.update({"sort_order": sort_order})

        url = self._make_url(category_id) + "/repositories"
        return self._get(url=url, params=params)