Skip to content

Commit

Permalink
Dropped python 3.5 and below.
Browse files Browse the repository at this point in the history
  • Loading branch information
akornatskyy committed Nov 7, 2020
1 parent db1e571 commit 076d4ad
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 139 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ language: python

matrix:
include:
- python: 2.7
env: TOXENV=py27
- python: 3.6
env: TOXENV=py36
- python: 3.7
env: TOXENV=py37
- python: 3.8
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ Resources:
## Install

[wheezy.html](https://pypi.org/project/wheezy.html) requires
[python](http://www.python.org) version 2.4 to 2.7 or 3.2+. It is
independent of operating system. You can install it from
[pypi](https://pypi.org/project/wheezy.html) site:
[python](http://www.python.org) version 3.6+. It is independent of operating
system. You can install it from [pypi](https://pypi.org/project/wheezy.html)
site:

```sh
pip install -U wheezy.html
Expand All @@ -39,7 +39,6 @@ If you would like take a benefit of template preprocessing for Mako,
Jinja2, Tenjin or Wheezy.Template engines specify extra requirements:

```sh
pip install wheezy.html[jinja2]
pip install wheezy.html[wheezy.template]
```

Expand Down
37 changes: 0 additions & 37 deletions requirements/dev-py2.txt

This file was deleted.

4 changes: 2 additions & 2 deletions requirements/dev-py3.txt → requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile --output-file=requirements/dev-py3.txt requirements/dev.in
# pip-compile --output-file=requirements/dev.txt requirements/dev.in
#
atomicwrites==1.4.0 # via pytest
attrs==20.3.0 # via pytest
Expand All @@ -23,7 +23,7 @@ pytest==6.1.2 # via -r requirements/dev.in, pytest-cov
six==1.15.0 # via packaging, pip-tools
tenjin==1.1.1 # via -r requirements/dev.in
toml==0.10.2 # via pytest
wheezy.template==3.0.0 # via -r requirements/dev.in
wheezy.template==3.0.1 # via -r requirements/dev.in

# The following packages are considered to be unsafe in a requirements file:
# pip
12 changes: 2 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
os.path.join(p, "ext", "__init__.py"),
],
nthreads=2,
compiler_directives={"language_level": 3},
quiet=True,
)
except ImportError:
Expand Down Expand Up @@ -72,6 +73,7 @@ def warn(self):
setup(
name="wheezy.html",
version=VERSION,
python_requires=">=3.6",
description="A lightweight html rendering library",
long_description=README,
long_description_content_type="text/markdown",
Expand All @@ -86,16 +88,6 @@ def warn(self):
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.4",
"Programming Language :: Python :: 2.5",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.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",
Expand Down
44 changes: 0 additions & 44 deletions src/wheezy/html/boost.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@

#include <Python.h>

#if PY_VERSION_HEX < 0x02050000
typedef int Py_ssize_t;
#endif

#if PY_VERSION_HEX < 0x02060000
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
#endif

static PyObject*
escape_html_unicode(PyUnicodeObject *s)
{
Expand Down Expand Up @@ -86,23 +78,15 @@ escape_html_unicode(PyUnicodeObject *s)
static PyObject*
escape_html_string(PyObject *s)
{
#if PY_MAJOR_VERSION < 3
const Py_ssize_t s_size = PyString_GET_SIZE(s);
#else
const Py_ssize_t s_size = PyBytes_GET_SIZE(s);
#endif
if (s_size == 0)
{
Py_INCREF(s);
return (PyObject*)s;
}

Py_ssize_t count = 0;
#if PY_MAJOR_VERSION < 3
char *start = PyString_AS_STRING(s);
#else
char *start = PyBytes_AS_STRING(s);
#endif
const char *end = start + s_size;
char *p = start;
while(p < end)
Expand All @@ -127,22 +111,14 @@ escape_html_string(PyObject *s)
return (PyObject*)s;
}

#if PY_MAJOR_VERSION < 3
PyObject *result = PyString_FromStringAndSize(NULL, s_size + count);
#else
PyObject *result = PyBytes_FromStringAndSize(NULL, s_size + count);
#endif
if (! result)
{
return NULL;
}

p = start;
#if PY_MAJOR_VERSION < 3
char *r = PyString_AS_STRING(result);
#else
char *r = PyBytes_AS_STRING(result);
#endif
while(p < end)
{
char ch = *p++;
Expand Down Expand Up @@ -186,21 +162,13 @@ escape_html(PyObject *self, PyObject *args)
return escape_html_unicode((PyUnicodeObject*)s);
}

#if PY_MAJOR_VERSION < 3
if (PyString_CheckExact(s))
#else
if (PyBytes_CheckExact(s))
#endif
{
return escape_html_string(s);
}

if (s == Py_None) {
#if PY_MAJOR_VERSION < 3
return PyString_FromStringAndSize(NULL, 0);
#else
return PyUnicode_FromStringAndSize(NULL, 0);
#endif
}

PyErr_Format(PyExc_TypeError,
Expand All @@ -217,16 +185,6 @@ static PyMethodDef module_methods[] = {
};


#if PY_MAJOR_VERSION < 3

PyMODINIT_FUNC
initboost(void)
{
Py_InitModule("wheezy.html.boost", module_methods);
}

#else

static struct PyModuleDef module_definition = {
PyModuleDef_HEAD_INIT,
"wheezy.html.boost",
Expand All @@ -240,5 +198,3 @@ PyInit_boost(void)
{
return PyModule_Create(&module_definition);
}

#endif
26 changes: 0 additions & 26 deletions src/wheezy/html/comp.py

This file was deleted.

3 changes: 1 addition & 2 deletions src/wheezy/html/ext/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import re

from wheezy.html.comp import xrange
from wheezy.html.ext.lexer import (
InlinePreprocessor,
Preprocessor,
Expand Down Expand Up @@ -133,7 +132,7 @@ class WidgetExtension(object):


def whitespace_postprocessor(tokens):
for i in xrange(len(tokens)):
for i in range(len(tokens)):
lineno, token, value = tokens[i]
if token == "markup":
value = whitespace_preprocessor(value)
Expand Down
10 changes: 4 additions & 6 deletions src/wheezy/html/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

from datetime import date, datetime

from wheezy.html.comp import str_type


def escape_html(s):
"""Escapes a string so it is valid within HTML. Converts `None`
Expand Down Expand Up @@ -66,7 +64,7 @@ def my_formatter(value, format_spec):
>>> format_value([])
()
If format provider is unknown apply str_type.
If format provider is unknown apply str.
>>> str(format_value({}))
'{}'
Expand All @@ -87,12 +85,12 @@ def my_formatter(value, format_spec):
if formatter_name in format_providers:
format_provider = format_providers[formatter_name]
else:
return str_type(value)
return str(value)
return format_provider(value, format_spec)


def str_format_provider(value, format_spec):
return str_type(value)
return str(value)


min_date = date(1900, 1, 1)
Expand Down Expand Up @@ -138,7 +136,7 @@ def datetime_format_provider(value, format_spec=None):


format_providers = {
"str": lambda value, format_spec: html_escape(str_type(value)),
"str": lambda value, format_spec: html_escape(str(value)),
"unicode": lambda value, format_spec: html_escape(value),
"int": str_format_provider,
"Decimal": str_format_provider,
Expand Down
12 changes: 6 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[tox]
envlist = py27,py37,py38,py39,pypy3,lint,docs
envlist = py36,py37,py38,py39,pypy3,lint,docs
skipsdist = True

[testenv]
usedevelop = True
deps =
py27: -r requirements/dev-py2.txt
py37: -r requirements/dev-py3.txt
py38: -r requirements/dev-py3.txt
py39: -r requirements/dev-py3.txt
pypy3: -r requirements/dev-py3.txt
py36: -r requirements/dev.txt
py37: -r requirements/dev.txt
py38: -r requirements/dev.txt
py39: -r requirements/dev.txt
pypy3: -r requirements/dev.txt
commands =
pytest -q -x --disable-pytest-warnings --doctest-modules \
--cov-report term-missing --cov wheezy.html
Expand Down

0 comments on commit 076d4ad

Please sign in to comment.