2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/7f7da7248d4d/ Changeset: 7f7da7248d4d Branch: stable User: greg Date: 2014-02-26 21:09:43 Summary: Fixes for handling complex repository dependency definitions in tool dependency recipes. Affected #: 2 files diff -r 66aa6798e55303abc40fbb585c75e8c77638cca3 -r 7f7da7248d4de5d9f039639db77721d0b22fa6c5 lib/tool_shed/util/commit_util.py --- a/lib/tool_shed/util/commit_util.py +++ b/lib/tool_shed/util/commit_util.py @@ -274,7 +274,11 @@ return False, None, error_message def handle_repository_dependency_elem( trans, elem, unpopulate=False ): + """Populate or unpopulate repository tags.""" # <repository name="molecule_datatypes" owner="test" changeset_revision="1a070566e9c6" /> + # <repository changeset_revision="xxx" name="package_xorg_macros_1_17_1" owner="test" toolshed="yyy"> + # <package name="xorg_macros" version="1.17.1" /> + # </repository> error_message = '' name = elem.get( 'name' ) owner = elem.get( 'owner' ) @@ -285,6 +289,23 @@ revised = False toolshed = elem.get( 'toolshed' ) changeset_revision = elem.get( 'changeset_revision' ) + sub_elems = elem.findall( './/' ) + if sub_elems: + # At this point, a <repository> tag will point only to a package. + # <package name="xorg_macros" version="1.17.1" /> + # Coerce the list to an odict(). + sub_elements = odict() + packages = [] + for sub_elem in sub_elems: + sub_elem_type = sub_elem.tag + sub_elem_name = sub_elem.get( 'name' ) + sub_elem_version = sub_elem.get( 'version' ) + if sub_elem_type and sub_elem_name and sub_elem_version: + packages.append( ( sub_elem_name, sub_elem_version ) ) + sub_elements[ 'packages' ] = packages + else: + # Set to None. + sub_elements = None if unpopulate: # We're exporting the repository, so eliminate all toolshed and changeset_revision attributes from the <repository> tag. if toolshed or changeset_revision: @@ -292,7 +313,7 @@ attributes[ 'name' ] = name attributes[ 'owner' ] = owner attributes[ 'prior_installation_required' ] = elem.get( 'prior_installation_required', 'False' ) - elem = xml_util.create_element( 'repository', attributes=attributes, sub_elements=None ) + elem = xml_util.create_element( 'repository', attributes=attributes, sub_elements=sub_elements ) revised = True return revised, elem, error_message # From here on we're populating the toolshed and changeset_revisions if necessary. @@ -321,10 +342,12 @@ return revised, elem, error_message def handle_repository_dependency_sub_elem( trans, package_altered, altered, actions_elem, action_index, action_elem, unpopulate=False ): - # This method populates the toolshed and changeset_revision attributes for each of the following. - # <action type="set_environment_for_install"> - # <action type="setup_r_environment"> - # <action type="setup_ruby_environment"> + """ + Populate or unpopulate the toolshed and changeset_revision attributes for each of the following tag sets. + <action type="set_environment_for_install"> + <action type="setup_r_environment"> + <action type="setup_ruby_environment"> + """ error_message = '' for repo_index, repo_elem in enumerate( action_elem ): # Make sure to skip comments and tags that are not <repository>. @@ -343,7 +366,8 @@ def handle_tool_dependencies_definition( trans, tool_dependencies_config, unpopulate=False ): """ - Populate or unpopulate the tooshed and changeset_revision attributes of each <repository> tag defined within a tool_dependencies.xml file. + Populate or unpopulate the tooshed and changeset_revision attributes of each <repository> + tag defined within a tool_dependencies.xml file. """ altered = False error_message = '' diff -r 66aa6798e55303abc40fbb585c75e8c77638cca3 -r 7f7da7248d4de5d9f039639db77721d0b22fa6c5 lib/tool_shed/util/xml_util.py --- a/lib/tool_shed/util/xml_util.py +++ b/lib/tool_shed/util/xml_util.py @@ -47,7 +47,7 @@ def create_element( tag, attributes=None, sub_elements=None ): """ Create a new element whose tag is the value of the received tag, and whose attributes are all - key / value pairs in the received the attributes and sub_elements. + key / value pairs in the received attributes and sub_elements. """ if tag: elem = XmlET.Element( tag ) @@ -56,14 +56,22 @@ for k, v in attributes.items(): elem.set( k, v ) if sub_elements: - # The received attributes is an odict as well. These handle information that tends to be + # The received attributes is an odict. These handle information that tends to be # long text including paragraphs (e.g., description and long_description. for k, v in sub_elements.items(): # Don't include fields that are blank. if v: - sub_elem = XmlET.SubElement( elem, k ) - if isinstance( v, list ): - # If the sub_elem is a list, then it must be a list of tuples where the first + if k == 'packages': + # The received sub_elements is an odict whose key is 'packages' and whose + # value is a list of ( name, version ) tuples. + for v_tuple in v: + sub_elem = XmlET.SubElement( elem, 'package' ) + sub_elem_name, sub_elem_version = v_tuple + sub_elem.set( 'name', sub_elem_name ) + sub_elem.set( 'version', sub_elem_version ) + elif isinstance( v, list ): + sub_elem = XmlET.SubElement( elem, k ) + # If v is a list, then it must be a list of tuples where the first # item is the tag and the second item is the text value. for v_tuple in v: if len( v_tuple ) == 2: @@ -74,6 +82,7 @@ v_elem = XmlET.SubElement( sub_elem, v_tag ) v_elem.text = v_text else: + sub_elem = XmlET.SubElement( elem, k ) sub_elem.text = v return elem return None https://bitbucket.org/galaxy/galaxy-central/commits/ce7e90f9576b/ Changeset: ce7e90f9576b User: davebgx Date: 2014-02-26 21:11:47 Summary: Merge stable. Affected #: 0 files 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.