commit/galaxy-central: 2 new changesets
2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/fe54618dbd31/ changeset: fe54618dbd31 user: jgoecks date: 2012-04-09 21:58:25 summary: Tool menu changes: (a) enable Toolbox to be directly dictified; and (b) enable Toolbox to return only tools compatible with Trackster. affected #: 3 files diff -r 7274516136812ee0a84aa69f420348848d1b5b08 -r fe54618dbd317fc1c8e9d8fd2f1650717878eade lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -487,18 +487,106 @@ Returns a SQLAlchemy session """ return self.app.model.context + + def to_dict( self, trans, in_panel=True, trackster=False ): + + def filter_for_trackster( item ): + """ + Filters tool panel elements so that only those that are compatible + with Trackster are kept. + """ + + if isinstance( item, Tool ): + # If tool has a trackster config, it can be used in Trackster. + if tool.trackster_conf: + return item + elif isinstance( item, ToolSectionLabel ): + # Tool label cannot be directly filtered. + return item + elif isinstance( item, ToolSection ): + # Filter section item-by-item. Only show a label if there are + # trackster-compatible tools below it. + cur_label_key = None + tools_under_label = False + filtered_elems = item.elems.copy() + for key, section_item in item.elems.items(): + if isinstance( section_item, Tool ): + # Filter tool. + if section_item.trackster_conf: + tools_under_label = True + else: + del filtered_elems[ key ] + elif isinstance( section_item, ToolSectionLabel ): + # If there is a label and it does not have tools, + # remove it. + if cur_label_key and not tools_under_label: + del filtered_elems[ cur_label_key ] + + # Reset attributes for new label. + cur_label_key = key + tools_under_label = False + + + # Handle last label. + if cur_label_key and not tools_under_label: + del filtered_elems[ cur_label_key ] + + # Only return section if there are elements. + if len( filtered_elems ) != 0: + copy = item.copy() + copy.elems = filtered_elems + return copy + + return None + + # + # Dictify toolbox. + # + + if in_panel: + panel_elts = [ val for val in self.tool_panel.itervalues() ] + + # Filter if necessary. + if trackster: + filtered_panel_elts = [] + for index, elt in enumerate( panel_elts ): + elt = filter_for_trackster( elt ) + if elt: + filtered_panel_elts.append( elt ) + panel_elts = filtered_panel_elts + + # Produce panel. + rval = [] + for elt in panel_elts: + rval.append( elt.to_dict( trans ) ) + else: + tools = [] + for id, tool in self.app.toolbox.tools_by_id.items(): + tools.append( tool.to_dict( trans ) ) + rval = tools + + return rval class ToolSection( object ): """ A group of tools with similar type/purpose that will be displayed as a group in the user interface. """ - def __init__( self, elem ): - self.name = elem.get( "name" ) - self.id = elem.get( "id" ) - self.version = elem.get( "version" ) or '' + def __init__( self, elem=None ): + 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 = odict() + 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 ): """ Return a dict that includes section's attributes. """ section_elts = [] @@ -880,7 +968,7 @@ self.is_workflow_compatible = self.check_workflow_compatible() # Trackster configuration. trackster_conf = root.find( "trackster_conf" ) - if trackster_conf: + if trackster_conf is not None: self.trackster_conf = TracksterConfig.parse( trackster_conf ) else: self.trackster_conf = None diff -r 7274516136812ee0a84aa69f420348848d1b5b08 -r fe54618dbd317fc1c8e9d8fd2f1650717878eade lib/galaxy/web/controllers/tools.py --- a/lib/galaxy/web/controllers/tools.py +++ b/lib/galaxy/web/controllers/tools.py @@ -14,18 +14,13 @@ GET /api/tools: returns a list of tools defined by parameters parameters: in_panel - if true, tools are returned in panel structure, including sections and labels + trackster - if true, only tools that are compatible with Trackster are returned """ + + # Read params. in_panel = util.string_as_bool( kwds.get( 'in_panel', 'True' ) ) - if in_panel: - panel_elts = [] - for key, val in self.app.toolbox.tool_panel.items(): - panel_elts.append( val.to_dict( trans ) ) - rval = panel_elts - else: - tools = [] - for id, tool in self.app.toolbox.tools_by_id.items(): - tools.append( tool.to_dict( trans ) ) - rval = tools - - return rval + trackster = util.string_as_bool( kwds.get( 'trackster', 'False' ) ) + + # Create return value. + return self.app.toolbox.to_dict( trans, in_panel=in_panel, trackster=trackster ) \ No newline at end of file diff -r 7274516136812ee0a84aa69f420348848d1b5b08 -r fe54618dbd317fc1c8e9d8fd2f1650717878eade templates/root/tool_menu.mako --- a/templates/root/tool_menu.mako +++ b/templates/root/tool_menu.mako @@ -25,9 +25,7 @@ if trans.user and trans.user.preferences.get( "show_tool_search", "False" ) == "False": tool_search_hidden = "true" - dictified_panel = [] - for key, val in trans.app.toolbox.tool_panel.items(): - dictified_panel.append( val.to_dict( trans ) ) + dictified_panel = trans.app.toolbox.to_dict( trans ) %><script type="text/javascript"> https://bitbucket.org/galaxy/galaxy-central/changeset/507135da0b2c/ changeset: 507135da0b2c user: jgoecks date: 2012-04-09 21:59:45 summary: Merge affected #: 1 file diff -r fe54618dbd317fc1c8e9d8fd2f1650717878eade -r 507135da0b2c15ddbb05759c5d38a0ed0f429d0a lib/galaxy/datatypes/registry.py --- a/lib/galaxy/datatypes/registry.py +++ b/lib/galaxy/datatypes/registry.py @@ -141,7 +141,7 @@ if hasattr( imported_module, datatype_class_name ): datatype_class = getattr( imported_module, datatype_class_name ) except Exception, e: - full_path = os.path.join( full_path, proprietary_datatype_module ) + full_path = os.path.join( proprietary_path, proprietary_datatype_module ) self.log.debug( "Exception importing proprietary code file %s: %s" % ( str( full_path ), str( e ) ) ) finally: lock.release() Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket