commit/galaxy-central: dannon: Merged in nsoranzo/galaxy-central (pull request #628)
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/d3dff45bbb05/ Changeset: d3dff45bbb05 User: dannon Date: 2015-01-12 12:02:23+00:00 Summary: Merged in nsoranzo/galaxy-central (pull request #628) PEP-8 fixes and API doc ehnancements to libraries API Affected #: 2 files diff -r eb61b02da1866c4a7da0f2fa357ce43e6c62b57c -r d3dff45bbb0554150da4491eb2d2031d11f90063 lib/galaxy/webapps/galaxy/api/libraries.py --- a/lib/galaxy/webapps/galaxy/api/libraries.py +++ b/lib/galaxy/webapps/galaxy/api/libraries.py @@ -6,10 +6,7 @@ from galaxy.managers import libraries, folders, roles from galaxy.web import _future_expose_api as expose_api from galaxy.web import _future_expose_api_anonymous as expose_api_anonymous -from galaxy.model.orm import and_, not_, or_ from galaxy.web.base.controller import BaseAPIController -from sqlalchemy.orm.exc import MultipleResultsFound -from sqlalchemy.orm.exc import NoResultFound import logging log = logging.getLogger( __name__ ) @@ -48,7 +45,7 @@ def __decode_id( self, trans, encoded_id, object_name=None ): """ - Try to decode the id. + Try to decode the id. :param object_name: Name of the object the id belongs to. (optional) :type object_name: str @@ -149,7 +146,7 @@ synopsis = payload.get( 'synopsis', None ) else: raise exceptions.RequestParameterMissingException( "You did not specify any payload." ) - updated_library = self.library_manager.update( trans, library, name, description, synopsis ) + updated_library = self.library_manager.update( trans, library, name, description, synopsis ) library_dict = self.library_manager.get_library_dict( trans, updated_library ) return library_dict @@ -248,20 +245,20 @@ *POST /api/libraries/{encoded_library_id}/permissions :param encoded_library_id: the encoded id of the library to set the permissions of - :type encoded_library_id: an encoded id string + :type encoded_library_id: an encoded id string :param action: (required) describes what action should be performed available actions: remove_restrictions, set_permissions - :type action: string + :type action: string :param access_ids[]: list of Role.id defining roles that should have access permission on the library - :type access_ids[]: string or list + :type access_ids[]: string or list :param add_ids[]: list of Role.id defining roles that should have add item permission on the library - :type add_ids[]: string or list + :type add_ids[]: string or list :param manage_ids[]: list of Role.id defining roles that should have manage permission on the library - :type manage_ids[]: string or list + :type manage_ids[]: string or list :param modify_ids[]: list of Role.id defining roles that should have modify permission on the library - :type modify_ids[]: string or list + :type modify_ids[]: string or list :rtype: dictionary :returns: dict of current roles for all available permission types @@ -306,7 +303,7 @@ else: invalid_access_roles_names.append( role_id ) if len( invalid_access_roles_names ) > 0: - log.warning( "The following roles could not be added to the library access permission: " + str( invalid_access_roles_names ) ) + log.warning( "The following roles could not be added to the library access permission: " + str( invalid_access_roles_names ) ) # ADD TO LIBRARY ROLES valid_add_roles = [] @@ -319,8 +316,8 @@ else: invalid_add_roles_names.append( role_id ) if len( invalid_add_roles_names ) > 0: - log.warning( "The following roles could not be added to the add library item permission: " + str( invalid_add_roles_names ) ) - + log.warning( "The following roles could not be added to the add library item permission: " + str( invalid_add_roles_names ) ) + # MANAGE LIBRARY ROLES valid_manage_roles = [] invalid_manage_roles_names = [] @@ -332,8 +329,8 @@ else: invalid_manage_roles_names.append( role_id ) if len( invalid_manage_roles_names ) > 0: - log.warning( "The following roles could not be added to the manage library permission: " + str( invalid_manage_roles_names ) ) - + log.warning( "The following roles could not be added to the manage library permission: " + str( invalid_manage_roles_names ) ) + # MODIFY LIBRARY ROLES valid_modify_roles = [] invalid_modify_roles_names = [] @@ -345,7 +342,7 @@ else: invalid_modify_roles_names.append( role_id ) if len( invalid_modify_roles_names ) > 0: - log.warning( "The following roles could not be added to the modify library permission: " + str( invalid_modify_roles_names ) ) + log.warning( "The following roles could not be added to the modify library permission: " + str( invalid_modify_roles_names ) ) permissions = { trans.app.security_agent.permitted_actions.LIBRARY_ACCESS : valid_access_roles } permissions.update( { trans.app.security_agent.permitted_actions.LIBRARY_ADD : valid_add_roles } ) @@ -357,7 +354,7 @@ # Copy the permissions to the root folder trans.app.security_agent.copy_library_permissions( trans, library, library.root_folder ) else: - raise exceptions.RequestParameterInvalidException( 'The mandatory parameter "action" has an invalid value.' + raise exceptions.RequestParameterInvalidException( 'The mandatory parameter "action" has an invalid value.' 'Allowed values are: "remove_restrictions", set_permissions"' ) roles = self.library_manager.get_current_roles( trans, library ) return roles @@ -369,18 +366,16 @@ POST /api/libraries/{encoded_library_id}/permissions Updates the library permissions. """ - import galaxy.util - params = galaxy.util.Params( payload ) + params = util.Params( payload ) permissions = {} for k, v in trans.app.model.Library.permitted_actions.items(): role_params = params.get( k + '_in', [] ) - in_roles = [ trans.sa_session.query( trans.app.model.Role ).get( trans.security.decode_id( x ) ) for x in galaxy.util.listify( role_params ) ] + in_roles = [ trans.sa_session.query( trans.app.model.Role ).get( trans.security.decode_id( x ) ) for x in util.listify( role_params ) ] permissions[ trans.app.security_agent.get_action( v.action ) ] = in_roles trans.app.security_agent.set_all_library_permissions( trans, library, permissions ) trans.sa_session.refresh( library ) # Copy the permissions to the root folder trans.app.security_agent.copy_library_permissions( trans, library, library.root_folder ) - message = "Permissions updated for library '%s'." % library.name item = library.to_dict( view='element', value_mapper={ 'id' : trans.security.encode_id , 'root_folder_id' : trans.security.encode_id } ) return item diff -r eb61b02da1866c4a7da0f2fa357ce43e6c62b57c -r d3dff45bbb0554150da4491eb2d2031d11f90063 lib/galaxy/webapps/galaxy/api/library_contents.py --- a/lib/galaxy/webapps/galaxy/api/library_contents.py +++ b/lib/galaxy/webapps/galaxy/api/library_contents.py @@ -29,12 +29,12 @@ .. note:: May be slow! Returns all content traversing recursively through all folders. .. seealso:: :class:`galaxy.webapps.galaxy.api.FolderContentsController.index` for a non-recursive solution - :param library_id: encoded id string of the library - :type library_id: string + :param library_id: the encoded id of the library + :type library_id: str :returns: list of dictionaries of the form: * id: the encoded id of the library item - * name: the 'libary path' + * name: the 'library path' or relationship of the library item to the root * type: 'file' or 'folder' * url: the url to get detailed information on the library item @@ -109,7 +109,7 @@ :param id: the encoded id of the library item to return :type id: str - :param library_id: encoded id string of the library that contains this item + :param library_id: the encoded id of the library that contains this item :type library_id: str :returns: detailed library item information @@ -119,7 +119,7 @@ :func:`galaxy.model.LibraryDataset.to_dict` and :attr:`galaxy.model.LibraryFolder.dict_element_visible_keys` """ - class_name, content_id = self.__decode_library_content_id( trans, id ) + class_name, content_id = self.__decode_library_content_id( id ) if class_name == 'LibraryFolder': content = self.get_library_folder( trans, content_id, check_ownership=False, check_accessible=True ) rval = content.to_dict( view='element', value_mapper={ 'id': trans.security.encode_id } ) @@ -146,27 +146,39 @@ the HDA's encoded id in ``from_hda_id`` (and optionally ``ldda_message``). :type library_id: str - :param library_id: encoded id string of the library where to create the new item + :param library_id: the encoded id of the library where to create the new item :type payload: dict :param payload: dictionary structure containing: - * folder_id: the parent folder of the new item + * folder_id: the encoded id of the parent folder of the new item * create_type: the type of item to create ('file', 'folder' or 'collection') - * from_hda_id: (optional) the id of an accessible HDA to copy into the - library + * from_hda_id: (optional, only if create_type is 'file') the + encoded id of an accessible HDA to copy into the library * ldda_message: (optional) the new message attribute of the LDDA created * extended_metadata: (optional) dub-dictionary containing any extended metadata to associate with the item - * link_data_only: (optional) either 'copy_files' (default) or 'link_to_files' * upload_option: (optional) one of 'upload_file' (default), 'upload_directory' or 'upload_paths' - * server_dir: (optional) only if upload_option is 'upload_directory' - * filesystem_paths: (optional) only if upload_option is 'upload_paths' and the user is an admin + * server_dir: (optional, only if upload_option is + 'upload_directory') relative path of the subdirectory of Galaxy + ``library_import_dir`` to upload. All and only the files (i.e. + no subdirectories) contained in the specified directory will be + uploaded. + * filesystem_paths: (optional, only if upload_option is + 'upload_paths' and the user is an admin) file paths on the + Galaxy server to upload to the library, one file per line + * link_data_only: (optional, only when upload_option is + 'upload_directory' or 'upload_paths') either 'copy_files' + (default) or 'link_to_files'. Setting to 'link_to_files' + symlinks instead of copying the files + * name: (optional, only if create_type is 'folder') name of the + folder to create + * description: (optional, only if create_type is 'folder') + description of the folder to create :rtype: dict :returns: a dictionary containing the id, name, and 'show' url of the new item """ - create_type = None if 'create_type' not in payload: trans.response.status = 400 return "Missing required 'create_type' parameter." @@ -178,10 +190,10 @@ if 'folder_id' not in payload: trans.response.status = 400 - return "Missing requred 'folder_id' parameter." + return "Missing required 'folder_id' parameter." else: folder_id = payload.pop( 'folder_id' ) - class_name, folder_id = self.__decode_library_content_id( trans, folder_id ) + class_name, folder_id = self.__decode_library_content_id( folder_id ) try: # security is checked in the downstream controller parent = self.get_library_folder( trans, folder_id, check_ownership=False, check_accessible=False ) @@ -198,9 +210,7 @@ #check for extended metadata, store it and pop it out of the param #otherwise sanitize_param will have a fit - ex_meta_payload = None - if 'extended_metadata' in payload: - ex_meta_payload = payload.pop('extended_metadata') + ex_meta_payload = payload.pop('extended_metadata', None) # Now create the desired content object, either file or folder. if create_type == 'file': @@ -272,7 +282,7 @@ def _copy_hda_to_library_folder( self, trans, from_hda_id, library_id, folder_id, ldda_message='' ): """ - Copies hda ``from_hda_id`` to library folder ``library_folder_id`` optionally + Copies hda ``from_hda_id`` to library folder ``folder_id``, optionally adding ``ldda_message`` to the new ldda's ``message``. ``library_contents.create`` will branch to this if called with 'from_hda_id' @@ -325,7 +335,7 @@ :type id: str :param id: the encoded id of the library item to return :type library_id: str - :param library_id: encoded id string of the library that contains this item + :param library_id: the encoded id of the library that contains this item :type payload: dict :param payload: dictionary structure containing:: 'converted_dataset_id': @@ -344,7 +354,7 @@ trans.sa_session.add( assoc ) trans.sa_session.flush() - def __decode_library_content_id( self, trans, content_id ): + def __decode_library_content_id( self, content_id ): if len( content_id ) % 16 == 0: return 'LibraryDataset', content_id elif content_id.startswith( 'F' ): 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