Move ToolSection and ToolSectionLabel out of galaxy.tools directly.

Would like to move the whole ToolBox out of galaxy.tools and into galaxy.tools.toolbox but need to separate all dependencies on galaxy.tools first.
This commit is contained in:
John Chilton
2014-12-31 18:21:10 -05:00
parent 68161e0857
commit aa86181e7c
8 changed files with 82 additions and 67 deletions
+2 -61
View File
@@ -53,6 +53,8 @@ from galaxy.tools.test import parse_tests
from galaxy.tools.parser import get_tool_source
from galaxy.tools.parser.xml import XmlPageSource
from galaxy.tools.toolbox import ToolPanelElements
from galaxy.tools.toolbox import ToolSection
from galaxy.tools.toolbox import ToolSectionLabel
from galaxy.tools.toolbox import tool_tag_manager
from galaxy.tools.toolbox.lineages import LineageMap
from galaxy.util import listify, parse_xml, rst_to_html, string_as_bool, string_to_object
@@ -1293,67 +1295,6 @@ def _filter_for_panel( item, filters, context ):
return None
class ToolSection( object, Dictifiable ):
"""
A group of tools with similar type/purpose that will be displayed as a
group in the user interface.
"""
dict_collection_visible_keys = ( 'id', 'name', 'version' )
def __init__( self, elem=None ):
""" Build a ToolSection from an ElementTree element or a dictionary.
"""
f = lambda elem, val: elem is not None and elem.get( val ) or ''
self.name = f( elem, 'name' )
self.id = f( elem, 'id' )
self.version = f( elem, 'version' )
self.elems = ToolPanelElements()
def copy( self ):
copy = ToolSection()
copy.name = self.name
copy.id = self.id
copy.version = self.version
copy.elems = self.elems.copy()
return copy
def to_dict( self, trans, link_details=False ):
""" Return a dict that includes section's attributes. """
section_dict = super( ToolSection, self ).to_dict()
section_elts = []
kwargs = dict(
trans=trans,
link_details=link_details
)
for elt in self.elems.values():
section_elts.append( elt.to_dict( **kwargs ) )
section_dict[ 'elems' ] = section_elts
return section_dict
class ToolSectionLabel( object, Dictifiable ):
"""
A label for a set of tools that can be displayed above groups of tools
and sections in the user interface
"""
dict_collection_visible_keys = ( 'id', 'text', 'version' )
def __init__( self, elem ):
""" Build a ToolSectionLabel from an ElementTree element or a
dictionary.
"""
self.text = elem.get( "text" )
self.id = elem.get( "id" )
self.version = elem.get( "version" ) or ''
def to_dict( self, **kwds ):
return super( ToolSectionLabel, self ).to_dict()
class DefaultToolState( object ):
"""
Keeps track of the state of a users interaction with a tool between
+3 -1
View File
@@ -3,6 +3,8 @@
from .tags import tool_tag_manager
from .panel import ToolPanelElements
from .panel import ToolSection
from .panel import ToolSectionLabel
__all__ = ["ToolPanelElements", "tool_tag_manager"]
__all__ = ["ToolPanelElements", "tool_tag_manager", "ToolSection", "ToolSectionLabel"]
+62
View File
@@ -1,4 +1,66 @@
from galaxy.util.odict import odict
from galaxy.model.item_attrs import Dictifiable
class ToolSection( object, Dictifiable ):
"""
A group of tools with similar type/purpose that will be displayed as a
group in the user interface.
"""
dict_collection_visible_keys = ( 'id', 'name', 'version' )
def __init__( self, elem=None ):
""" Build a ToolSection from an ElementTree element or a dictionary.
"""
f = lambda elem, val: elem is not None and elem.get( val ) or ''
self.name = f( elem, 'name' )
self.id = f( elem, 'id' )
self.version = f( elem, 'version' )
self.elems = ToolPanelElements()
def copy( self ):
copy = ToolSection()
copy.name = self.name
copy.id = self.id
copy.version = self.version
copy.elems = self.elems.copy()
return copy
def to_dict( self, trans, link_details=False ):
""" Return a dict that includes section's attributes. """
section_dict = super( ToolSection, self ).to_dict()
section_elts = []
kwargs = dict(
trans=trans,
link_details=link_details
)
for elt in self.elems.values():
section_elts.append( elt.to_dict( **kwargs ) )
section_dict[ 'elems' ] = section_elts
return section_dict
class ToolSectionLabel( object, Dictifiable ):
"""
A label for a set of tools that can be displayed above groups of tools
and sections in the user interface
"""
dict_collection_visible_keys = ( 'id', 'text', 'version' )
def __init__( self, elem ):
""" Build a ToolSectionLabel from an ElementTree element or a
dictionary.
"""
self.text = elem.get( "text" )
self.id = elem.get( "id" )
self.version = elem.get( "version" ) or ''
def to_dict( self, **kwds ):
return super( ToolSectionLabel, self ).to_dict()
class ToolPanelElements( odict ):
@@ -10,7 +10,7 @@ import threading
import logging
from galaxy import util
from galaxy.tools import ToolSection
from galaxy.tools.toolbox import ToolSection
from galaxy.util.odict import odict
from tool_shed.galaxy_install import install_manager
+4 -1
View File
@@ -1,6 +1,9 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
<% from galaxy.tools import Tool, ToolSection %>
<%
from galaxy.tools import Tool
from galaxy.tools.toolbox import ToolSection
%>
<script type="text/javascript">
$().ready(function() {
+4 -1
View File
@@ -1,6 +1,9 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
<% from galaxy.tools import Tool, ToolSection %>
<%
from galaxy.tools import Tool
from galaxy.tools.toolbox import ToolSection
%>
<script type="text/javascript">
$().ready(function() {
@@ -269,7 +269,10 @@
</%def>
<%def name="left_panel()">
<% from galaxy.tools import Tool, ToolSection, ToolSectionLabel %>
<%
from galaxy.tools import Tool
from galaxy.tools.toolbox import ToolSection, ToolSectionLabel
%>
<div class="unified-panel-header" unselectable="on">
<div class='unified-panel-header-inner'>
+2 -1
View File
@@ -1,5 +1,6 @@
from xml.etree import ElementTree as ET
from galaxy.tools import ToolSection
from galaxy.tools.toolbox import ToolSection
def test_tool_section( ):