commit/galaxy-central: greg: Slight refactoring of message generation in the tool shed.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/595c30bc8df5/ Changeset: 595c30bc8df5 User: greg Date: 2013-09-10 20:19:46 Summary: Slight refactoring of message generation in the tool shed. Affected #: 5 files diff -r 04a3137539d245fa294f73f8b6467a5b13e6d028 -r 595c30bc8df5dfd626d78cc4e030ac1910b54f4e lib/galaxy/webapps/tool_shed/controllers/repository.py --- a/lib/galaxy/webapps/tool_shed/controllers/repository.py +++ b/lib/galaxy/webapps/tool_shed/controllers/repository.py @@ -2159,11 +2159,17 @@ all_repository_dependencies=None, handled_key_rd_dicts=None ) if str( repository.type ) != rt_util.TOOL_DEPENDENCY_DEFINITION: - # Handle messaging for orphan tool dependencies. - orphan_message = tool_dependency_util.generate_message_for_orphan_tool_dependencies( trans, repository, metadata ) - if orphan_message: - message += orphan_message + # Handle messaging for resetting repository type to the optimal value. + change_repository_type_message = tool_dependency_util.generate_message_for_repository_type_change( trans, repository ) + if change_repository_type_message: + message += change_repository_type_message status = 'warning' + else: + # Handle messaging for orphan tool dependency definitions. + orphan_message = tool_dependency_util.generate_message_for_orphan_tool_dependencies( trans, repository, metadata ) + if orphan_message: + message += orphan_message + status = 'warning' if is_malicious: if trans.app.security_agent.can_push( trans.app, trans.user, repository ): message += malicious_error_can_push diff -r 04a3137539d245fa294f73f8b6467a5b13e6d028 -r 595c30bc8df5dfd626d78cc4e030ac1910b54f4e lib/galaxy/webapps/tool_shed/controllers/upload.py --- a/lib/galaxy/webapps/tool_shed/controllers/upload.py +++ b/lib/galaxy/webapps/tool_shed/controllers/upload.py @@ -207,15 +207,20 @@ else: metadata_dict = {} if str( repository.type ) != rt_util.TOOL_DEPENDENCY_DEFINITION: - # Provide a warning message if a tool_dependencies.xml file is provided, but tool dependencies weren't loaded due to a requirement tag mismatch - # or some other problem. Tool dependency definitions can define orphan tool dependencies (no relationship to any tools contained in the repository), - # so warning messages are important because orphans are always valid. The repository owner must be warned in case they did not intend to define an - # orphan dependency, but simply provided incorrect information (tool shed, name owner, changeset_revision) for the definition. - # Handle messaging for orphan tool dependencies. - orphan_message = tool_dependency_util.generate_message_for_orphan_tool_dependencies( trans, repository, metadata_dict ) - if orphan_message: - message += orphan_message + change_repository_type_message = tool_dependency_util.generate_message_for_repository_type_change( trans, repository ) + if change_repository_type_message: + message += change_repository_type_message status = 'warning' + else: + # Provide a warning message if a tool_dependencies.xml file is provided, but tool dependencies weren't loaded due to a requirement tag mismatch + # or some other problem. Tool dependency definitions can define orphan tool dependencies (no relationship to any tools contained in the repository), + # so warning messages are important because orphans are always valid. The repository owner must be warned in case they did not intend to define an + # orphan dependency, but simply provided incorrect information (tool shed, name owner, changeset_revision) for the definition. + # Handle messaging for orphan tool dependencies. + orphan_message = tool_dependency_util.generate_message_for_orphan_tool_dependencies( trans, repository, metadata_dict ) + if orphan_message: + message += orphan_message + status = 'warning' # Handle messaging for invalid tool dependencies. invalid_tool_dependencies_message = tool_dependency_util.generate_message_for_invalid_tool_dependencies( metadata_dict ) if invalid_tool_dependencies_message: diff -r 04a3137539d245fa294f73f8b6467a5b13e6d028 -r 595c30bc8df5dfd626d78cc4e030ac1910b54f4e lib/tool_shed/util/metadata_util.py --- a/lib/tool_shed/util/metadata_util.py +++ b/lib/tool_shed/util/metadata_util.py @@ -906,13 +906,13 @@ repository_dependency_tups=invalid_repository_dependency_tups, is_valid=False, description=description ) - # We need to continue to restrict the behavior of orphan tool dependencies, possibly eliminating them altoghether at some point. + # We need to continue to restrict the behavior for defining orphan tool dependencies, possibly eliminating them altoghether at some point. check_for_orphan_tool_dependencies = False if app.name == 'tool_shed': - if repository.type == rt_util.UNRESTRICTED and 'tools' not in metadata_dict: + if repository.type != rt_util.TOOL_DEPENDENCY_DEFINITION and not repository.can_change_type_to( app, rt_util.TOOL_DEPENDENCY_DEFINITION ): check_for_orphan_tool_dependencies = True - elif 'tools' in metadata_dict: - check_for_orphan_tool_dependencies = True + elif 'tools' in metadata_dict: + check_for_orphan_tool_dependencies = True if check_for_orphan_tool_dependencies: # Determine and store orphan tool dependencies. orphan_tool_dependencies = get_orphan_tool_dependencies( metadata_dict ) diff -r 04a3137539d245fa294f73f8b6467a5b13e6d028 -r 595c30bc8df5dfd626d78cc4e030ac1910b54f4e lib/tool_shed/util/tool_dependency_util.py --- a/lib/tool_shed/util/tool_dependency_util.py +++ b/lib/tool_shed/util/tool_dependency_util.py @@ -150,14 +150,17 @@ version = requirements_dict[ 'version' ] message += "<b>* name:</b> %s, <b>type:</b> %s, <b>version:</b> %s<br/>" % ( str( name ), str( type ), str( version ) ) message += "<br/>" - elif repository.can_change_type_to( trans.app, rt_util.TOOL_DEPENDENCY_DEFINITION ): - tool_dependency_definition_type_class = trans.app.repository_types_registry.get_class_by_label( rt_util.TOOL_DEPENDENCY_DEFINITION ) - message += "This repository currently contains a single file named <b>%s</b>. If additional files will " % suc.TOOL_DEPENDENCY_DEFINITION_FILENAME - message += "not be added to this repository, then it's type should be set to <b>%s</b>.<br/>" % tool_dependency_definition_type_class.label - else: - message += "This repository contains no tools, so it's defined tool dependencies are considered orphans within this repository.<br/>" return message +def generate_message_for_repository_type_change( trans, repository ): + message = '' + if repository.can_change_type_to( trans.app, rt_util.TOOL_DEPENDENCY_DEFINITION ): + tool_dependency_definition_type_class = trans.app.repository_types_registry.get_class_by_label( rt_util.TOOL_DEPENDENCY_DEFINITION ) + message += "This repository currently contains a single file named <b>%s</b>. If additional files will " % suc.TOOL_DEPENDENCY_DEFINITION_FILENAME + message += "not be added to this repository, then it's type should be set to <b>%s</b>.<br/>" % tool_dependency_definition_type_class.label + return message + + def get_download_url_for_platform( url_templates, platform_info_dict ): ''' Compare the dict returned by get_platform_info() with the values specified in the url_template element. Return diff -r 04a3137539d245fa294f73f8b6467a5b13e6d028 -r 595c30bc8df5dfd626d78cc4e030ac1910b54f4e test/tool_shed/functional/test_0100_complex_repository_dependencies.py --- a/test/tool_shed/functional/test_0100_complex_repository_dependencies.py +++ b/test/tool_shed/functional/test_0100_complex_repository_dependencies.py @@ -54,7 +54,7 @@ strings_displayed=[ 'This repository currently contains a single file named <b>tool_dependencies.xml</b>' ], strings_not_displayed=[] ) # Visit the manage repository page for package_bwa_0_5_9_0100. - self.display_manage_repository_page( repository, strings_displayed=[ 'Tool dependencies', 'may not be', 'in this repository' ] ) + self.display_manage_repository_page( repository, strings_displayed=[ 'Tool dependencies', 'will not be', 'to this repository' ] ) def test_0010_create_bwa_base_repository( self ): '''Create and populate bwa_base_0100.''' 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)
-
commits-noreply@bitbucket.org