Skip to content

Commit

Permalink
Add name and owner parameters to ``ToolShedRepositoryClient.g…
Browse files Browse the repository at this point in the history
…et_repositories()``

xref. #462 (comment)
  • Loading branch information
nsoranzo committed Oct 13, 2022
1 parent 990b11a commit e3774a8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
``WorkflowClient.invoke_workflow()`` method (thanks to
[cat-bro](https://github.com/cat-bro)).

* Added ``name`` and ``owner`` parameters to
``ToolShedRepositoryClient.get_repositories()``.

* Remove unused methods from ``bioblend.config.Config``. If needed, use the
methods inherited from `configparser.ConfigParser` instead.

Expand Down
7 changes: 6 additions & 1 deletion bioblend/_tests/TestToolshed.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,18 @@ def test_repositories_client(self):
assert len(repositories) > 5000
assert repositories[0]["model_class"] == "Repository"

repositories = self.ts.repositories.get_repositories(name="bam_to_sam", owner="devteam")
assert len(repositories) == 1
bam_to_sam_repo = repositories[0]
assert bam_to_sam_repo["name"] == "bam_to_sam"
assert bam_to_sam_repo["owner"] == "devteam"

# search_repositories
samtools_search = self.ts.repositories.search_repositories("samtools", page_size=5)
assert int(samtools_search["total_results"]) > 20
assert len(samtools_search["hits"]) == 5

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

Expand Down
18 changes: 15 additions & 3 deletions bioblend/toolshed/repositories/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,16 @@ class ToolShedRepositoryClient(Client):
def __init__(self, toolshed_instance: "ToolShedInstance") -> None:
super().__init__(toolshed_instance)

def get_repositories(self) -> List[Dict[str, Any]]:
def get_repositories(self, name: Optional[str] = None, owner: Optional[str] = None) -> List[Dict[str, Any]]:
"""
Get a list of all the repositories in a Galaxy Tool Shed.
Get all repositories in a Galaxy Tool Shed, or select a subset by
specifying optional arguments for filtering (e.g. a repository name).
:type name: str
:param name: Repository name to filter on.
:type owner: str
:param owner: Repository owner to filter on.
:rtype: list
:return: Returns a list of dictionaries containing information about
Expand All @@ -54,7 +61,12 @@ def get_repositories(self) -> List[Dict[str, Any]]:
Changed method name from ``get_tools`` to ``get_repositories`` to
better align with the Tool Shed concepts.
"""
return self._get()
params = {}
if name:
params["name"] = name
if owner:
params["owner"] = owner
return self._get(params=params)

def search_repositories(
self,
Expand Down

0 comments on commit e3774a8

Please sign in to comment.