'For each exported repository archive contained in the capsule, inspect the Tool Shed to
see if that repository already exists or if the current user is authorized to create the
repository and set a status appropriately.  If repository dependencies are included in the
capsule, repositories may have various owners.  We will keep repositories associated with
owners, so we need to restrict created repositories to those the current user can create.
If the current user is an admin or a member of the IUC, all repositories will be created
no matter the owner.  Otherwise only repositories whose associated owner is the current
user will be created.'

def get_repository_status_from_tool_shed(self, repository_info_dicts):

    repository_status_info_dicts = []
    for repository_info_dict in repository_info_dicts:
        repository = repository_util.get_repository_by_name_and_owner(self.app, repository_info_dict['name'], repository_info_dict['owner'])
        if repository:
            if repository.deleted:
                repository_info_dict['status'] = 'Exists,    deleted'
            elif repository.deprecated:
                repository_info_dict['status'] = 'Exists,    deprecated'
            else:
                repository_info_dict['status'] = 'Exists'
        elif self.user_is_admin:
            repository_info_dict['status'] = None
        elif self.app.security_agent.user_can_import_repository_archive(self.user, repository_info_dict['owner']):
            repository_info_dict['status'] = None
        else:
            repository_info_dict['status'] = 'Not    authorized    to    import'
        repository_status_info_dicts.append(repository_info_dict)
    return repository_status_info_dicts
