Skip to content

Commit

Permalink
more py2 droppage (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbe committed May 7, 2020
1 parent a3671cb commit 8710a0d
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 50 deletions.
1 change: 0 additions & 1 deletion premailer/__init__.py
@@ -1,4 +1,3 @@
from __future__ import absolute_import, unicode_literals
from .premailer import Premailer, transform # noqa

__version__ = "3.6.2"
1 change: 0 additions & 1 deletion premailer/__main__.py
@@ -1,4 +1,3 @@
from __future__ import absolute_import, unicode_literals
import sys
import argparse

Expand Down
8 changes: 1 addition & 7 deletions premailer/merge_style.py
@@ -1,13 +1,7 @@
from __future__ import absolute_import
import cssutils
import threading
from operator import itemgetter

try:
from collections import OrderedDict
except ImportError: # pragma: no cover
# some old python 2.6 thing then, eh?
from ordereddict import OrderedDict
from collections import OrderedDict

from premailer.cache import function_cache

Expand Down
32 changes: 4 additions & 28 deletions premailer/premailer.py
@@ -1,11 +1,10 @@
from __future__ import absolute_import, print_function, unicode_literals

import codecs
import operator
import os
import re
import sys
import warnings
from collections import OrderedDict
from urllib.parse import urljoin, urlparse

import cssutils
import requests
Expand All @@ -15,29 +14,6 @@
from premailer.cache import function_cache
from premailer.merge_style import csstext_to_pairs, merge_styles

try:
from collections import OrderedDict
except ImportError: # pragma: no cover
# some old python 2.6 thing then, eh?
from ordereddict import OrderedDict

if sys.version_info >= (3,): # pragma: no cover
# As in, Python 3
from io import StringIO
from urllib.parse import urljoin, urlparse

STR_TYPE = str
else: # Python 2
try:
from cStringIO import StringIO
except ImportError: # pragma: no cover
from StringIO import StringIO

StringIO = StringIO # shut up pyflakes
from urlparse import urljoin, urlparse

STR_TYPE = basestring # NOQA


__all__ = ["PremailerError", "Premailer", "transform"]

Expand Down Expand Up @@ -184,10 +160,10 @@ def __init__(
self.capitalize_float_margin = capitalize_float_margin
# whether to process or ignore selectors like '* { foo:bar; }'
self.include_star_selectors = include_star_selectors
if isinstance(external_styles, STR_TYPE):
if isinstance(external_styles, str):
external_styles = [external_styles]
self.external_styles = external_styles
if isinstance(css_text, STR_TYPE):
if isinstance(css_text, str):
css_text = [css_text]
self.css_text = css_text
self.strip_important = strip_important
Expand Down
2 changes: 0 additions & 2 deletions premailer/tests/test_cache.py
@@ -1,5 +1,3 @@
from __future__ import absolute_import, unicode_literals

import imp
import os
import threading
Expand Down
1 change: 0 additions & 1 deletion premailer/tests/test_merge_style.py
@@ -1,4 +1,3 @@
from __future__ import absolute_import, unicode_literals
import unittest
from premailer.merge_style import csstext_to_pairs, merge_styles

Expand Down
11 changes: 1 addition & 10 deletions premailer/tests/test_premailer.py
@@ -1,11 +1,9 @@
from __future__ import absolute_import, unicode_literals

import logging
import re
import sys
import unittest
from contextlib import contextmanager
from io import StringIO # Yes, the is an io lib in py2.x
from io import StringIO

from lxml.etree import XMLSyntaxError, fromstring
from requests.exceptions import HTTPError
Expand All @@ -21,13 +19,6 @@
transform,
)

if sys.version_info >= (3,): # As in, Python 3
from urllib.request import urlopen
else: # Python 2
from urllib2 import urlopen

urlopen = urlopen # shut up pyflakes


whitespace_between_tags = re.compile(r">\s*<")

Expand Down

0 comments on commit 8710a0d

Please sign in to comment.