Skip to content

Commit

Permalink
Merge pull request #91 from galuszkak/feature/upgrade-python
Browse files Browse the repository at this point in the history
  • Loading branch information
Changaco committed Jan 18, 2020
2 parents a29047d + 36e8573 commit 41aa6e0
Show file tree
Hide file tree
Showing 43 changed files with 36 additions and 257 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ branches:
- master
language: python
python:
- 2.7
- 3.4
- 3.5
- 3.6
- 3.7
- 3.8
install: travis_retry pip install tox-travis
script: tox
notifications:
Expand Down
8 changes: 8 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ environment:
PYTHON_VERSION: "3.7.x"
PYTHON_ARCH: "64"

- PYTHON: "C:\\Python38"
PYTHON_VERSION: "3.8.x"
PYTHON_ARCH: "32"

- PYTHON: "C:\\Python38-x64"
PYTHON_VERSION: "3.8.x"
PYTHON_ARCH: "64"

install:
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"

Expand Down
6 changes: 0 additions & 6 deletions aspen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
scheme in the global `codecs` registry to support handling decoding errors as
well as encoding errors.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals


from . import backcompat

backcompat.upgrade_backslashreplace()
5 changes: 0 additions & 5 deletions aspen/backcompat.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import codecs


Expand Down
4 changes: 0 additions & 4 deletions aspen/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
"""
This module defines all of the custom exceptions used across the Aspen library.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals


class ConfigurationError(Exception):
Expand Down
6 changes: 0 additions & 6 deletions aspen/http/mapping.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


NO_DEFAULT = object()


Expand Down
31 changes: 6 additions & 25 deletions aspen/http/request.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from six import PY2, text_type as str
from six.moves.urllib.parse import parse_qs, unquote, unquote_plus
from urllib.parse import parse_qs, unquote, unquote_plus

from .mapping import Mapping

Expand All @@ -14,7 +8,7 @@ def _decode(o, errors='strict'):


def path_decode(bs):
return _decode(unquote(bs.encode('ascii') if PY2 else bs))
return _decode(unquote(bs))


class PathPart(str):
Expand Down Expand Up @@ -102,22 +96,9 @@ def __init__(self, raw, errors='replace'):
"""Takes a string of type application/x-www-form-urlencoded.
"""
# urllib needs bytestrings in py2 and unicode strings in py3
raw_str = raw.encode('ascii') if PY2 else raw

self.decoded = _decode(unquote_plus(raw_str), errors=errors)
self.decoded = _decode(unquote_plus(raw), errors=errors)
self.raw = raw

common_kw = dict(keep_blank_values=True, strict_parsing=False)
if PY2:
# in python 2 parse_qs does its own unquote_plus'ing ...
as_dict = parse_qs(raw_str, **common_kw)
# ... but doesn't decode to unicode.
for k, vals in list(as_dict.items()):
as_dict[_decode(k, errors=errors)] = [
_decode(v, errors=errors) for v in vals
]
else:
# in python 3 parse_qs does the decoding
as_dict = parse_qs(raw_str, errors=errors, **common_kw)

Mapping.__init__(self, as_dict)
Mapping.__init__(self, parse_qs(
raw, errors=errors, keep_blank_values=True, strict_parsing=False
))
5 changes: 0 additions & 5 deletions aspen/request_processor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
path variables, loads the resource from the filesystem, and then renders and
encodes the resource (if it's dynamic).
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from copy import copy
import errno
import mimetypes
Expand Down
5 changes: 0 additions & 5 deletions aspen/request_processor/dispatcher.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
"""
This module implements finding the file that matches a request path.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from functools import reduce
from inspect import isclass
from operator import attrgetter
Expand Down
6 changes: 0 additions & 6 deletions aspen/request_processor/typecasting.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
"""
This module handles the parsing of path variables.
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from ..exceptions import TypecastError


Expand Down
5 changes: 0 additions & 5 deletions aspen/resources.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import os
import stat

Expand Down
5 changes: 0 additions & 5 deletions aspen/simplates/json_.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import datetime


Expand Down
5 changes: 0 additions & 5 deletions aspen/simplates/pagination.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import re


Expand Down
5 changes: 0 additions & 5 deletions aspen/simplates/renderers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import sys
import pkg_resources

Expand Down
13 changes: 4 additions & 9 deletions aspen/simplates/renderers/json_dump.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from . import Renderer, Factory
from . import Renderer as BaseRenderer, Factory as BaseFactory
from .. import json_

class Renderer(Renderer):

class Renderer(BaseRenderer):

def render_content(self, context):
output = context['output']
Expand All @@ -18,6 +14,5 @@ def render_content(self, context):
return r


class Factory(Factory):
class Factory(BaseFactory):
Renderer = Renderer

5 changes: 0 additions & 5 deletions aspen/simplates/renderers/jsonp_dump.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from . import Factory
from .json_dump import Renderer as JsonRenderer

Expand Down
5 changes: 0 additions & 5 deletions aspen/simplates/renderers/stdlib_format.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from . import Renderer, Factory


Expand Down
5 changes: 0 additions & 5 deletions aspen/simplates/renderers/stdlib_percent.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from . import Renderer, Factory


Expand Down
11 changes: 3 additions & 8 deletions aspen/simplates/renderers/stdlib_template.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 . import Renderer, Factory
from . import Renderer as BaseRenderer, Factory as BaseFactory
from string import Template


class Renderer(Renderer):
class Renderer(BaseRenderer):

def compile(self, filepath, padded):
return Template(padded)
Expand All @@ -16,5 +11,5 @@ def render_content(self, context):
return self.compiled.substitute(context)


class Factory(Factory):
class Factory(BaseFactory):
Renderer = Renderer
9 changes: 1 addition & 8 deletions aspen/simplates/simplate.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from io import BytesIO
import re

from six import PY2

from ..output import Output
from .pagination import split_and_escape, parse_specline, Page
from aspen.http.resource import Dynamic, open_resource


DEFAULT_ENCODING = 'ascii' if PY2 else 'utf8'
DEFAULT_ENCODING = 'utf8'


renderer_re = re.compile(r'[a-z0-9.-_]+$')
Expand Down
5 changes: 0 additions & 5 deletions aspen/testing.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
"""
This module provides helpers for testing applications that use Aspen.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from contextlib import contextmanager
import os
import sys
Expand Down
18 changes: 3 additions & 15 deletions fabricate.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
"""

from __future__ import with_statement, print_function, unicode_literals

# fabricate version number
__version__ = '1.26'

Expand Down Expand Up @@ -49,11 +47,6 @@ def __getattr__(self, name):
raise NotImplementedError("multiprocessing module not available, can't do parallel builds")
multiprocessing = MultiprocessingModule()

PY3 = sys.version_info[0] == 3
if PY3:
string_types = str
else:
string_types = basestring

# so you can do "from fabricate import *" to simplify your build script
__all__ = ['setup', 'run', 'autoclean', 'main', 'shell', 'fabricate_version',
Expand All @@ -67,7 +60,6 @@ def __getattr__(self, name):
__doc__ += "Exported functions are:\n" + ' ' + '\n '.join(textwrap.wrap(', '.join(__all__), 80))



FAT_atime_resolution = 24*60*60 # resolution on FAT filesystems (seconds)
FAT_mtime_resolution = 2

Expand Down Expand Up @@ -127,7 +119,7 @@ def args_to_list(args):
if isinstance(arg, (list, tuple)):
arglist.extend(args_to_list(arg))
else:
if not isinstance(arg, string_types):
if not isinstance(arg, str):
arg = str(arg)
arglist.append(arg)
return arglist
Expand Down Expand Up @@ -415,9 +407,6 @@ def __call__(self, *args, **kwargs):
and after access times to determine dependencies. """

# For Python pre-2.5, ensure os.stat() returns float atimes
old_stat_float = os.stat_float_times()
os.stat_float_times(True)

originals = self.file_times()
if self.atimes == 2:
befores = originals
Expand Down Expand Up @@ -464,7 +453,6 @@ def __call__(self, *args, **kwargs):
if original != afters.get(name, None):
self._utime(name, original[0], original[1])

os.stat_float_times(old_stat_float) # restore stat_float_times value
return deps, outputs

class StraceProcess(object):
Expand Down Expand Up @@ -1183,7 +1171,7 @@ def memoize(self, command, **kwargs):
This function is for compatiblity with memoize.py and is
deprecated. Use run() instead. """
if isinstance(command, string_types):
if isinstance(command, str):
args = shlex.split(command)
else:
args = args_to_list(command)
Expand Down Expand Up @@ -1329,7 +1317,7 @@ def set_runner(self, runner):
try:
self.runner = self._runner_map[runner](self)
except KeyError:
if isinstance(runner, string_types):
if isinstance(runner, str):
# For backwards compatibility, allow runner to be the
# name of a method in a derived class:
self.runner = getattr(self, runner)
Expand Down
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
python-mimeparse>=0.1.4
filesystem_tree>=1.0.1
dependency_injection>=1.1.0
six
scandir; python_version < "3.5"
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
, 'License :: OSI Approved :: MIT License'
, 'Natural Language :: English'
, 'Operating System :: OS Independent'
, 'Programming Language :: Python :: 2.7'
, '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'
, 'Programming Language :: Python :: Implementation :: CPython'
, 'Topic :: Internet :: WWW/HTTP :: WSGI :: Application'
]
Expand Down

0 comments on commit 41aa6e0

Please sign in to comment.