Warning

This document is for an old release 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 galaxy.tool_util.toolbox.views.definitions

from enum import Enum
from typing import (
    Any,
    cast,
    List,
    Optional,
    Union,
)

from pydantic import (
    BaseModel,
    Field,
)
from typing_extensions import Literal


[docs]class StaticToolBoxViewTypeEnum(str, Enum): generic = "generic" activity = "activity" publication = "publication" training = "training"
[docs]class ExcludeTool(BaseModel): tool_id: str
[docs]class ExcludeToolRegex(BaseModel): tool_id_regex: str
[docs]class ExcludeTypes(BaseModel): types: List[str]
Exclusions = Union[ ExcludeTool, ExcludeToolRegex, ExcludeTypes, ] OptionalExclusionList = Optional[List[Exclusions]]
[docs]class Tool(BaseModel): content_type: Literal["tool"] = Field("tool", alias="type") id: str
[docs] class Config: allow_population_by_field_name = True
[docs]class Label(BaseModel): content_type: Literal["label"] = Field(alias="type") id: Optional[str] text: str
[docs] class Config: allow_population_by_field_name = True
[docs]class LabelShortcut(BaseModel): content_type = "simple_label" label: str
[docs]class Workflow(BaseModel): content_type: Literal["workflow"] = Field(alias="type") id: str
[docs] class Config: allow_population_by_field_name = True
[docs]class ItemsFrom(BaseModel): content_type = "items_from" items_from: str excludes: OptionalExclusionList
SectionContent = Union[ Tool, Label, LabelShortcut, Workflow, ItemsFrom, ]
[docs]class HasItems: items: Optional[List[Any]] @property def items_expanded(self) -> Optional[List["ExpandedRootContent"]]: if self.items is None: return None # replace SectionAliases with individual SectionAlias objects # replace LabelShortcuts with Labels items: List[ExpandedRootContent] = [] for item in self.items: item = cast(RootContent, item) if isinstance(item, SectionAliases): for section in item.sections: section_alias = SectionAlias( section=section, excludes=item.excludes, ) items.append(section_alias) elif isinstance(item, LabelShortcut): new_item = Label( id=None, text=item.label, content_type="label", ) items.append(new_item) else: items.append(item) return items
[docs]class Section(BaseModel, HasItems): content_type: Literal["section"] = Field(alias="type") id: Optional[str] name: Optional[str] items: Optional[List[SectionContent]] excludes: OptionalExclusionList
[docs] class Config: allow_population_by_field_name = True
[docs]class SectionAlias(BaseModel): content_type = "section_alias" section: str excludes: OptionalExclusionList
[docs]class SectionAliases(BaseModel): content_type = "section_aliases" sections: List[str] excludes: OptionalExclusionList
RootContent = Union[ Section, SectionAlias, SectionAliases, Tool, Label, LabelShortcut, Workflow, ItemsFrom, ] ExpandedRootContent = Union[ Section, SectionAlias, Tool, Label, Workflow, ItemsFrom, ]
[docs]class StaticToolBoxView(BaseModel, HasItems): id: str name: str description: Optional[str] view_type: StaticToolBoxViewTypeEnum = Field(alias="type") items: Optional[List[RootContent]] # if empty, use integrated tool panel excludes: OptionalExclusionList
[docs] @staticmethod def from_dict(as_dict): return StaticToolBoxView(**as_dict)
[docs] class Config: allow_population_by_field_name = True