From a5e8c167eb14367ba138f9048e0819936ecec4a5 Mon Sep 17 00:00:00 2001 From: Michael Youngstrom Date: Thu, 28 Mar 2019 16:05:28 -0400 Subject: [PATCH] Run python-modernize on openedx/core/djangoapps/catalog --- openedx/core/djangoapps/catalog/admin.py | 2 ++ openedx/core/djangoapps/catalog/constants.py | 2 ++ openedx/core/djangoapps/catalog/models.py | 2 ++ openedx/core/djangoapps/catalog/urls.py | 5 +++++ openedx/core/djangoapps/catalog/utils.py | 9 ++++++--- openedx/core/djangoapps/catalog/views.py | 1 + 6 files changed, 18 insertions(+), 3 deletions(-) diff --git a/openedx/core/djangoapps/catalog/admin.py b/openedx/core/djangoapps/catalog/admin.py index 545ffd4886..a80f1161ae 100644 --- a/openedx/core/djangoapps/catalog/admin.py +++ b/openedx/core/djangoapps/catalog/admin.py @@ -1,6 +1,8 @@ """ Django admin bindings for catalog support models. """ +from __future__ import absolute_import + from config_models.admin import ConfigurationModelAdmin from django.contrib import admin diff --git a/openedx/core/djangoapps/catalog/constants.py b/openedx/core/djangoapps/catalog/constants.py index b040b45e98..c3700e77bd 100644 --- a/openedx/core/djangoapps/catalog/constants.py +++ b/openedx/core/djangoapps/catalog/constants.py @@ -1,4 +1,6 @@ """ Constants associated with catalog """ +from __future__ import absolute_import + from enum import Enum diff --git a/openedx/core/djangoapps/catalog/models.py b/openedx/core/djangoapps/catalog/models.py index 691bc6a8f9..35bf203e17 100644 --- a/openedx/core/djangoapps/catalog/models.py +++ b/openedx/core/djangoapps/catalog/models.py @@ -1,4 +1,6 @@ """Models governing integration with the catalog service.""" +from __future__ import absolute_import + from config_models.models import ConfigurationModel from django.conf import settings from django.contrib.auth import get_user_model diff --git a/openedx/core/djangoapps/catalog/urls.py b/openedx/core/djangoapps/catalog/urls.py index 8b4a802b07..6914d14bab 100644 --- a/openedx/core/djangoapps/catalog/urls.py +++ b/openedx/core/djangoapps/catalog/urls.py @@ -1,3 +1,8 @@ +""" +Defines the URL routes for this app. +""" +from __future__ import absolute_import + from django.conf.urls import url from . import views diff --git a/openedx/core/djangoapps/catalog/utils.py b/openedx/core/djangoapps/catalog/utils.py index 4d0849c21d..89c41ced23 100644 --- a/openedx/core/djangoapps/catalog/utils.py +++ b/openedx/core/djangoapps/catalog/utils.py @@ -1,10 +1,13 @@ """Helper functions for working with the catalog service.""" +from __future__ import absolute_import + import copy import datetime import logging import uuid import pycountry +import six from django.core.cache import cache from django.core.exceptions import ObjectDoesNotExist from edx_rest_api_client.client import EdxRestApiClient @@ -197,7 +200,7 @@ def get_pathways(site, pathway_id=None): logger.warning('Failed to get credit pathway ids from the cache.') pathways = cache.get_many([PATHWAY_CACHE_KEY_TPL.format(id=pathway_id) for pathway_id in pathway_ids]) - pathways = pathways.values() + pathways = list(pathways.values()) # The get_many above sometimes fails to bring back details cached on one or # more Memcached nodes. It doesn't look like these keys are being evicted. @@ -216,7 +219,7 @@ def get_pathways(site, pathway_id=None): retried_pathways = cache.get_many( [PATHWAY_CACHE_KEY_TPL.format(id=pathway_id) for pathway_id in missing_ids] ) - pathways += retried_pathways.values() + pathways += list(retried_pathways.values()) still_missing_ids = set(pathway_ids) - set(pathway['id'] for pathway in pathways) for missing_id in still_missing_ids: @@ -412,7 +415,7 @@ def get_course_uuid_for_course(course_run_key): course_run_data = get_edx_api_data( catalog_integration, 'course_runs', - resource_id=unicode(course_run_key), + resource_id=six.text_type(course_run_key), api=api, cache_key=run_cache_key if catalog_integration.is_cache_enabled else None, long_term_cache=True, diff --git a/openedx/core/djangoapps/catalog/views.py b/openedx/core/djangoapps/catalog/views.py index 740032f052..8a9f150c99 100644 --- a/openedx/core/djangoapps/catalog/views.py +++ b/openedx/core/djangoapps/catalog/views.py @@ -1,4 +1,5 @@ from __future__ import absolute_import + from django.conf import settings from django.core.management import call_command from django.http import Http404, HttpResponse