parameters: (self, repo, collaborator)
return_statement: return result
docstring: Removes a user's or app's privileges on a repo.
  
          Returns True on success.
  
          Raises LookupError when repo or collaborator does not exist.
          Raises User.DoesNotExist if collaborator owns repo.
          Raises PermissionDenied on insufficient permissions.
docstring_summary: Removes a user's or app's privileges on a repo.
docstring_tokens: Removes a user s or app s privileges on a repo .
function: def delete_collaborator(self, repo, collaborator):
          """
          Removes a user's or app's privileges on a repo.
  
          Returns True on success.
  
          Raises LookupError when repo or collaborator does not exist.
          Raises User.DoesNotExist if collaborator owns repo.
          Raises PermissionDenied on insufficient permissions.
          """
          with _superuser_connection(self.repo_base) as conn:
              collaborators = conn.list_collaborators(repo=repo)
              collaborators = [c.get('username') for c in collaborators]
  
              # Current user must be the repo's owner or the collaborator to be
              # removed and must be an existing collaborator. If not the owner
              # and removing someone else, current user must have CREATE db
              # privileges.
              if (self.username not in [collaborator, self.repo_base] or
                      self.username not in collaborators):
                  DataHubManager.has_repo_db_privilege(
                      self.username, self.repo_base, repo, 'CREATE')
              # The reason we're enforcing permission checks this way is to deal
              # with the edge case where a user removes himself as a collaborator
              # from another user's repo.
              if collaborator not in collaborators:
                  raise LookupError('Failed to delete collaborator.'
                                    ' %s is not a collaborator in the specified '
                                    'repository.' % collaborator)
  
              collab = User.objects.get(username=collaborator)
              Collaborator.objects.get(
                  user=collab, repo_name=repo, repo_base=self.repo_base).delete()
  
              result = conn.delete_collaborator(
                  repo=repo, collaborator=collaborator)
          return result
function_tokens: def delete_collaborator ( self , repo , collaborator ) : with _superuser_connection ( self . repo_base ) as conn : collaborators = conn . list_collaborators ( repo = repo ) collaborators = [ c . get ( 'username' ) for c in collaborators ] # Current user must be the repo's owner or the collaborator to be # removed and must be an existing collaborator. If not the owner # and removing someone else, current user must have CREATE db # privileges. if ( self . username not in [ collaborator , self . repo_base ] or self . username not in collaborators ) : DataHubManager . has_repo_db_privilege ( self . username , self . repo_base , repo , 'CREATE' ) # The reason we're enforcing permission checks this way is to deal # with the edge case where a user removes himself as a collaborator # from another user's repo. if collaborator not in collaborators : raise LookupError ( 'Failed to delete collaborator.' ' %s is not a collaborator in the specified ' 'repository.' % collaborator ) collab = User . objects . get ( username = collaborator ) Collaborator . objects . get ( user = collab , repo_name = repo , repo_base = self . repo_base ) . delete ( ) result = conn . delete_collaborator ( repo = repo , collaborator = collaborator ) return result