Warning
This document is for an in-development version of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.
Source code for tool_shed.repository_types.tool_dependency_definition
import logging
import tool_shed.repository_types.util as rt_util
from tool_shed.repository_types.metadata import TipOnly
from tool_shed.util import (
basic_util,
hg_util
)
log = logging.getLogger(__name__)
[docs]class ToolDependencyDefinition(TipOnly):
[docs] def __init__(self):
self.type = rt_util.TOOL_DEPENDENCY_DEFINITION
self.label = 'Tool dependency definition'
self.valid_file_names = ['tool_dependencies.xml']
[docs] def is_valid_for_type(self, app, repository, revisions_to_check=None):
"""
Inspect the received repository's contents to determine if they abide by the rules defined for the contents of this type.
If the received revisions_to_check is a list of changeset revisions, then inspection will be restricted to the revisions
in the list.
"""
repo = hg_util.get_repo_for_repository(app, repository=repository)
if revisions_to_check:
changeset_revisions = revisions_to_check
else:
changeset_revisions = repo.changelog
for changeset in changeset_revisions:
ctx = repo.changectx(changeset)
# Inspect all files in the changeset (in sorted order) to make sure there is only one and it is named tool_dependencies.xml.
files_changed_in_changeset = ctx.files()
for file_path in files_changed_in_changeset:
file_name = basic_util.strip_path(file_path)
if file_name not in self.valid_file_names:
return False
return True