Fixing python-modernize issues.

This commit is contained in:
arbisoft
2019-07-09 13:14:00 +05:00
parent 9d856c4cec
commit bc39c60715
18 changed files with 45 additions and 12 deletions

View File

@@ -1,6 +1,8 @@
"""
Django admin page for theming models
"""
from __future__ import absolute_import
from django.contrib import admin
from .models import SiteTheme

View File

@@ -1,7 +1,9 @@
from __future__ import absolute_import
from django.apps import AppConfig
from openedx.core.djangoapps.plugins.constants import ProjectType, PluginURLs
from openedx.core.djangoapps.plugins.constants import PluginURLs, ProjectType
plugin_urls_config = {PluginURLs.NAMESPACE: u'theming', PluginURLs.REGEX: r'^theming/'}

View File

@@ -1,7 +1,10 @@
"""
Settings validations for the theming app
"""
from __future__ import absolute_import
import os
import six
from django.conf import settings
from django.core.checks import Error, Tags, register

View File

@@ -17,6 +17,8 @@ interface, as well.
.. _Django-Pipeline: https://django-pipeline.readthedocs.org/
.. _Django-Require: https://github.com/etianen/django-require
"""
from __future__ import absolute_import
import os
from collections import OrderedDict

View File

@@ -4,6 +4,8 @@ Helpers for accessing comprehensive theming related variables.
This file is imported at startup. Imports of models or things which import models will break startup on Django 1.9+. If
you need models here, please import them inside the function which uses them.
"""
from __future__ import absolute_import
import os
import re
from logging import getLogger

View File

@@ -2,7 +2,10 @@
Code which dynamically discovers comprehensive themes. Deliberately uses no Django settings,
as the discovery happens during the initial setup of Django settings.
"""
from __future__ import absolute_import
import os
from path import Path
@@ -127,7 +130,8 @@ class Theme(object):
return hash((self.theme_dir_name, self.path))
def __unicode__(self):
return u"<Theme: {name} at '{path}'>".format(name=self.name, path=self.path)
# pylint: disable=line-too-long
return u"<Theme: {name} at '{path}'>".format(name=self.name, path=self.path) # xss-lint: disable=python-wrap-html
def __repr__(self):
return self.__unicode__()

View File

@@ -1,4 +1,6 @@
from __future__ import absolute_import
from django.contrib.staticfiles.storage import staticfiles_storage

View File

@@ -5,11 +5,11 @@ Management command for compiling sass.
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 paver.easy import call_task
class Command(BaseCommand):

View File

@@ -13,11 +13,12 @@ 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 provider.constants import CONFIDENTIAL
from provider.oauth2.models import Client
from lms.djangoapps.commerce.models import CommerceConfiguration
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__)

View File

@@ -10,8 +10,9 @@ from django.contrib.sites.models import Site
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 openedx.core.djangoapps.theming.models import SiteTheme
from student.models import UserProfile
SITES = ["site_a", "site_b"]

View File

@@ -5,6 +5,8 @@ Note:
This middleware depends on "django_sites_extensions" app
So it must be added to INSTALLED_APPS in django settings files.
"""
from __future__ import absolute_import
from django.conf import settings
from .models import SiteTheme

View File

@@ -1,6 +1,8 @@
"""
Django models supporting the Comprehensive Theming subsystem
"""
from __future__ import absolute_import
from django.contrib.sites.models import Site
from django.db import models

View File

@@ -2,7 +2,8 @@
This file contains helpers for paver commands, Django is not initialized in paver commands.
So, django settings, models etc. can not be used here.
"""
from __future__ import print_function
from __future__ import absolute_import, print_function
import os
from path import Path

View File

@@ -2,6 +2,8 @@
Comprehensive Theming support for Django's collectstatic functionality.
See https://docs.djangoproject.com/en/1.8/ref/contrib/staticfiles/
"""
from __future__ import absolute_import
import os.path
import posixpath
import re

View File

@@ -1,6 +1,8 @@
"""
Theming aware template loaders.
"""
from __future__ import absolute_import
from django.template.loaders.filesystem import Loader as FilesystemLoader
from edxmako.makoloader import MakoLoader

View File

@@ -7,10 +7,11 @@ 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 openedx.core.djangoapps.theming.helpers_static import get_static_file_url
from pipeline.templatetags.pipeline import JavascriptNode, StylesheetNode
from pipeline.utils import guess_type
from openedx.core.djangoapps.theming.helpers_static import get_static_file_url
register = template.Library() # pylint: disable=invalid-name

View File

@@ -2,12 +2,13 @@
Defines URLs for theming views.
"""
from __future__ import absolute_import
from django.conf.urls import url
from .helpers import is_comprehensive_theming_enabled
from .views import ThemingAdministrationFragmentView
if is_comprehensive_theming_enabled():
urlpatterns = [
url(

View File

@@ -2,6 +2,8 @@
Views file for theming administration.
"""
from __future__ import absolute_import
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.http import Http404
@@ -9,15 +11,16 @@ from django.shortcuts import redirect
from django.template.loader import render_to_string
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext as _
from web_fragments.fragment import Fragment
from openedx.core.djangoapps.plugin_api.views import EdxFragmentView
from openedx.core.djangoapps.user_api.preferences.api import (
delete_user_preference,
get_user_preference,
set_user_preference,
set_user_preference
)
from openedx.core.djangoapps.util.user_messages import PageLevelMessages
from student.roles import GlobalStaff
from web_fragments.fragment import Fragment
from .helpers import theme_exists
from .models import SiteTheme