예제 #1
0
 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')
             proprietary_name = suc.strip_path(proprietary_tool_config)
             if tool_config == proprietary_name:
                 # 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')
                     proprietary_name = suc.strip_path(
                         proprietary_tool_config)
                     if tool_config == proprietary_name:
                         # 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
예제 #2
0
 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' )
             proprietary_name = suc.strip_path( proprietary_tool_config )
             if tool_config == proprietary_name:
                 # 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' )
                     proprietary_name = suc.strip_path( proprietary_tool_config )
                     if tool_config == proprietary_name:
                         # 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
예제 #3
0
 def get_proprietary_tool_panel_elems(self,
                                      latest_tool_migration_script_number):
     # Parse each config in self.proprietary_tool_confs (the default is tool_conf.xml) and generate a list of Elements that are
     # either ToolSection elements or Tool elements.  These will be used to generate new entries in the migrated_tools_conf.xml
     # file for the installed tools.
     tools_xml_file_path = os.path.abspath(
         os.path.join(
             'scripts', 'migrate_tools',
             '%04d_tools.xml' % latest_tool_migration_script_number))
     # Parse the XML and load the file attributes for later checking against the integrated elements from self.proprietary_tool_confs.
     migrated_tool_configs = []
     tree = util.parse_xml(tools_xml_file_path)
     root = tree.getroot()
     for elem in root:
         if elem.tag == 'repository':
             for tool_elem in elem:
                 migrated_tool_configs.append(tool_elem.get('file'))
     # Parse each file in self.proprietary_tool_confs and generate the integrated list of tool panel Elements that contain them.
     tool_panel_elems = []
     for proprietary_tool_conf in self.proprietary_tool_confs:
         tree = util.parse_xml(proprietary_tool_conf)
         root = tree.getroot()
         for elem in root:
             if elem.tag == 'tool':
                 # Tools outside of sections.
                 file_path = elem.get('file', None)
                 if file_path:
                     name = suc.strip_path(file_path)
                     if name in migrated_tool_configs:
                         if elem not in tool_panel_elems:
                             tool_panel_elems.append(elem)
             elif elem.tag == 'section':
                 # Tools contained in a section.
                 for section_elem in elem:
                     if section_elem.tag == 'tool':
                         file_path = section_elem.get('file', None)
                         if file_path:
                             name = suc.strip_path(file_path)
                             if name in migrated_tool_configs:
                                 # Append the section, not the tool.
                                 if elem not in tool_panel_elems:
                                     tool_panel_elems.append(elem)
     return tool_panel_elems
예제 #4
0
 def get_proprietary_tool_panel_elems( self, latest_tool_migration_script_number ):
     # Parse each config in self.proprietary_tool_confs (the default is tool_conf.xml) and generate a list of Elements that are
     # either ToolSection elements or Tool elements.  These will be used to generate new entries in the migrated_tools_conf.xml
     # file for the installed tools.
     tools_xml_file_path = os.path.abspath( os.path.join( 'scripts', 'migrate_tools', '%04d_tools.xml' % latest_tool_migration_script_number ) )
     # Parse the XML and load the file attributes for later checking against the integrated elements from self.proprietary_tool_confs.
     migrated_tool_configs = []
     tree = util.parse_xml( tools_xml_file_path )
     root = tree.getroot()
     for elem in root:
         if elem.tag == 'repository':
             for tool_elem in elem:
                 migrated_tool_configs.append( tool_elem.get( 'file' ) )
     # Parse each file in self.proprietary_tool_confs and generate the integrated list of tool panel Elements that contain them.
     tool_panel_elems = []
     for proprietary_tool_conf in self.proprietary_tool_confs:
         tree = util.parse_xml( proprietary_tool_conf )
         root = tree.getroot()
         for elem in root:
             if elem.tag == 'tool':
                 # Tools outside of sections.
                 file_path = elem.get( 'file', None )
                 if file_path:
                     name = suc.strip_path( file_path )
                     if name in migrated_tool_configs:
                         if elem not in tool_panel_elems:
                             tool_panel_elems.append( elem )
             elif elem.tag == 'section':
                 # Tools contained in a section.
                 for section_elem in elem:
                     if section_elem.tag == 'tool':
                         file_path = section_elem.get( 'file', None )
                         if file_path:
                             name = suc.strip_path( file_path )
                             if name in migrated_tool_configs:
                                 # Append the section, not the tool.
                                 if elem not in tool_panel_elems:
                                     tool_panel_elems.append( elem )
     return tool_panel_elems