From 24981f87f4ae52b5ca063d662954a340da91639e Mon Sep 17 00:00:00 2001 From: Constanza Date: Mon, 29 Apr 2019 10:51:18 -0400 Subject: [PATCH] INCR-194 (#20318) * INCR-194 * fixed error, the import absolute_import instruction should have been at the beginning of the file * added empty line required by PEP 8 * fixed comments order * trailing whitespace fixed --- .../management/commands/compile_sass.py | 14 +++++++------- .../create_sites_and_configurations.py | 19 ++++++++++--------- .../test_create_sites_and_configurations.py | 10 +++++----- .../theming/migrations/0001_initial.py | 2 +- .../theming/templatetags/optional_include.py | 7 ++++--- .../theming/templatetags/theme_pipeline.py | 8 ++++---- 6 files changed, 31 insertions(+), 29 deletions(-) diff --git a/openedx/core/djangoapps/theming/management/commands/compile_sass.py b/openedx/core/djangoapps/theming/management/commands/compile_sass.py index 1f1ad6bb2f..2cfe2ed0b5 100644 --- a/openedx/core/djangoapps/theming/management/commands/compile_sass.py +++ b/openedx/core/djangoapps/theming/management/commands/compile_sass.py @@ -2,14 +2,14 @@ Management command for compiling sass. """ -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals + +import six from django.core.management import BaseCommand, CommandError - -from paver.easy import call_task - +from openedx.core.djangoapps.theming.helpers import get_theme_base_dirs, get_themes, is_comprehensive_theming_enabled from pavelib.assets import ALL_SYSTEMS -from openedx.core.djangoapps.theming.helpers import get_themes, get_theme_base_dirs, is_comprehensive_theming_enabled +from paver.easy import call_task class Command(BaseCommand): @@ -103,7 +103,7 @@ class Command(BaseCommand): raise CommandError("Invalid themes value, It must either be 'all' or 'no' or list of themes.") # Raise error if any of the given theme name is invalid # (theme name would be invalid if it does not exist in themes directory) - elif (not set(given_themes).issubset(available_themes.keys())) and is_comprehensive_theming_enabled(): + elif (not set(given_themes).issubset(list(available_themes.keys()))) and is_comprehensive_theming_enabled(): raise CommandError( "Given themes '{themes}' do not exist inside any of the theme directories '{theme_dirs}'".format( themes=", ".join(set(given_themes) - set(available_themes.keys())), @@ -112,7 +112,7 @@ class Command(BaseCommand): ) if "all" in given_themes: - themes = list(available_themes.itervalues()) + themes = list(six.itervalues(available_themes)) elif "no" in given_themes: themes = [] else: diff --git a/openedx/core/djangoapps/theming/management/commands/create_sites_and_configurations.py b/openedx/core/djangoapps/theming/management/commands/create_sites_and_configurations.py index 05b126b818..820fa91577 100644 --- a/openedx/core/djangoapps/theming/management/commands/create_sites_and_configurations.py +++ b/openedx/core/djangoapps/theming/management/commands/create_sites_and_configurations.py @@ -2,21 +2,22 @@ This command will be run by an ansible script. """ -import os -import json -import fnmatch -import logging +from __future__ import absolute_import + +import fnmatch +import json +import logging +import os -from provider.oauth2.models import Client -from provider.constants import CONFIDENTIAL -from edx_oauth2_provider.models import TrustedClient from django.contrib.auth.models import User from django.contrib.sites.models import Site from django.core.management.base import BaseCommand - +from edx_oauth2_provider.models import TrustedClient from lms.djangoapps.commerce.models import CommerceConfiguration -from openedx.core.djangoapps.theming.models import SiteTheme from openedx.core.djangoapps.site_configuration.models import SiteConfiguration +from openedx.core.djangoapps.theming.models import SiteTheme +from provider.constants import CONFIDENTIAL +from provider.oauth2.models import Client from student.models import UserProfile LOG = logging.getLogger(__name__) diff --git a/openedx/core/djangoapps/theming/management/commands/tests/test_create_sites_and_configurations.py b/openedx/core/djangoapps/theming/management/commands/tests/test_create_sites_and_configurations.py index 793a2df79c..68b6d79d58 100644 --- a/openedx/core/djangoapps/theming/management/commands/tests/test_create_sites_and_configurations.py +++ b/openedx/core/djangoapps/theming/management/commands/tests/test_create_sites_and_configurations.py @@ -2,16 +2,16 @@ Test cases for create_sites_and_configurations command. """ -import mock +from __future__ import absolute_import -from django.test import TestCase +import mock from django.contrib.auth.models import User from django.contrib.sites.models import Site -from django.core.management import call_command, CommandError - -from provider.oauth2.models import Client +from django.core.management import CommandError, call_command +from django.test import TestCase from edx_oauth2_provider.models import TrustedClient from openedx.core.djangoapps.theming.models import SiteTheme +from provider.oauth2.models import Client from student.models import UserProfile SITES = ["site_a", "site_b"] diff --git a/openedx/core/djangoapps/theming/migrations/0001_initial.py b/openedx/core/djangoapps/theming/migrations/0001_initial.py index 78c906f1c9..a9db371b6d 100644 --- a/openedx/core/djangoapps/theming/migrations/0001_initial.py +++ b/openedx/core/djangoapps/theming/migrations/0001_initial.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals from django.db import migrations, models diff --git a/openedx/core/djangoapps/theming/templatetags/optional_include.py b/openedx/core/djangoapps/theming/templatetags/optional_include.py index 47575693f0..29ffbd07da 100644 --- a/openedx/core/djangoapps/theming/templatetags/optional_include.py +++ b/openedx/core/djangoapps/theming/templatetags/optional_include.py @@ -5,14 +5,15 @@ specifically, the do_include function. It has been modified as little as possible, in order to match the behavior of the {% include %} template tag, except for making it optional. """ + # Because we want to match the original loader_tags.py file as closely as # possible, we should disable pylint so it doesn't complain about the violations # that are already in that file # pylint: skip-file +from __future__ import absolute_import + from django.template import Library, TemplateDoesNotExist -from django.template.base import ( - TemplateSyntaxError, token_kwargs -) +from django.template.base import TemplateSyntaxError, token_kwargs from django.template.loader_tags import IncludeNode register = Library() diff --git a/openedx/core/djangoapps/theming/templatetags/theme_pipeline.py b/openedx/core/djangoapps/theming/templatetags/theme_pipeline.py index f144c44ba0..d3e37e4187 100644 --- a/openedx/core/djangoapps/theming/templatetags/theme_pipeline.py +++ b/openedx/core/djangoapps/theming/templatetags/theme_pipeline.py @@ -2,14 +2,14 @@ Theme aware pipeline template tags. """ +from __future__ import absolute_import + from django import template from django.template.loader import render_to_string from django.utils.safestring import mark_safe - -from pipeline.templatetags.pipeline import StylesheetNode, JavascriptNode -from pipeline.utils import guess_type - from openedx.core.djangoapps.theming.helpers_static import get_static_file_url +from pipeline.templatetags.pipeline import JavascriptNode, StylesheetNode +from pipeline.utils import guess_type register = template.Library() # pylint: disable=invalid-name