diff --git a/.travis.yml b/.travis.yml index 8f4fbea..020a7e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,15 +3,12 @@ language: python python: - - 2.7 - 3.5 matrix: include: - python: 3.5 env: TOXENV=quality - - python: 2.7 - env: TOXENV=quality script: - make clean diff --git a/requirements/base.txt b/requirements/base.txt index 0fa2f65..9087aa1 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -2,11 +2,8 @@ # This file is autogenerated by pip-compile # To update, run: # -# pip-compile --output-file requirements/base.txt requirements/base.in +# pip-compile --output-file=requirements/base.txt requirements/base.in # ---index-url https://pypi.org/simple/ ---extra-index-url https://saleem.latif:AP81xRt5DR6ruigseCVZpcYxA1QFyuHvZ4ky6m@intechww.jfrog.io/intechww/api/pypi/pypi-virtual/simple - django==1.11.25 importlib-metadata==0.23 # via path.py more-itertools==7.2.0 # via zipp diff --git a/requirements/dev.in b/requirements/dev.in index 7941763..0fc4851 100644 --- a/requirements/dev.in +++ b/requirements/dev.in @@ -1,8 +1,4 @@ # Additional requirements for development of this application -diff-cover # Changeset diff test coverage pip-tools # Requirements file management tox # virtualenv management for tests -tox-battery==0.5 # Makes tox aware of requirements file changes (it's experimental, so keep it pinned) -twine # Utility for PyPI package uploads -wheel # For generation of wheels for PyPI diff --git a/requirements/dev.txt b/requirements/dev.txt index a639ad7..8013515 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -2,38 +2,28 @@ # This file is autogenerated by pip-compile # To update, run: # -# pip-compile --output-file requirements/dev.txt requirements/base.in requirements/dev.in requirements/quality.in requirements/test.in +# pip-compile --output-file=requirements/dev.txt requirements/base.in requirements/dev.in requirements/quality.in requirements/test.in # ---index-url https://pypi.org/simple/ ---extra-index-url https://saleem.latif:AP81xRt5DR6ruigseCVZpcYxA1QFyuHvZ4ky6m@intechww.jfrog.io/intechww/api/pypi/pypi-virtual/simple - argparse==1.4.0 # via caniusepython3 astroid==2.3.1 # via pylint atomicwrites==1.3.0 # via pytest attrs==19.2.0 # via pytest backports.functools-lru-cache==1.5 # via caniusepython3 -bleach==3.1.0 # via readme-renderer caniusepython3==7.1.0 certifi==2019.9.11 # via requests chardet==3.0.4 # via requests click==7.0 # via pip-tools coverage==4.5.4 # via pytest-cov ddt==1.2.1 -diff-cover==2.3.0 distlib==0.2.9.post0 # via caniusepython3 django==1.11.25 -docutils==0.15.2 # via readme-renderer factory-boy==2.12.0 faker==2.0.2 # via factory-boy filelock==3.0.12 # via tox idna==2.8 # via requests importlib-metadata==0.23 # via path.py, pluggy, pytest, tox -inflect==2.1.0 # via jinja2-pluralize isort==4.3.21 -jinja2-pluralize==0.3.0 # via diff-cover -jinja2==2.10.1 # via diff-cover, jinja2-pluralize lazy-object-proxy==1.4.2 # via astroid -markupsafe==1.1.1 # via jinja2 mccabe==0.6.1 # via pylint mock==3.0.5 more-itertools==7.2.0 # via pytest, zipp @@ -41,12 +31,10 @@ packaging==19.2 # via caniusepython3, pytest, tox path.py==12.0.1 pep8==1.7.1 pip-tools==4.1.0 -pkginfo==1.5.0.1 # via twine pluggy==0.13.0 # via pytest, tox py==1.8.0 # via pytest, tox pycodestyle==2.5.0 pydocstyle==4.0.1 -pygments==2.4.2 # via diff-cover, readme-renderer pylint==2.4.2 pyparsing==2.4.2 # via packaging pytest-cov==2.7.1 @@ -54,22 +42,18 @@ pytest-django==3.5.1 pytest==5.2.0 # via pytest-cov, pytest-django python-dateutil==2.8.0 # via faker pytz==2019.2 # via django -readme-renderer==24.0 # via twine -requests-toolbelt==0.9.1 # via twine -requests==2.22.0 # via caniusepython3, requests-toolbelt, twine -six==1.12.0 # via astroid, bleach, diff-cover, faker, mock, packaging, pip-tools, python-dateutil, readme-renderer, tox +requests==2.22.0 # via caniusepython3 +six==1.12.0 # via astroid, faker, mock, packaging, pip-tools, python-dateutil, tox snowballstemmer==1.9.1 # via pydocstyle text-unidecode==1.3 # via faker toml==0.10.0 # via tox -tox-battery==0.5 tox==3.14.0 -tqdm==4.36.1 # via twine -twine==2.0.0 typed-ast==1.4.0 # via astroid urllib3==1.25.6 # via requests virtualenv==16.7.5 # via tox wcwidth==0.1.7 # via pytest -webencodings==0.5.1 # via bleach -wheel==0.33.6 wrapt==1.11.2 # via astroid zipp==0.6.0 # via importlib-metadata + +# The following packages are considered to be unsafe in a requirements file: +# setuptools==41.2.0 # via caniusepython3 diff --git a/requirements/quality.txt b/requirements/quality.txt index e72a98d..7857a20 100644 --- a/requirements/quality.txt +++ b/requirements/quality.txt @@ -2,11 +2,8 @@ # This file is autogenerated by pip-compile # To update, run: # -# pip-compile --output-file requirements/quality.txt requirements/base.in requirements/quality.in requirements/test.in +# pip-compile --output-file=requirements/quality.txt requirements/base.in requirements/quality.in requirements/test.in # ---index-url https://pypi.org/simple/ ---extra-index-url https://saleem.latif:AP81xRt5DR6ruigseCVZpcYxA1QFyuHvZ4ky6m@intechww.jfrog.io/intechww/api/pypi/pypi-virtual/simple - argparse==1.4.0 # via caniusepython3 astroid==2.3.1 # via pylint atomicwrites==1.3.0 # via pytest @@ -51,3 +48,6 @@ urllib3==1.25.6 # via requests wcwidth==0.1.7 # via pytest wrapt==1.11.2 # via astroid zipp==0.6.0 # via importlib-metadata + +# The following packages are considered to be unsafe in a requirements file: +# setuptools==41.2.0 # via caniusepython3 diff --git a/requirements/test.txt b/requirements/test.txt index fa6dc67..3f1ba36 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -2,11 +2,8 @@ # This file is autogenerated by pip-compile # To update, run: # -# pip-compile --output-file requirements/test.txt requirements/base.in requirements/test.in +# pip-compile --output-file=requirements/test.txt requirements/base.in requirements/test.in # ---index-url https://pypi.org/simple/ ---extra-index-url https://saleem.latif:AP81xRt5DR6ruigseCVZpcYxA1QFyuHvZ4ky6m@intechww.jfrog.io/intechww/api/pypi/pypi-virtual/simple - atomicwrites==1.3.0 # via pytest attrs==19.2.0 # via pytest coverage==4.5.4 # via pytest-cov diff --git a/settings/test.py b/settings/test.py index a9701b4..eff4b5d 100644 --- a/settings/test.py +++ b/settings/test.py @@ -9,6 +9,7 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.11/ref/settings/ """ +from __future__ import absolute_import import os from path import Path diff --git a/test_utils/__init__.py b/test_utils/__init__.py index d83adee..b0566ed 100644 --- a/test_utils/__init__.py +++ b/test_utils/__init__.py @@ -1,8 +1,10 @@ """ Utility functions for theming tests. """ +from __future__ import absolute_import import os + from path import Path from django.conf import settings diff --git a/test_utils/factories.py b/test_utils/factories.py index a65fad6..f7c8514 100644 --- a/test_utils/factories.py +++ b/test_utils/factories.py @@ -1,6 +1,8 @@ """ Theming Factories. """ +from __future__ import absolute_import + import factory from factory.django import DjangoModelFactory @@ -14,7 +16,7 @@ class SiteFactory(DjangoModelFactory): Factory for django.contrib.sites.models.Site. """ - class Meta(object): + class Meta: model = Site django_get_or_create = ('domain',) @@ -27,7 +29,7 @@ class ThemeFactory(DjangoModelFactory): Factory for theming.models.Theme. """ - class Meta(object): + class Meta: model = Theme django_get_or_create = ('site',) diff --git a/test_utils/testcases.py b/test_utils/testcases.py index a3f71da..8e5d62f 100644 --- a/test_utils/testcases.py +++ b/test_utils/testcases.py @@ -1,6 +1,8 @@ """ Module containing functions and methods common to all theme related tests. """ +from __future__ import absolute_import + from django.test import TestCase as DjangoTestCase @@ -8,5 +10,3 @@ class TestCase(DjangoTestCase): """ Base test case for theme tests. """ - - pass diff --git a/test_utils/utils.py b/test_utils/utils.py index 80274d9..d4f16cd 100644 --- a/test_utils/utils.py +++ b/test_utils/utils.py @@ -1,6 +1,8 @@ """ Utility functions used by the tests in `theming` app. """ +from __future__ import absolute_import + from django.test import RequestFactory from theming.thread_locals import get_current_request, set_current_request, set_current_theme diff --git a/tests/test_theming/test_apps.py b/tests/test_theming/test_apps.py index f95f23f..76ac22c 100644 --- a/tests/test_theming/test_apps.py +++ b/tests/test_theming/test_apps.py @@ -1,6 +1,8 @@ """ Validate ThemingConfig """ +from __future__ import absolute_import + import ddt from six import assertRaisesRegex @@ -73,9 +75,9 @@ def test_ready_with_missing_theme_settings(self): # pylint: disable=invalid-nam """ del settings.THEMING with assertRaisesRegex( - self, - ImproperlyConfigured, - r'"THEMING" setting not set in django settings file. ' - r'If you are not using theming then remove it from INSTALLED_APPS.' + self, + ImproperlyConfigured, + r'"THEMING" setting not set in django settings file. ' + r'If you are not using theming then remove it from INSTALLED_APPS.' ): self.theming_config.ready() diff --git a/tests/test_theming/test_core.py b/tests/test_theming/test_core.py index d67327c..06abef7 100644 --- a/tests/test_theming/test_core.py +++ b/tests/test_theming/test_core.py @@ -1,6 +1,8 @@ """ Validate theming core. """ +from __future__ import absolute_import + import os import ddt diff --git a/tests/test_theming/test_middleware.py b/tests/test_theming/test_middleware.py index 8e191c9..3a36dec 100644 --- a/tests/test_theming/test_middleware.py +++ b/tests/test_theming/test_middleware.py @@ -1,6 +1,7 @@ """ Validate theming middleware. """ +from __future__ import absolute_import from django.test import RequestFactory diff --git a/tests/test_theming/test_models.py b/tests/test_theming/test_models.py index 31c579b..ff36743 100644 --- a/tests/test_theming/test_models.py +++ b/tests/test_theming/test_models.py @@ -1,6 +1,9 @@ +# pylint: disable=no-member """ Validate theming models. """ +from __future__ import absolute_import + from functools import partial import ddt diff --git a/tests/test_theming/test_static/test_finders.py b/tests/test_theming/test_static/test_finders.py index 183382b..8624a90 100644 --- a/tests/test_theming/test_static/test_finders.py +++ b/tests/test_theming/test_static/test_finders.py @@ -1,6 +1,8 @@ """ Tests to validate theme finders work as expected. """ +from __future__ import absolute_import + import ddt from django.core.checks import Error diff --git a/tests/test_theming/test_static/test_storage.py b/tests/test_theming/test_static/test_storage.py index 068abee..0b33ff0 100644 --- a/tests/test_theming/test_static/test_storage.py +++ b/tests/test_theming/test_static/test_storage.py @@ -1,6 +1,8 @@ """ Tests to validate theme storage classes work as expected.. """ +from __future__ import absolute_import + import ddt from django.conf import settings diff --git a/tests/test_theming/test_template/test_loaders/test_theme.py b/tests/test_theming/test_template/test_loaders/test_theme.py index 56ac58a..43a4fd1 100644 --- a/tests/test_theming/test_template/test_loaders/test_theme.py +++ b/tests/test_theming/test_template/test_loaders/test_theme.py @@ -1,6 +1,8 @@ """ Validate theme template loaders. """ +from __future__ import absolute_import + from functools import partial import ddt diff --git a/tests/test_theming/test_thread_locals.py b/tests/test_theming/test_thread_locals.py index 9b059ee..5b83a99 100644 --- a/tests/test_theming/test_thread_locals.py +++ b/tests/test_theming/test_thread_locals.py @@ -1,6 +1,8 @@ """ Validate thread_locals module of theming. """ +from __future__ import absolute_import + from functools import partial from threading import local diff --git a/theming/__init__.py b/theming/__init__.py index 8df261b..66d4248 100644 --- a/theming/__init__.py +++ b/theming/__init__.py @@ -1,8 +1,11 @@ """ Module to hold all the nuts and bolts for theming a django site. """ +from __future__ import absolute_import + +from .core import get_base_dir, get_themes, is_enabled + __version__ = "0.1.0" -from .core import is_enabled, get_base_dir, get_themes default_app_config = "theming.apps.ThemingConfig" # pylint: disable=invalid-name diff --git a/theming/admin.py b/theming/admin.py index 5650a31..a649d5f 100644 --- a/theming/admin.py +++ b/theming/admin.py @@ -1,6 +1,8 @@ """ Module containing admin interfaces for the theming app. """ +from __future__ import absolute_import + from django.contrib import admin from .models import Theme diff --git a/theming/apps.py b/theming/apps.py index 39691b5..04f542f 100644 --- a/theming/apps.py +++ b/theming/apps.py @@ -1,6 +1,8 @@ """ App Config for theming. """ +from __future__ import absolute_import + import os from django.apps import AppConfig @@ -33,27 +35,27 @@ def ready(self): '"THEMING" setting not set in django settings file. ' 'If you are not using theming then remove it from INSTALLED_APPS.' ) - elif 'DIRS' not in settings.THEMING: + if 'DIRS' not in settings.THEMING: raise ImproperlyConfigured( 'The THEMING["DIRS"] setting must be populated.', ) - elif 'ENABLED' not in settings.THEMING: + if 'ENABLED' not in settings.THEMING: raise ImproperlyConfigured( 'The THEMING["ENABLED"] setting must be populated.', ) - elif not isinstance(settings.THEMING['DIRS'], (list, tuple)): + if not isinstance(settings.THEMING['DIRS'], (list, tuple)): raise ImproperlyConfigured( 'The THEMING["DIRS"] setting is not a tuple or list. Perhaps you forgot a trailing comma?', ) - elif not all([isinstance(theme_dir, str) for theme_dir in settings.THEMING['DIRS']]): + if not all([isinstance(theme_dir, str) for theme_dir in settings.THEMING['DIRS']]): raise ImproperlyConfigured( 'THEMING["DIRS"] must contain only string paths.', ) - elif not all([theme_dir.startswith("/") for theme_dir in settings.THEMING['DIRS']]): + if not all([theme_dir.startswith("/") for theme_dir in settings.THEMING['DIRS']]): raise ImproperlyConfigured( 'THEMING["DIRS"] must contain only absolute paths to themes dirs.', ) - elif not all([os.path.isdir(theme_dir) for theme_dir in settings.THEMING['DIRS']]): + if not all([os.path.isdir(theme_dir) for theme_dir in settings.THEMING['DIRS']]): raise ImproperlyConfigured( 'THEMING["DIRS"] must contain valid paths.', ) diff --git a/theming/core.py b/theming/core.py index 5df8a81..a5d2990 100644 --- a/theming/core.py +++ b/theming/core.py @@ -1,6 +1,8 @@ """ Core logic for Theming. """ +from __future__ import absolute_import, division + import os from path import Path diff --git a/theming/exceptions.py b/theming/exceptions.py index 878b1b5..13c099c 100644 --- a/theming/exceptions.py +++ b/theming/exceptions.py @@ -1,6 +1,8 @@ """ Module to contain all of the exceptions defined and used by the theming app. """ +from __future__ import absolute_import + from django.core.exceptions import ImproperlyConfigured as DjangoImproperlyConfigured @@ -9,20 +11,14 @@ class ThemeException(Exception): Base exception for all theming related exceptions. """ - pass - class MiddlewareNotActivated(ThemeException): """ Exception raised when features being used depends on a theming middleware. """ - pass - class ImproperlyConfigured(ThemeException, DjangoImproperlyConfigured): """ Theming is somehow improperly configured. """ - - pass diff --git a/theming/middleware.py b/theming/middleware.py index 2856c4b..21fb231 100644 --- a/theming/middleware.py +++ b/theming/middleware.py @@ -1,6 +1,7 @@ """ Module to contain middleware defined by the theming app. """ +from __future__ import absolute_import from django.utils.deprecation import MiddlewareMixin diff --git a/theming/models.py b/theming/models.py index 2e9ca8b..be16453 100644 --- a/theming/models.py +++ b/theming/models.py @@ -1,6 +1,7 @@ """ Module to contain model definitions for theming app. """ +from __future__ import absolute_import from path import Path diff --git a/theming/static/finders.py b/theming/static/finders.py index 795bc83..12e10e2 100644 --- a/theming/static/finders.py +++ b/theming/static/finders.py @@ -3,6 +3,8 @@ https://docs.djangoproject.com/en/1.8/ref/settings/#std:setting-STATICFILES_FINDERS Yes, this interface is private and undocumented, but we need to access it anyway. """ +from __future__ import absolute_import + import os from collections import OrderedDict @@ -44,7 +46,10 @@ def __init__(self, *args, **kwargs): super(ThemeFilesFinder, self).__init__(*args, **kwargs) - def check(self, **kwargs): + def check(self, **kwargs): # pylint: disable=unused-argument + """ + Check if current instance data has errors. + """ errors = [] if 'DIRS' not in settings.THEMING: errors.append(Error( diff --git a/theming/static/storage.py b/theming/static/storage.py index 07742ec..052cd5f 100644 --- a/theming/static/storage.py +++ b/theming/static/storage.py @@ -2,6 +2,8 @@ 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 from django.conf import settings @@ -92,6 +94,6 @@ def themed(self, name, theme_name): name = name[1:] if name.startswith("/") else name path = safe_join(themed_path, name) return os.path.exists(path) + # in live mode check static asset in the static files dir defined by "STATIC_ROOT" setting - else: - return self.exists(os.path.join(theme_name, name)) + return self.exists(os.path.join(theme_name, name)) diff --git a/theming/template/loaders/theme.py b/theming/template/loaders/theme.py index cf6d65b..db68ee8 100644 --- a/theming/template/loaders/theme.py +++ b/theming/template/loaders/theme.py @@ -1,6 +1,7 @@ """ Wrapper for loading templates from "templates" directories for themes. """ +from __future__ import absolute_import from django.template.loaders.filesystem import Loader as FilesystemLoader diff --git a/theming/thread_locals.py b/theming/thread_locals.py index ed9cba2..889b7c9 100644 --- a/theming/thread_locals.py +++ b/theming/thread_locals.py @@ -2,6 +2,7 @@ """ Thread scoped variables. """ +from __future__ import absolute_import from threading import local