def get_containing_tool_sections( self, tool_config ): """ If tool_config is defined somewhere in self.proprietary_tool_panel_elems, return True and a list of ToolSections in which the tool is displayed. If the tool is displayed outside of any sections, None is appended to the list. """ tool_sections = [] is_displayed = False for proprietary_tool_panel_elem in self.proprietary_tool_panel_elems: if proprietary_tool_panel_elem.tag == 'tool': # The proprietary_tool_panel_elem looks something like <tool file="emboss_5/emboss_antigenic.xml" />. proprietary_tool_config = proprietary_tool_panel_elem.get( 'file' ) if tool_config == proprietary_tool_config: # The tool is loaded outside of any sections. tool_sections.append( None ) if not is_displayed: is_displayed = True if proprietary_tool_panel_elem.tag == 'section': # The proprietary_tool_panel_elem looks something like <section name="EMBOSS" id="EMBOSSLite">. for section_elem in proprietary_tool_panel_elem: if section_elem.tag == 'tool': # The section_elem looks something like <tool file="emboss_5/emboss_antigenic.xml" />. proprietary_tool_config = section_elem.get( 'file' ) if tool_config == proprietary_tool_config: # The tool is loaded inside of the section_elem. tool_sections.append( ToolSection( proprietary_tool_panel_elem ) ) if not is_displayed: is_displayed = True return is_displayed, tool_sections
def test_tool_section(): elem = ET.Element('section') elem.attrib['name'] = "Cool Tools" elem.attrib['id'] = "cool1" section = ToolSection(elem) assert section.id == "cool1" assert section.name == "Cool Tools" assert section.version == "" section = ToolSection(dict(id="cool1", name="Cool Tools")) assert section.id == "cool1" assert section.name == "Cool Tools" assert section.version == "" section = ToolSection() assert section.id == "" assert section.name == "" assert section.version == ""