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.

tool_shed.util package

Submodules

tool_shed.util.admin_util module

class tool_shed.util.admin_util.Admin[source]

Bases: object

user_list_grid: Grid | None = None
role_list_grid: Grid | None = None
group_list_grid: Grid | None = None
delete_operation: GridOperation | None = None
undelete_operation: GridOperation | None = None
purge_operation: GridOperation | None = None
index(trans, **kwd)[source]
center(trans, **kwd)[source]
roles(trans, **kwargs)[source]
create_role(trans, **kwd)[source]
rename_role(trans, **kwd)[source]
manage_users_and_groups_for_role(trans, **kwd)[source]
mark_role_deleted(trans, **kwd)[source]
undelete_role(trans, **kwd)[source]
purge_role(trans, **kwd)[source]
groups(trans, **kwargs)[source]
rename_group(trans, **kwd)[source]
manage_users_and_roles_for_group(trans, **kwd)[source]
create_group(trans, **kwd)[source]
mark_group_deleted(trans, **kwd)[source]
undelete_group(trans, **kwd)[source]
purge_group(trans, **kwd)[source]
create_new_user(trans, **kwd)[source]
reset_user_password(trans, **kwd)[source]
mark_user_deleted(trans, **kwd)[source]
undelete_user(trans, **kwd)[source]
purge_user(trans, **kwd)[source]
users(trans, **kwd)[source]
name_autocomplete_data(trans, q=None, limit=None, timestamp=None)[source]

Return autocomplete data for user emails

manage_roles_and_groups_for_user(trans, **kwd)[source]
tool_shed.util.admin_util.get_user(trans, user_id)[source]

Get a User from the database by id.

tool_shed.util.admin_util.get_role(trans, id)[source]

Get a Role from the database by id.

tool_shed.util.admin_util.get_group(trans, id)[source]

Get a Group from the database by id.

tool_shed.util.admin_util.get_role_id(session, role_model, name)[source]
tool_shed.util.admin_util.get_group_id(session, group_model, name)[source]
tool_shed.util.admin_util.get_current_users(session, user_model)[source]
tool_shed.util.admin_util.get_current_groups(session, group_model)[source]
tool_shed.util.admin_util.get_current_roles(session, role_model)[source]
tool_shed.util.admin_util.get_ldda_by_dataset(session, dataset_id)[source]
tool_shed.util.admin_util.get_library_by_folder(session, folder_id)[source]
tool_shed.util.admin_util.get_user_emails_by_prefix(session, user_model, prefix)[source]

tool_shed.util.basic_util module

tool_shed.util.basic_util.get_file_type_str(changeset_revision, file_type)[source]
tool_shed.util.basic_util.move_file(current_dir, source, destination, rename_to=None)[source]
tool_shed.util.basic_util.remove_dir(dir)[source]

Attempt to remove a directory from disk.

tool_shed.util.basic_util.size_string(raw_text, size=32768)[source]

Return a subset of a string (up to MAX_DISPLAY_SIZE) translated to a safe string for display in a browser.

tool_shed.util.basic_util.stringify(list)[source]
tool_shed.util.basic_util.strip_path(fpath)[source]

Attempt to strip the path from a file name.

tool_shed.util.basic_util.to_html_string(text)[source]

Translates the characters in text to an html string

tool_shed.util.commit_util module

tool_shed.util.commit_util.check_archive(repository: Repository, archive)[source]
tool_shed.util.commit_util.check_file_contents_for_email_alerts(app: ToolShedApp)[source]

See if any admin users have chosen to receive email alerts when a repository is updated. If so, the file contents of the update must be checked for inappropriate content.

tool_shed.util.commit_util.check_file_content_for_html_and_images(file_path)[source]
tool_shed.util.commit_util.get_change_lines_in_file_for_tag(tag, change_dict)[source]

The received change_dict is the jsonified version of the changes to a file in a changeset being pushed to the Tool Shed from the command line. This method cleans and returns appropriate lines for inspection.

tool_shed.util.commit_util.handle_bz2(repository: Repository, uploaded_file_name)[source]
tool_shed.util.commit_util.handle_directory_changes(app: ToolShedApp, host: str, username: str, repository: Repository, full_path: str, filenames_in_archive, remove_repo_files_not_in_tar, new_repo_alert, commit_message: str, undesirable_dirs_removed: int, undesirable_files_removed: int, repo_path: str | None = None, dry_run: bool = False) Tuple[bool | str, str, List[str], str, int, int][source]
tool_shed.util.commit_util.handle_gzip(repository, uploaded_file_name)[source]
tool_shed.util.commit_util.uncompress(repository, uploaded_file_name, uploaded_file_filename, isgzip=False, isbz2=False)[source]
tool_shed.util.commit_util.get_repositories_with_alerts(session, repository_model)[source]

tool_shed.util.common_util module

tool_shed.util.common_util.accumulate_tool_dependencies(tool_shed_accessible, tool_dependencies, all_tool_dependencies)[source]
tool_shed.util.common_util.check_tool_tag_set(elem, migrated_tool_configs_dict, missing_tool_configs_dict)[source]
tool_shed.util.common_util.generate_clone_url_for_installed_repository(app: HasToolShedRegistry, repository) str[source]

Generate the URL for cloning a repository that has been installed into a Galaxy instance.

tool_shed.util.common_util.generate_clone_url_for_repository_in_tool_shed(user: User | None, repository: Repository, hostname: str | None = None) str[source]

Generate the URL for cloning a repository that is in the tool shed.

tool_shed.util.common_util.generate_clone_url_from_repo_info_tup(app: HasToolShedRegistry, repo_info_tup) str[source]

Generate the URL for cloning a repository given a tuple of toolshed, name, owner, changeset_revision.

tool_shed.util.common_util.get_repository_dependencies(app, tool_shed_url, repository_name, repository_owner, changeset_revision)[source]
tool_shed.util.common_util.get_protocol_from_tool_shed_url(tool_shed_url: str) str[source]

Return the protocol from the received tool_shed_url if it exists.

tool_shed.util.common_util.get_tool_shed_repository_ids(as_string=False, **kwd)[source]
tool_shed.util.common_util.get_tool_shed_url_from_tool_shed_registry(app: HasToolShedRegistry, tool_shed: str) str | None[source]

The value of tool_shed is something like: toolshed.g2.bx.psu.edu. We need the URL to this tool shed, which is something like: http://toolshed.g2.bx.psu.edu/

tool_shed.util.common_util.get_tool_shed_repository_url(app: HasToolShedRegistry, tool_shed: str, owner: str, name: str)[source]
tool_shed.util.common_util.handle_galaxy_url(trans, **kwd)[source]
tool_shed.util.common_util.handle_tool_shed_url_protocol(app: HasToolShedRegistry, shed_url: str) str[source]

Handle secure and insecure HTTP protocol since they may change over time.

tool_shed.util.common_util.parse_repository_dependency_tuple(repository_dependency_tuple, contains_error=False)[source]
tool_shed.util.common_util.remove_port_from_tool_shed_url(tool_shed_url: str) str[source]

Return a partial Tool Shed URL, eliminating the port if it exists.

tool_shed.util.common_util.remove_protocol_and_port_from_tool_shed_url(tool_shed_url: str) str[source]

Return a partial Tool Shed URL, eliminating the protocol and/or port if either exists.

tool_shed.util.common_util.remove_protocol_and_user_from_clone_url(repository_clone_url: str) str[source]

Return a URL that can be used to clone a repository, eliminating the protocol and user if either exists.

tool_shed.util.common_util.remove_protocol_from_tool_shed_url(tool_shed_url: str) str[source]

Return a partial Tool Shed URL, eliminating the protocol if it exists.

tool_shed.util.container_util module

tool_shed.util.container_util.generate_repository_dependencies_key_for_repository(toolshed_base_url: str, repository_name: str, repository_owner: str, changeset_revision: str, prior_installation_required: bool | str, only_if_compiling_contained_td: bool | str) str[source]

Assumes tool shed is current tool shed since repository dependencies across tool sheds is not yet supported.

tool_shed.util.container_util.get_components_from_key(key: str) tuple[source]

Assumes tool shed is current tool shed since repository dependencies across tool sheds is not yet supported.

tool_shed.util.encoding_util module

tool_shed.util.hg_util module

tool_shed.util.hg_util.add_changeset(repo_path, path_to_filename_in_archive)[source]
tool_shed.util.hg_util.archive_repository_revision(app, repository, archive_dir, changeset_revision)[source]

Create an un-versioned archive of a repository.

tool_shed.util.hg_util.clone_repository(repository_clone_url: str, repository_file_dir: str, ctx_rev=None) Tuple[bool, str | None][source]

Clone the repository up to the specified changeset_revision. No subsequent revisions will be present in the cloned repository.

tool_shed.util.hg_util.commit_changeset(repo_path: str, full_path_to_changeset: str, username: str, message: str) None[source]
tool_shed.util.hg_util.copy_file_from_manifest(repo, changeset_revision, filename, dir)[source]

Copy the latest version of the file named filename from the repository manifest to the directory to which dir refers.

tool_shed.util.hg_util.create_hgrc_file(app, repository, repo_path)[source]
tool_shed.util.hg_util.get_changectx_for_changeset(repo, changeset_revision, **kwd)[source]

Retrieve a specified changectx from a repository.

tool_shed.util.hg_util.get_config_from_disk(config_file: str, relative_install_dir: str) str | None[source]
tool_shed.util.hg_util.get_ctx_file_path_from_manifest(filename, repo, changeset_revision)[source]

Get the ctx file path for the latest revision of filename from the repository manifest up to the value of changeset_revision.

tool_shed.util.hg_util.get_file_context_from_ctx(ctx, filename)[source]

Return the mercurial file context for a specified file.

tool_shed.util.hg_util.get_named_tmpfile_from_ctx(ctx, filename, dir)[source]

Return a named temporary file created from a specified file with a given name included in a repository changeset revision.

tool_shed.util.hg_util.get_readable_ctx_date(ctx)[source]

Convert the date of the changeset (the received ctx) to a human-readable date.

tool_shed.util.hg_util.get_repository_heads(repo)[source]

Return current repository heads, which are changesets with no child changesets.

tool_shed.util.hg_util.get_reversed_changelog_changesets(repo)[source]

Return a list of changesets in reverse order from that provided by the repository manifest.

tool_shed.util.hg_util.get_revision_label(app, repository, changeset_revision, include_date=True, include_hash=True)[source]

Return a string consisting of the human readable changeset rev and the changeset revision string which includes the revision date if the receive include_date is True.

tool_shed.util.hg_util.get_rev_label_changeset_revision_from_repository_metadata(app, repository_metadata, repository=None, include_date=True, include_hash=True)[source]
tool_shed.util.hg_util.get_revision_label_from_ctx(ctx, include_date=True, include_hash=True)[source]
tool_shed.util.hg_util.get_rev_label_from_changeset_revision(repo, changeset_revision, include_date=True, include_hash=True)[source]

Given a changeset revision hash, return two strings, the changeset rev and the changeset revision hash which includes the revision date if the receive include_date is True.

tool_shed.util.hg_util.pull_repository(repo_path, repository_clone_url, ctx_rev)[source]

Pull changes from a remote repository to a local one.

tool_shed.util.hg_util.remove_path(repo_path, selected_file)[source]
tool_shed.util.hg_util.reversed_lower_upper_bounded_changelog(repo, excluded_lower_bounds_changeset_revision, included_upper_bounds_changeset_revision)[source]

Return a reversed list of changesets in the repository changelog after the excluded_lower_bounds_changeset_revision, but up to and including the included_upper_bounds_changeset_revision. The value of excluded_lower_bounds_changeset_revision will be the value of INITIAL_CHANGELOG_HASH if no valid changesets exist before included_upper_bounds_changeset_revision.

tool_shed.util.hg_util.reversed_upper_bounded_changelog(repo, included_upper_bounds_changeset_revision)[source]

Return a reversed list of changesets in the repository changelog up to and including the included_upper_bounds_changeset_revision.

tool_shed.util.hg_util.update_repository(repo_path, ctx_rev=None)[source]

Update the cloned repository to changeset_revision. It is critical that the installed repository is updated to the desired changeset_revision before metadata is set because the process for setting metadata uses the repository files on disk.

tool_shed.util.hg_util.init_repository(repo_path)[source]

Create a new Mercurial repository in the given directory.

tool_shed.util.hg_util.changeset2rev(repo_path, changeset_revision)[source]

Return the revision number (as an int) corresponding to a specified changeset revision.

tool_shed.util.hgweb_config module

class tool_shed.util.hgweb_config.HgWebConfigManager[source]

Bases: object

__init__()[source]
add_entry(lhs, rhs)[source]

Add an entry in the hgweb.config file for a new repository.

change_entry(old_lhs, new_lhs, new_rhs)[source]

Change an entry in the hgweb.config file for a repository - this only happens when the owner changes the name of the repository.

get_entry(lhs)[source]

Return an entry in the hgweb.config file for a repository

property hgweb_config
make_backup()[source]
read_config(force_read=False)[source]
write_config()[source]

Writing the in-memory configuration to the hgweb.config file on disk.

tool_shed.util.metadata_util module

tool_shed.util.metadata_util.get_all_dependencies(app, metadata_entry, processed_dependency_links=None)[source]
tool_shed.util.metadata_util.get_current_repository_metadata_for_changeset_revision(app, repository, changeset_revision)[source]
tool_shed.util.metadata_util.get_dependencies_for_metadata_revision(app, metadata)[source]
tool_shed.util.metadata_util.get_latest_changeset_revision(app, repository)[source]
tool_shed.util.metadata_util.get_latest_downloadable_changeset_revision(app, repository)[source]
tool_shed.util.metadata_util.get_latest_repository_metadata(app, decoded_repository_id, downloadable=False)[source]

Get last metadata defined for a specified repository from the database.

tool_shed.util.metadata_util.get_metadata_revisions(app, repository, sort_revisions=True, reverse=False, downloadable=True)[source]

Return a list of changesets for the provided repository.

tool_shed.util.metadata_util.get_next_downloadable_changeset_revision(app, repository, after_changeset_revision)[source]

Return the installable changeset_revision in the repository changelog after the changeset to which after_changeset_revision refers. If there isn’t one, return None. If there is only one installable changeset, and that matches the requested revision, return it.

tool_shed.util.metadata_util.get_previous_metadata_changeset_revision(app, repository, before_changeset_revision, downloadable=True)[source]

Return the changeset_revision in the repository changelog that has associated metadata prior to the changeset to which before_changeset_revision refers. If there isn’t one, return the hash value of an empty repository changelog, INITIAL_CHANGELOG_HASH.

tool_shed.util.metadata_util.get_repository_dependency_tups_from_repository_metadata(app, repository_metadata, deprecated_only=False)[source]

Return a list of of tuples defining repository objects required by the received repository. The returned list defines the entire repository dependency tree. This method is called only from the Tool Shed.

tool_shed.util.metadata_util.get_repository_metadata_by_changeset_revision(app: ToolShedApp, id: str, changeset_revision: str) RepositoryMetadata | None[source]

Get metadata for a specified repository change set from the database.

tool_shed.util.metadata_util.repository_metadata_by_changeset_revision(model_mapping: ToolShedModelMapping, id: int, changeset_revision: str) RepositoryMetadata | None[source]
tool_shed.util.metadata_util.get_repository_metadata_by_id(app, id)[source]

Get repository metadata from the database

tool_shed.util.metadata_util.get_repository_metadata_by_repository_id_changeset_revision(app, id, changeset_revision, metadata_only=False)[source]

Get a specified metadata record for a specified repository in the tool shed.

tool_shed.util.metadata_util.get_updated_changeset_revisions(app, name, owner, changeset_revision)[source]

Return a string of comma-separated changeset revision hashes for all available updates to the received changeset revision for the repository defined by the received name and owner.

tool_shed.util.metadata_util.is_downloadable(metadata_dict)[source]
tool_shed.util.metadata_util.is_malicious(app, id, changeset_revision, **kwd)[source]

Check the malicious flag in repository metadata for a specified change set revision.

tool_shed.util.metadata_util.get_metadata_by_changeset(session, repository_id, changeset_revision, repository_metadata_model)[source]

tool_shed.util.readme_util module

tool_shed.util.readme_util.build_readme_files_dict(app, repository, changeset_revision, metadata, tool_path=None)[source]

Return a dictionary of valid readme file name <-> readme file content pairs for all readme files defined in the received metadata. Since the received changeset_revision (which is associated with the received metadata) may not be the latest installable changeset revision, the README file contents may not be available on disk. This method is used by both Galaxy and the Tool Shed.

tool_shed.util.readme_util.get_readme_files_dict_for_display(app, tool_shed_url, repo_info_dict)[source]

Return a dictionary of README files contained in the single repository being installed so they can be displayed on the tool panel section selection page.

tool_shed.util.repository_content_util module

tool_shed.util.repository_content_util.tar_open(uploaded_file)[source]
tool_shed.util.repository_content_util.upload_tar(trans: ProvidesRepositoriesContext, username: str, repository: Repository, uploaded_file, commit_message: str, dry_run: bool = False, remove_repo_files_not_in_tar: bool = True, new_repo_alert: bool = False, tar=None, rdah: RepositoryDependencyAttributeHandler | None = None, tdah: ToolDependencyAttributeHandler | None = None) Tuple[bool | str, str, List[str], str, int, int][source]

tool_shed.util.repository_util module

tool_shed.util.repository_util.change_repository_name_in_hgrc_file(hgrc_file: str, new_name: str) None[source]
tool_shed.util.repository_util.create_or_update_tool_shed_repository(app, name, description, installed_changeset_revision, ctx_rev, repository_clone_url, status, metadata_dict=None, current_changeset_revision=None, owner='', dist_to_shed=False)[source]

Update a tool shed repository record in the Galaxy database with the new information received. If a record defined by the received tool shed, repository name and owner does not exist, create a new record with the received information.

tool_shed.util.repository_util.create_repo_info_dict(app: ToolShedApp, repository_clone_url, changeset_revision, ctx_rev, repository_owner, repository_name=None, repository=None, repository_metadata=None, tool_dependencies=None, repository_dependencies=None, trans=None)[source]

Return a dictionary that includes all of the information needed to install a repository into a local Galaxy instance. The dictionary will also contain the recursive list of repository dependencies defined for the repository, as well as the defined tool dependencies.

This method is called from Galaxy under four scenarios: 1. During the tool shed repository installation process via the tool shed’s get_repository_information() method. In this case both the received repository and repository_metadata will be objects, but tool_dependencies and repository_dependencies will be None. 2. When getting updates for an installed repository where the updates include newly defined repository dependency definitions. This scenario is similar to 1. above. The tool shed’s get_repository_information() method is the caller, and both the received repository and repository_metadata will be objects, but tool_dependencies and repository_dependencies will be None. 3. When a tool shed repository that was uninstalled from a Galaxy instance is being reinstalled with no updates available. In this case, both repository and repository_metadata will be None, but tool_dependencies and repository_dependencies will be objects previously retrieved from the tool shed if the repository includes definitions for them. 4. When a tool shed repository that was uninstalled from a Galaxy instance is being reinstalled with updates available. In this case, this method is reached via the tool shed’s get_updated_repository_information() method, and both repository and repository_metadata will be objects but tool_dependencies and repository_dependencies will be None.

tool_shed.util.repository_util.create_repository_admin_role(app: ToolShedApp, repository: Repository)[source]

Create a new role with name-spaced name based on the repository name and its owner’s public user name. This will ensure that the role name is unique.

tool_shed.util.repository_util.create_repository(app: ToolShedApp, name: str, type: str, description, long_description, user, category_ids: List[str] | None = None, remote_repository_url=None, homepage_url=None) Tuple[Repository, str][source]

Create a new ToolShed repository

tool_shed.util.repository_util.extract_components_from_tuple(repository_components_tuple)[source]

Extract the repository components from the provided tuple in a backward-compatible manner.

Generate the URL for sharing a repository that is in the tool shed.

tool_shed.util.repository_util.generate_tool_shed_repository_install_dir(repository_clone_url, changeset_revision)[source]

Generate a repository installation directory that guarantees repositories with the same name will always be installed in different directories. The tool path will be of the form: <tool shed url>/repos/<repository owner>/<repository name>/<installed changeset revision>

tool_shed.util.repository_util.get_absolute_path_to_file_in_repository(repo_files_dir, file_name)[source]

Return the absolute path to a specified disk file contained in a repository.

tool_shed.util.repository_util.get_ids_of_tool_shed_repositories_being_installed(app, as_string=False)[source]
tool_shed.util.repository_util.get_installed_repository(app, tool_shed=None, name=None, owner=None, changeset_revision=None, installed_changeset_revision=None, repository_id=None, from_cache=False)[source]

Return a tool shed repository database record defined by the combination of a toolshed, repository name, repository owner and either current or originally installed changeset_revision.

tool_shed.util.repository_util.get_installed_tool_shed_repository(app, id)[source]

Get a tool shed repository record from the Galaxy database defined by the id.

tool_shed.util.repository_util.get_prior_import_or_install_required_dict(app, tsr_ids, repo_info_dicts)[source]

This method is used in the Tool Shed when exporting a repository and its dependencies, and in Galaxy when a repository and its dependencies are being installed. Return a dictionary whose keys are the received tsr_ids and whose values are a list of tsr_ids, each of which is contained in the received list of tsr_ids and whose associated repository must be imported or installed prior to the repository associated with the tsr_id key.

tool_shed.util.repository_util.get_repo_info_dict(trans: ProvidesRepositoriesContext, repository_id, changeset_revision)[source]
tool_shed.util.repository_util.get_repo_info_tuple_contents(repo_info_tuple: Tuple[str, str, str, str, str, Dict[str, Dict[str, Any] | List[Dict[str, Any]]]] | Tuple[str, str, str, str, str, Any | None, Dict[str, Dict[str, Any] | List[Dict[str, Any]]]]) Tuple[str, str, str, str, str, Any | None, Dict[str, Dict[str, Any] | List[Dict[str, Any]]]][source]

Take care in handling the repo_info_tuple as it evolves over time as new tool shed features are introduced.

tool_shed.util.repository_util.get_repositories_by_category(app: ToolShedApp, category_id, installable=False, sort_order='asc', sort_key='name', page=None, per_page=25)[source]
tool_shed.util.repository_util.get_repository_admin_role_name(repository_name, repository_owner)[source]
tool_shed.util.repository_util.get_repository_and_repository_dependencies_from_repo_info_dict(app, repo_info_dict)[source]

Return a tool_shed_repository or repository record defined by the information in the received repo_info_dict.

tool_shed.util.repository_util.get_repository_by_id(app, id)[source]

Get a repository from the database via id.

tool_shed.util.repository_util.get_repository_by_name(app, name)[source]

Get a repository from the database via name.

tool_shed.util.repository_util.get_repository_by_name_and_owner(app, name, owner, eagerload_columns=None)[source]

Get a repository from the database via name and owner

tool_shed.util.repository_util.get_repository_dependency_types(repository_dependencies)[source]

Inspect the received list of repository_dependencies tuples and return boolean values for has_repository_dependencies and has_repository_dependencies_only_if_compiling_contained_td.

tool_shed.util.repository_util.get_repository_for_dependency_relationship(app, tool_shed, name, owner, changeset_revision)[source]

Return an installed tool_shed_repository database record that is defined by either the current changeset revision or the installed_changeset_revision.

tool_shed.util.repository_util.get_repository_ids_requiring_prior_import_or_install(app, tsr_ids, repository_dependencies)[source]

This method is used in the Tool Shed when exporting a repository and its dependencies, and in Galaxy when a repository and its dependencies are being installed. Inspect the received repository_dependencies and determine if the encoded id of each required repository is in the received tsr_ids. If so, then determine whether that required repository should be imported / installed prior to its dependent repository. Return a list of encoded repository ids, each of which is contained in the received list of tsr_ids, and whose associated repositories must be imported / installed prior to the dependent repository associated with the received repository_dependencies.

tool_shed.util.repository_util.get_repository_in_tool_shed(app, id, eagerload_columns=None)[source]

Get a repository on the tool shed side from the database via id.

tool_shed.util.repository_util.get_repository_owner(cleaned_repository_url)[source]

Gvien a “cleaned” repository clone URL, return the owner of the repository.

tool_shed.util.repository_util.get_repository_owner_from_clone_url(repository_clone_url)[source]

Given a repository clone URL, return the owner of the repository.

tool_shed.util.repository_util.get_repository_query(app)[source]
tool_shed.util.repository_util.get_role_by_id(app, role_id)[source]

Get a Role from the database by id.

tool_shed.util.repository_util.get_tool_shed_from_clone_url(repository_clone_url)[source]
tool_shed.util.repository_util.get_tool_shed_repository_by_id(app, repository_id) ToolShedRepository[source]

Return a tool shed repository database record defined by the id.

tool_shed.util.repository_util.get_tool_shed_status_for_installed_repository(app, repository: ToolShedRepository)[source]

Send a request to the tool shed to retrieve information about newer installable repository revisions, current revision updates, whether the repository revision is the latest downloadable revision, and whether the repository has been deprecated in the tool shed. The received repository is a ToolShedRepository object from Galaxy.

tool_shed.util.repository_util.handle_role_associations(app: ToolShedApp, role, repository, **kwd)[source]
tool_shed.util.repository_util.is_tool_shed_client(app)[source]

The tool shed and clients to the tool (i.e. Galaxy) require a lot of similar functionality in this file but with small differences. This method should determine if the app performing the action is the tool shed or a client of the tool shed.

tool_shed.util.repository_util.repository_was_previously_installed(app, tool_shed_url, repository_name, repo_info_tuple, from_tip=False)[source]

Find out if a repository is already installed into Galaxy - there are several scenarios where this is necessary. For example, this method will handle the case where the repository was previously installed using an older changeset_revsion, but later the repository was updated in the tool shed and now we’re trying to install the latest changeset revision of the same repository instead of updating the one that was previously installed. We’ll look in the database instead of on disk since the repository may be currently uninstalled.

tool_shed.util.repository_util.set_repository_attributes(app, repository, status, error_message, deleted, uninstalled, remove_from_disk=False)[source]
tool_shed.util.repository_util.update_repository(trans: ProvidesUserContext, id: str, **kwds) Tuple[Repository | None, str | None][source]

Update an existing ToolShed repository

tool_shed.util.repository_util.validate_repository_name(app: ToolShedApp, name, user)[source]

Validate whether the given name qualifies as a new TS repo name. Repository names must be unique for each user, must be at least two characters in length and must contain only lower-case letters, numbers, and the ‘_’ character.

tool_shed.util.review_util module

tool_shed.util.search_util module

tool_shed.util.search_util.in_tool_dict(tool_dict, exact_matches_checked, tool_id=None, tool_name=None, tool_version=None)[source]
tool_shed.util.search_util.make_same_length(list1, list2)[source]
tool_shed.util.search_util.search_ids_names(tool_dict, exact_matches_checked, match_tuples, repository_metadata, tool_ids, tool_names)[source]
tool_shed.util.search_util.search_ids_versions(tool_dict, exact_matches_checked, match_tuples, repository_metadata, tool_ids, tool_versions)[source]
tool_shed.util.search_util.search_names_versions(tool_dict, exact_matches_checked, match_tuples, repository_metadata, tool_names, tool_versions)[source]
tool_shed.util.search_util.search_repository_metadata(app, exact_matches_checked, tool_ids='', tool_names='', tool_versions='')[source]
tool_shed.util.search_util.get_metadata(session, repository_metadata_model, repository_model)[source]

tool_shed.util.shed_index module

tool_shed.util.shed_index.build_index(whoosh_index_dir, file_path, hgweb_config_dir, hgweb_repo_prefix, dburi, **kwargs)[source]

Build two search indexes simultaneously One is for repositories and the other for tools.

Returns a tuple with number of repos and tools that were indexed.

tool_shed.util.shed_index.get_repos(sa_session, file_path, hgweb_config_dir, hgweb_repo_prefix, **kwargs)[source]

Load repos from DB and included tools from .xml configs.

tool_shed.util.shed_index.debug_handler(path, exc_info)[source]

By default the underlying tool parsing logs warnings for each exception. This is very chatty hence this metod changes it to debug level.

tool_shed.util.shed_index.load_one_dir(path)[source]
tool_shed.util.shed_index.get_repositories_for_indexing(session)[source]
tool_shed.util.shed_index.get_repo_cat_associations(session, repository_id)[source]

tool_shed.util.shed_util_common module

tool_shed.util.shed_util_common.count_repositories_in_category(app: ToolShedApp, category_id: str) int[source]
tool_shed.util.shed_util_common.get_categories(app: ToolShedApp)[source]

Get all categories from the database.

tool_shed.util.shed_util_common.get_category(app: ToolShedApp, id: str)[source]

Get a category from the database.

tool_shed.util.shed_util_common.get_category_by_name(app: ToolShedApp, name: str)[source]

Get a category from the database via name.

tool_shed.util.shed_util_common.get_repository_file_contents(app: ToolShedApp, file_path: str, repository_id: str, is_admin: bool = False) str[source]

Return the display-safe contents of a repository file for display in a browser.

tool_shed.util.shed_util_common.get_user(app, id)[source]

Get a user from the database by id.

tool_shed.util.shed_util_common.handle_email_alerts(app: ToolShedApp, host: str, repository: Repository, content_alert_str: str = '', new_repo_alert: bool = False, admin_only: bool = False) None[source]

There are 2 complementary features that enable a tool shed user to receive email notification:

  1. Within User Preferences, they can elect to receive email when the first (or first valid) change set is produced for a new repository.

  2. When viewing or managing a repository, they can check the box labeled “Receive email alerts” which caused them to receive email alerts when updates to the repository occur. This same feature is available on a per-repository basis on the repository grid within the tool shed.

There are currently 4 scenarios for sending email notification when a change is made to a repository:

  1. An admin user elects to receive email when the first change set is produced for a new repository from User Preferences. The change set does not have to include any valid content. This allows for the capture of inappropriate content being uploaded to new repositories.

  2. A regular user elects to receive email when the first valid change set is produced for a new repository from User Preferences. This differs from 1 above in that the user will not receive email until a change set that includes valid content is produced.

  3. An admin user checks the “Receive email alerts” check box on the manage repository page. Since the user is an admin user, the email will include information about both HTML and image content that was included in the change set.

  4. A regular user checks the “Receive email alerts” check box on the manage repository page. Since the user is not an admin user, the email will not include any information about both HTML and image content that was included in the change set.

tool_shed.util.shed_util_common.is_path_within_dependency_dir(app: ToolShedApp, path: str) bool[source]

Detect whether the given path is within the tool_dependency_dir folder on the disk. (Specified by the config option). Use to filter malicious symlinks targeting outside paths.

tool_shed.util.shed_util_common.is_path_within_repo(app: ToolShedApp, path: str, repository_id: str) bool[source]

Detect whether the given path is within the repository folder on the disk. Use to filter malicious symlinks targeting outside paths.

tool_shed.util.shed_util_common.open_repository_files_folder(app: ToolShedApp, folder_path: str, repository_id: str, is_admin: bool = False) List[source]

Return a list of dictionaries, each of which contains information for a file or directory contained within a directory in a repository file hierarchy.

tool_shed.util.shed_util_common.tool_shed_is_this_tool_shed(toolshed_base_url, trans=None)[source]

Determine if a tool shed is the current tool shed.

tool_shed.util.tool_dependency_util module

tool_shed.util.tool_util module

tool_shed.util.tool_util.copy_sample_file(tool_data_path: str, filename: str, dest_path: str | None = None) str[source]

Copies a sample file at filename to the dest_path directory and strips the ‘.sample’ extensions from filename. Returns the path to the copied file (with the .sample extension).

tool_shed.util.tool_util.copy_sample_files(tool_data_path: str, sample_files, tool_path: str | None = None, sample_files_copied=None, dest_path: str | None = None) None[source]

Copy all appropriate files to dest_path in the local Galaxy environment that have not already been copied. Those that have been copied are contained in sample_files_copied. The default value for dest_path is ~/tool-data. We need to be careful to copy only appropriate files here because tool shed repositories can contain files ending in .sample that should not be copied to the ~/tool-data directory.

tool_shed.util.tool_util.generate_message_for_invalid_tools(app, invalid_file_tups: list, repository, metadata_dict: dict | None, as_html: bool = True, displaying_invalid_tool: bool = False) str[source]
tool_shed.util.tool_util.new_state(trans, tool, invalid=False)[source]

Create a new DefaultToolState for the received tool. Only inputs on the first page will be initialized.

tool_shed.util.web_util module

tool_shed.util.web_util.escape(string)[source]

A tool shed variant of markupsafe.escape that allows a select few HTML elements that are repeatedly used in messages created deep in the toolshed components. Ideally abstract things would be produced in these components and messages in the views or client side - this is what should be worked toward - but for now - we have this hack.

>>> assert escape(u"A <b>cómplǐcḁtëd strĩñg</b>") == u'A <b>cómplǐcḁtëd strĩñg</b>'

tool_shed.util.xml_util module

tool_shed.util.xml_util.create_and_write_tmp_file(elem: Element) str[source]
tool_shed.util.xml_util.parse_xml(file_name: str | PathLike, check_exists=True) Tuple[ElementTree | None, str][source]

Returns a parsed xml tree with comments intact.