Skip to content

Commit 5d3e4f9

Browse files
authored
Merge pull request #556 from a-detiste/master
trim old Python2 compatibility layer
2 parents e92246f + 645719e commit 5d3e4f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+11
-104
lines changed

docs/conf.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# serve to show the default.
1313

1414
import sys, os
15-
from webassets.six.moves import map
16-
from webassets.six.moves import zip
1715

1816
# If extensions (or modules to document with autodoc) are in another directory,
1917
# add these directories to sys.path here. If the directory is relative to the

examples/appengine/helloworld.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
from __future__ import print_function
2-
from __future__ import print_function
3-
from __future__ import print_function
4-
from __future__ import print_function
5-
from __future__ import print_function
61
# Import assets configuration
72
from assets import bundle
83

src/webassets/bundle.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
import os
33
from os import path
44
from webassets import six
5-
from webassets.six.moves import map
6-
from webassets.six.moves import zip
75

86
from .filter import get_filter
97
from .merge import (FileHunk, UrlHunk, FilterTool, merge, merge_filters,
@@ -161,12 +159,9 @@ def _set_filters(self, value):
161159
self._filters = ()
162160
return
163161

164-
if isinstance(value, six.string_types):
162+
if isinstance(value, str):
165163
# 333: Simplify w/o condition?
166-
if six.PY3:
167-
filters = map(str.strip, value.split(','))
168-
else:
169-
filters = map(unicode.strip, unicode(value).split(','))
164+
filters = map(str.strip, value.split(','))
170165
elif isinstance(value, (list, tuple)):
171166
filters = value
172167
else:
@@ -276,7 +271,7 @@ def _filter_duplicates(resolved):
276271
def _get_depends(self):
277272
return self._depends
278273
def _set_depends(self, value):
279-
self._depends = [value] if isinstance(value, six.string_types) else value
274+
self._depends = [value] if isinstance(value, str) else value
280275
self._resolved_depends = None
281276
depends = property(_get_depends, _set_depends, doc=
282277
"""Allows you to define an additional set of files (glob syntax

src/webassets/env.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import os
22
from os import path
33
from itertools import chain
4-
from webassets import six
5-
from webassets.six.moves import map
64
from webassets.utils import is_url
75

86
try:
@@ -242,7 +240,7 @@ def resolve_source(self, ctx, item):
242240
"""
243241

244242
# Pass through some things unscathed
245-
if not isinstance(item, six.string_types):
243+
if not isinstance(item, str):
246244
# Don't stand in the way of custom values.
247245
return item
248246
if is_url(item) or path.isabs(item):
@@ -308,7 +306,7 @@ def __init__(self):
308306
self._anon_bundles = []
309307

310308
def __iter__(self):
311-
return chain(six.itervalues(self._named_bundles), self._anon_bundles)
309+
return chain(self._named_bundles.values(), self._anon_bundles)
312310

313311
def __getitem__(self, name):
314312
return self._named_bundles[name]

src/webassets/ext/jinja2.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import
2-
31
import warnings
42
import jinja2
53
from jinja2.ext import Extension

src/webassets/filter/__init__.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@
22
contents (think minification, compression).
33
"""
44

5-
from __future__ import with_statement
6-
75
import os
86
import subprocess
97
import inspect
108
import shlex
119
import tempfile
1210
import pkgutil
1311
from webassets import six
14-
from webassets.six.moves import map
15-
from webassets.six.moves import zip
1612
try:
1713
frozenset
1814
except NameError:
@@ -34,7 +30,7 @@ def freezedicts(obj):
3430
if isinstance(obj, (list, tuple)):
3531
return type(obj)([freezedicts(sub) for sub in obj])
3632
if isinstance(obj, dict):
37-
return frozenset(six.iteritems(obj))
33+
return frozenset(obj.items())
3834
return obj
3935

4036

@@ -50,19 +46,11 @@ def smartsplit(string, sep):
5046
be done.
5147
"""
5248
assert string is not None # or shlex will read from stdin
53-
if not six.PY3:
54-
# On 2.6, shlex fails miserably with unicode input
55-
is_unicode = isinstance(string, unicode)
56-
if is_unicode:
57-
string = string.encode('utf8')
5849
l = shlex.shlex(string, posix=True)
5950
l.whitespace += ','
6051
l.whitespace_split = True
6152
l.quotes = ''
62-
if not six.PY3 and is_unicode:
63-
return map(lambda s: s.decode('utf8'), list(l))
64-
else:
65-
return list(l)
53+
return list(l)
6654

6755

6856
class option(tuple):
@@ -204,9 +192,6 @@ def get_config(self, setting=False, env=None, require=True,
204192
if value is None and not env is False:
205193
value = os.environ.get(env)
206194
if value is not None:
207-
if not six.PY3:
208-
# TODO: What charset should we use? What does Python 3 use?
209-
value = value.decode('utf8')
210195
if type == list:
211196
value = smartsplit(value, ',')
212197

@@ -623,7 +608,7 @@ def get_filter(f, *args, **kwargs):
623608
# Don't need to do anything.
624609
assert not args and not kwargs
625610
return f
626-
elif isinstance(f, six.string_types):
611+
elif isinstance(f, str):
627612
if f in _FILTERS:
628613
klass = _FILTERS[f]
629614
else:

src/webassets/filter/autoprefixer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import with_statement
2-
31
from webassets.filter import ExternalTool
42
from webassets.utils import working_directory
53

src/webassets/filter/clevercss.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import absolute_import
21
from webassets.filter import Filter
32

43

src/webassets/filter/closure.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
['--output_wrapper', 'foo: %output%']
3131
"""
3232

33-
from __future__ import absolute_import
3433
from webassets.filter import JavaTool
3534

3635

src/webassets/filter/coffeescript.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from __future__ import print_function
21
import os, subprocess
32

43
from webassets.filter import Filter

0 commit comments

Comments
 (0)