commit/galaxy-central: greg: A few fixes for retriveingdictionary entries and a few enhancements to the tool shed containers.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/9cf72c86ee4f/ changeset: 9cf72c86ee4f user: greg date: 2012-12-06 00:14:10 summary: A few fixes for retriveingdictionary entries and a few enhancements to the tool shed containers. affected #: 3 files diff -r 75a97c971d36599955f67384b6f36ca73a80dd2e -r 9cf72c86ee4f37c9035cdc30912b4f33a0f6b3bb lib/galaxy/util/shed_util_common.py --- a/lib/galaxy/util/shed_util_common.py +++ b/lib/galaxy/util/shed_util_common.py @@ -819,7 +819,6 @@ """Generate a repository dependencies dictionary based on valid information defined in the received repository_dependencies_config.""" repository_dependencies_tups = [] error_message = '' - config_file_name = strip_path( repository_dependencies_config ) try: # Make sure we're looking at a valid repository_dependencies.xml file. tree = util.parse_xml( repository_dependencies_config ) @@ -838,15 +837,13 @@ changeset_revision = repository_elem.attrib[ 'changeset_revision' ] user = None repository = None - # Repository dependencies are currentlhy supported only within a single tool shed. if tool_shed_is_this_tool_shed( toolshed ): try: user = sa_session.query( app.model.User ) \ .filter( app.model.User.table.c.username == owner ) \ .one() except Exception, e: - error_message = "Invalid owner %s defined for repository %s in config file %s. " % ( owner, name, config_file_name ) - error_message += "Repository dependencies will be ignored." + error_message = "Invalid owner %s defined for repository %s. Repository dependencies will be ignored." % ( owner, name ) log.debug( error_message ) return metadata_dict, error_message if user: @@ -856,8 +853,7 @@ app.model.Repository.table.c.user_id == user.id ) ) \ .first() except: - error_message = "Invalid name %s or owner %s defined for repository in config file %s. " % ( name, owner, config_file_name ) - error_message += "Repository dependencies will be ignored." + error_message = "Invalid name %s or owner %s defined for repository. Repository dependencies will be ignored." % ( name, owner ) log.debug( error_message ) return metadata_dict, error_message if repository: @@ -865,16 +861,19 @@ if repository_dependencies_tup not in repository_dependencies_tups: repository_dependencies_tups.append( repository_dependencies_tup ) else: - error_message = "Invalid name %s or owner %s defined for repository in config file %s. " % ( name, owner, config_file_name ) - error_message += "Repository dependencies will be ignored." + error_message = "Invalid name %s or owner %s defined for repository. Repository dependencies will be ignored." % ( name, owner ) log.debug( error_message ) return metadata_dict, error_message else: - # We have an invalid repository owner defined for an entry in repository_dependencies.xml. - config_file_name = strip_path( repository_dependencies_config ) - error_message = "Invalid username %s defined for owner of repository %s in config file %s. Repository dependencies will be ignored." % ( owner, name, config_file_name ) + error_message = "Invalid owner %s defined for owner of repository %s. Repository dependencies will be ignored." % ( owner, name ) log.debug( error_message ) - return metadata_dict, error_message + return metadata_dict, error_message + else: + # Repository dependencies are currentlhy supported within a single tool shed. + error_message = "Invalid tool shed %s defined for repository %s. " % ( toolshed, name ) + error_message += "Repository dependencies are currently supported within a single tool shed, so your definition will be ignored." + log.debug( error_message ) + return metadata_dict, error_message if repository_dependencies_tups: repository_dependencies_dict = dict( description=root.get( 'description' ), repository_dependencies=repository_dependencies_tups ) diff -r 75a97c971d36599955f67384b6f36ca73a80dd2e -r 9cf72c86ee4f37c9035cdc30912b4f33a0f6b3bb lib/galaxy/webapps/community/util/container_util.py --- a/lib/galaxy/webapps/community/util/container_util.py +++ b/lib/galaxy/webapps/community/util/container_util.py @@ -7,10 +7,11 @@ class Folder( object ): """Container object.""" - def __init__( self, id=None, key=None, label=None ): + def __init__( self, id=None, key=None, label=None, parent=None ): self.id = id self.key = key self.label = label + self.parent = parent self.description = None self.datatypes = [] self.folders = [] @@ -25,8 +26,18 @@ if folder == contained_folder: return index, contained_folder return 0, None + def contains_repository_dependency( self, repository_dependency ): + listified_repository_dependency = repository_dependency.listify + for contained_repository_dependency in self.repository_dependencies: + if contained_repository_dependency.listify == listified_repository_dependency: + return True + return False def remove_repository_dependency( self, repository_dependency ): - self.repository_dependencies.remove( repository_dependency ) + listified_repository_dependency = repository_dependency.listify + for contained_repository_dependency in self.repository_dependencies: + if contained_repository_dependency.listify == listified_repository_dependency: + self.repository_dependencies.remove( contained_repository_dependency ) + class Datatype( object ): """Datatype object""" def __init__( self, id=None, extension=None, type=None, mimetype=None, subclass=None ): @@ -102,9 +113,9 @@ if datatypes: datatype_id = 0 folder_id += 1 - datatypes_root_folder = Folder( id=folder_id, key='root', label='root' ) + datatypes_root_folder = Folder( id=folder_id, key='root', label='root', parent=None ) folder_id += 1 - folder = Folder( id=folder_id, key='datatypes', label=label ) + folder = Folder( id=folder_id, key='datatypes', label=label, parent=datatypes_root_folder ) datatypes_root_folder.folders.append( folder ) # Insert a header row. datatype_id += 1 @@ -131,9 +142,9 @@ if invalid_tool_configs: invalid_tool_id = 0 folder_id += 1 - invalid_tools_root_folder = Folder( id=folder_id, key='root', label='root' ) + invalid_tools_root_folder = Folder( id=folder_id, key='root', label='root', parent=None ) folder_id += 1 - folder = Folder( id=folder_id, key='invalid_tools', label=label ) + folder = Folder( id=folder_id, key='invalid_tools', label=label, parent=invalid_tools_root_folder ) invalid_tools_root_folder.folders.append( folder ) for invalid_tool_config in invalid_tool_configs: invalid_tool_id += 1 @@ -155,24 +166,22 @@ multiple_readme_files = len( readme_files_dict ) > 1 readme_id = 0 folder_id += 1 - readme_files_root_folder = Folder( id=folder_id, key='root', label='root' ) + readme_files_root_folder = Folder( id=folder_id, key='root', label='root', parent=None ) if multiple_readme_files: folder_id += 1 - readme_files_folder = Folder( id=folder_id, key='readme_files', label=label ) + readme_files_folder = Folder( id=folder_id, key='readme_files', label=label, parent=readme_files_root_folder ) readme_files_root_folder.folders.append( readme_files_folder ) for readme_file_name, readme_file_text in readme_files_dict.items(): readme_id += 1 - readme = ReadMe( id=readme_id, - name=readme_file_name, - text=readme_file_text ) + readme = ReadMe( id=readme_id, name=readme_file_name, text=readme_file_text ) if multiple_readme_files: folder_id += 1 - folder = Folder( id=folder_id, key=readme.name, label=readme.name ) + folder = Folder( id=folder_id, key=readme.name, label=readme.name, parent=readme_files_folder ) folder.readme_files.append( readme ) readme_files_folder.folders.append( folder ) else: folder_id += 1 - readme_files_folder = Folder( id=folder_id, key='readme_files', label=readme.name ) + readme_files_folder = Folder( id=folder_id, key='readme_files', label=readme.name, parent=readme_files_root_folder ) readme_files_folder.readme_files.append( readme ) readme_files_root_folder.folders.append( readme_files_folder ) else: @@ -185,11 +194,11 @@ repository_dependency_id = 0 folder_id += 1 # Create the root folder. - repository_dependencies_root_folder = Folder( id=folder_id, key='root', label='root' ) + repository_dependencies_root_folder = Folder( id=folder_id, key='root', label='root', parent=None ) folder_id += 1 # Create the Repository dependencies folder and add it to the root folder. repository_dependencies_folder_key = repository_dependencies[ 'root_key' ] - repository_dependencies_folder = Folder( id=folder_id, key=repository_dependencies_folder_key, label=label ) + repository_dependencies_folder = Folder( id=folder_id, key=repository_dependencies_folder_key, label=label, parent=repository_dependencies_root_folder ) # The received repository_dependencies is a dictionary with a single 'description' key, and one or more repository_dependency keys. # We want the description value associated with the repository_dependencies_folder. repository_dependencies_folder.description = repository_dependencies.get( 'description', None ) @@ -203,7 +212,7 @@ # Create a new folder. folder_id += 1 label = generate_repository_dependencies_folder_label_from_key( repository_name, repository_owner, changeset_revision, key ) - folder = Folder( id=folder_id, key=key, label=label ) + folder = Folder( id=folder_id, key=key, label=label, parent=repository_dependencies_folder ) for repository_dependency_tup in val: toolshed, name, owner, changeset_revision = repository_dependency_tup # Create a new repository_dependency. @@ -218,8 +227,8 @@ if not get_folder( repository_dependencies_folder, key ): # Insert the folder into the list. repository_dependencies_folder.folders.append( folder ) - # Remove repository_dependencies that are also folders. - remove_unwanted_repository_dependencies( repository_dependencies_folder ) + # Remove repository_dependencies that are also folders, and coerce empty folders into repository dependencies. + prune_repository_dependencies( repository_dependencies_folder, repository_dependencies_folder ) else: repository_dependencies_root_folder = None return folder_id, repository_dependencies_root_folder @@ -228,9 +237,9 @@ if tool_dicts: tool_id = 0 folder_id += 1 - tools_root_folder = Folder( id=folder_id, key='root', label='root' ) + tools_root_folder = Folder( id=folder_id, key='root', label='root', parent=None ) folder_id += 1 - folder = Folder( id=folder_id, key='tools', label=label ) + folder = Folder( id=folder_id, key='tools', label=label, parent=tools_root_folder ) tools_root_folder.folders.append( folder ) # Insert a header row. tool_id += 1 @@ -272,9 +281,9 @@ if tool_dependencies: tool_dependency_id = 0 folder_id += 1 - tool_dependencies_root_folder = Folder( id=folder_id, key='root', label='root' ) + tool_dependencies_root_folder = Folder( id=folder_id, key='root', label='root', parent=None ) folder_id += 1 - folder = Folder( id=folder_id, key='tool_dependencies', label=label ) + folder = Folder( id=folder_id, key='tool_dependencies', label=label, parent=tool_dependencies_root_folder ) tool_dependencies_root_folder.folders.append( folder ) # Insert a header row. tool_dependency_id += 1 @@ -320,9 +329,9 @@ if workflows: workflow_id = 0 folder_id += 1 - workflows_root_folder = Folder( id=folder_id, key='root', label='root' ) + workflows_root_folder = Folder( id=folder_id, key='root', label='root', parent=None ) folder_id += 1 - folder = Folder( id=folder_id, key='workflows', label=label ) + folder = Folder( id=folder_id, key='workflows', label=label, parent=workflows_root_folder ) workflows_root_folder.folders.append( folder ) # Insert a header row. workflow_id += 1 @@ -388,10 +397,19 @@ def key_is_current_repositorys_key( repository_name, repository_owner, changeset_revision, key ): toolshed_base_url, key_name, key_owner, key_changeset_revision = get_components_from_key( key ) return repository_name == key_name and repository_owner == key_owner and changeset_revision == key_changeset_revision -def remove_unwanted_repository_dependencies( folder ): +def prune_folder( folder, repository_dependency, key ): + if get_folder( folder, key ): + folder.remove_repository_dependency( repository_dependency ) + for sub_folder in folder.folders: + prune_folder( sub_folder, repository_dependency, key ) +def prune_repository_dependencies( folder, root_folder ): + """Remove repository_dependencies that are also folders, and coerce empty folders into repository dependencies.""" + remove_repository_dependencies( folder, root_folder ) + for sub_folder in folder.folders: + prune_repository_dependencies( sub_folder, root_folder ) +def remove_repository_dependencies( folder, root_folder ): for repository_dependency in folder.repository_dependencies: toolshed, name, owner, changeset_revision = repository_dependency.listify key = generate_repository_dependencies_key_for_repository( toolshed, name, owner, changeset_revision ) - if get_folder( folder, key ): - folder.remove_repository_dependency( repository_dependency ) + prune_folder( root_folder, repository_dependency, key ) \ No newline at end of file diff -r 75a97c971d36599955f67384b6f36ca73a80dd2e -r 9cf72c86ee4f37c9035cdc30912b4f33a0f6b3bb lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py --- a/lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py +++ b/lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py @@ -1066,10 +1066,10 @@ raw_text = response.read() response.close() repo_information_dict = from_json_string( raw_text ) - includes_tools = util.string_as_bool( repo_information_dict[ 'includes_tools' ] ) - includes_repository_dependencies = util.string_as_bool( repo_information_dict[ 'includes_repository_dependencies' ] ) - includes_tool_dependencies = util.string_as_bool( repo_information_dict[ 'includes_tool_dependencies' ] ) - encoded_repo_info_dicts = util.listify( repo_information_dict[ 'repo_info_dicts' ] ) + includes_tools = util.string_as_bool( repo_information_dict.get( 'includes_tools', False ) ) + includes_repository_dependencies = util.string_as_bool( repo_information_dict.get( 'includes_repository_dependencies', False ) ) + includes_tool_dependencies = util.string_as_bool( repo_information_dict.get( 'includes_tool_dependencies', False ) ) + encoded_repo_info_dicts = util.listify( repo_information_dict.get( 'repo_info_dicts', [] ) ) repo_info_dicts = [ tool_shed_decode( encoded_repo_info_dict ) for encoded_repo_info_dict in encoded_repo_info_dicts ] if ( not includes_tools and not includes_repository_dependencies ) or \ ( ( includes_tools or includes_repository_dependencies ) and kwd.get( 'select_tool_panel_section_button', False ) ): 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