Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recent Django / Python improvements #51

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
language: python
python:
- 2.7
- 3.4
- 3.5
- 3.6
- 3.7
- 3.8
env:
- DJANGO_VERSION=1.11
- DJANGO_VERSION=2.2
install:
- pip install -q Django==$DJANGO_VERSION
- pip install -e .[flake8,tests]
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/roverdotcom/django-inlinecss.png?branch=master)](https://travis-ci.org/roverdotcom/django-inlinecss)
[![Build Status](https://travis-ci.org/roverdotcom/django-inlinecss.svg?branch=master)](https://travis-ci.org/roverdotcom/django-inlinecss)

## About

Expand All @@ -14,8 +14,8 @@ template language.

- BeautifulSoup
- cssutils
- Python 2.7+,3.4+
- Django 1.11+
- Python 3.5+
- Django 2.2+


#### Step 2: Install django_inlinecss
Expand Down
6 changes: 0 additions & 6 deletions django_inlinecss/conf.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals


try:
import importlib
except ImportError:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In python 3 just import importlib .
There is no from django.utils import importlib in django 2.2

Expand Down
7 changes: 1 addition & 6 deletions django_inlinecss/css_loaders.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from django.contrib.staticfiles import finders
from django.contrib.staticfiles.storage import staticfiles_storage


class BaseCSSLoader(object):
class BaseCSSLoader:
def __init__(self):
pass

Expand Down
9 changes: 1 addition & 8 deletions django_inlinecss/engines.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from builtins import object

import pynliner


class EngineBase(object):
class EngineBase:
def __init__(self, html, css):
self.html = html
self.css = css
Expand Down
9 changes: 2 additions & 7 deletions django_inlinecss/templatetags/inlinecss.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from django import template
from django.utils.encoding import smart_text
from django.utils.encoding import smart_str

from django_inlinecss import conf

Expand All @@ -23,7 +18,7 @@ def render(self, context):
for expression in self.filter_expressions:
path = expression.resolve(context, True)
if path is not None:
path = smart_text(path)
path = smart_str(path)

css_loader = conf.get_css_loader()()
css = ''.join((css, css_loader.load(path)))
Expand Down
9 changes: 2 additions & 7 deletions django_inlinecss/tests/test_css_loaders.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
"""
Test CSS loaders
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from django.conf import settings
from django.test import TestCase
from django.test import override_settings
Expand All @@ -18,7 +13,7 @@
class StaticfilesFinderCSSLoaderTestCase(TestCase):
def setUp(self):
self.loader = StaticfilesFinderCSSLoader()
super(StaticfilesFinderCSSLoaderTestCase, self).setUp()
super().setUp()

def test_loads_existing_css_file(self):
css = self.loader.load('bar.css')
Expand All @@ -34,7 +29,7 @@ def test_load_file_does_not_exist(self):
class StaticfilesStorageCSSLoaderTestCase(TestCase):
def setUp(self):
self.loader = StaticfilesStorageCSSLoader()
super(StaticfilesStorageCSSLoaderTestCase, self).setUp()
super().setUp()

def test_loads_existing_css_file(self):
css = self.loader.load('bar.css')
Expand Down
7 changes: 1 addition & 6 deletions django_inlinecss/tests/test_templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
The actual CSS inlining displayed here is extremely simple:
tests of the CSS selector functionality is independent.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import os

from django.conf import settings
Expand All @@ -21,7 +16,7 @@

class InlinecssTests(TestCase):
def setUp(self):
super(InlinecssTests, self).setUp()
super().setUp()

def assert_foo_and_bar_rendered(self, rendered):
foo_div_regex = (
Expand Down
24 changes: 5 additions & 19 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import io
import os
import sys
Expand All @@ -21,14 +15,13 @@
URL = 'https://github.com/roverdotcom/django-inlinecss'
EMAIL = '[email protected]'
AUTHOR = 'Philip Kimmey'
REQUIRES_PYTHON = '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <3.7'
REQUIRES_PYTHON = '>=3.5'
VERSION = None

# What packages are required for this module to be executed?
REQUIRED = [
'Django>=1.11',
'Django>=2.2',
'pynliner',
'future>=0.16.0',
]

# What packages are required only for tests?
Expand All @@ -41,7 +34,7 @@
# What packages are optional?
EXTRAS = {
'flake8': [
'flake8==3.6.0',
'flake8==3.8.0',
'flake8-isort==2.6.0',
'isort==4.3.4',
'testfixtures==6.3.0',
Expand All @@ -55,12 +48,6 @@
# Import the README and use it as the long-description.
# Note: this will only work if 'README.md' is present in your MANIFEST.in file!

try:
# Python 3 will raise FileNotFoundError instead of IOError
FileNotFoundError = IOError
except NameError:
pass

try:
with io.open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = '\n' + f.read()
Expand Down Expand Up @@ -134,12 +121,11 @@ def run(self):
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Topic :: Communications :: Email',
'Topic :: Text Processing :: Markup :: HTML',
],
Expand Down
5 changes: 0 additions & 5 deletions test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import os


Expand Down