Skip to content

Commit e3774a8

Browse files
committed
Add name and owner parameters to ToolShedRepositoryClient.get_repositories()
xref. #462 (comment)
1 parent 990b11a commit e3774a8

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
``WorkflowClient.invoke_workflow()`` method (thanks to
1717
[cat-bro](https://github.com/cat-bro)).
1818

19+
* Added ``name`` and ``owner`` parameters to
20+
``ToolShedRepositoryClient.get_repositories()``.
21+
1922
* Remove unused methods from ``bioblend.config.Config``. If needed, use the
2023
methods inherited from `configparser.ConfigParser` instead.
2124

bioblend/_tests/TestToolshed.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,18 @@ def test_repositories_client(self):
3636
assert len(repositories) > 5000
3737
assert repositories[0]["model_class"] == "Repository"
3838

39+
repositories = self.ts.repositories.get_repositories(name="bam_to_sam", owner="devteam")
40+
assert len(repositories) == 1
41+
bam_to_sam_repo = repositories[0]
42+
assert bam_to_sam_repo["name"] == "bam_to_sam"
43+
assert bam_to_sam_repo["owner"] == "devteam"
44+
3945
# search_repositories
4046
samtools_search = self.ts.repositories.search_repositories("samtools", page_size=5)
4147
assert int(samtools_search["total_results"]) > 20
4248
assert len(samtools_search["hits"]) == 5
4349

4450
# show_repository
45-
bam_to_sam_repo = [r for r in repositories if r["name"] == "bam_to_sam"][0]
4651
show_bam_to_sam_repo = self.ts.repositories.show_repository(bam_to_sam_repo["id"])
4752
assert "SAM" in show_bam_to_sam_repo["long_description"]
4853

bioblend/toolshed/repositories/__init__.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,16 @@ class ToolShedRepositoryClient(Client):
2525
def __init__(self, toolshed_instance: "ToolShedInstance") -> None:
2626
super().__init__(toolshed_instance)
2727

28-
def get_repositories(self) -> List[Dict[str, Any]]:
28+
def get_repositories(self, name: Optional[str] = None, owner: Optional[str] = None) -> List[Dict[str, Any]]:
2929
"""
30-
Get a list of all the repositories in a Galaxy Tool Shed.
30+
Get all repositories in a Galaxy Tool Shed, or select a subset by
31+
specifying optional arguments for filtering (e.g. a repository name).
32+
33+
:type name: str
34+
:param name: Repository name to filter on.
35+
36+
:type owner: str
37+
:param owner: Repository owner to filter on.
3138
3239
:rtype: list
3340
:return: Returns a list of dictionaries containing information about
@@ -54,7 +61,12 @@ def get_repositories(self) -> List[Dict[str, Any]]:
5461
Changed method name from ``get_tools`` to ``get_repositories`` to
5562
better align with the Tool Shed concepts.
5663
"""
57-
return self._get()
64+
params = {}
65+
if name:
66+
params["name"] = name
67+
if owner:
68+
params["owner"] = owner
69+
return self._get(params=params)
5870

5971
def search_repositories(
6072
self,

0 commit comments

Comments
 (0)