diff --git a/.travis.yml b/.travis.yml
index ab4a6b1..f85cf57 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,6 @@
language: python
-
+python: "3.4"
env:
- - TOXENV=py27
- TOXENV=py34
- TOXENV=pep8
install:
diff --git a/HISTORY.rst b/HISTORY.rst
index c09a8f4..9020f4a 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -4,6 +4,9 @@ Changelog
Unreleased
~~~~~~~~~~
+- Removes Python 2.x support.
+ [href]
+
0.7.3 (2015-10-08)
~~~~~~~~~~~~~~~~~~~
diff --git a/onegov/form/compat.py b/onegov/form/compat.py
deleted file mode 100644
index e5a9e3d..0000000
--- a/onegov/form/compat.py
+++ /dev/null
@@ -1,12 +0,0 @@
-import sys
-
-PY3 = sys.version_info[0] == 3
-
-
-if PY3:
- unicode_characters = ''.join(
- chr(c) for c in range(65536) if not chr(c).isspace())
-else:
- # pragma: nocoverage
- unicode_characters = ''.join(
- unichr(c) for c in xrange(65536) if not unichr(c).isspace()) # noqa
diff --git a/onegov/form/display.py b/onegov/form/display.py
index 1159201..cae5d32 100644
--- a/onegov/form/display.py
+++ b/onegov/form/display.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
""" Contains renderers to display form fields. """
import humanize
@@ -111,7 +109,7 @@ def __call__(self, field):
class RadioFieldRenderer(BaseRenderer):
def __call__(self, field):
- return u"✓ " + self.escape(field.data)
+ return "✓ " + self.escape(field.data)
@registry.register_for('MultiCheckboxField')
@@ -119,7 +117,7 @@ class MultiCheckboxFieldRenderer(BaseRenderer):
def __call__(self, field):
return "".join(
- u"✓ " + self.escape(value) + '
' for value in field.data
+ "✓ " + self.escape(value) + '
' for value in field.data
)[:-4]
diff --git a/onegov/form/fields.py b/onegov/form/fields.py
index b9337ef..e2c16af 100644
--- a/onegov/form/fields.py
+++ b/onegov/form/fields.py
@@ -2,7 +2,7 @@
import gzip
import magic
-from onegov.core.compat import BytesIO
+from io import BytesIO
from onegov.form.widgets import MultiCheckboxWidget, UploadWidget
from wtforms import FileField, SelectMultipleField, widgets
diff --git a/onegov/form/models.py b/onegov/form/models.py
index 18d9d10..efddc42 100644
--- a/onegov/form/models.py
+++ b/onegov/form/models.py
@@ -176,7 +176,7 @@ def state_observer(self, state):
)
if title_fields:
- self.title = u', '.join(
+ self.title = ', '.join(
render_field(form._fields[id]) for id in title_fields
)
diff --git a/onegov/form/parser/core.py b/onegov/form/parser/core.py
index a0d4353..79bb089 100644
--- a/onegov/form/parser/core.py
+++ b/onegov/form/parser/core.py
@@ -632,24 +632,24 @@ def translate_to_yaml(text):
# the top level are the fieldsets
if match(elements.fieldset_title, line):
- yield u'- "{}":'.format(line.lstrip(u'# ').rstrip())
+ yield '- "{}":'.format(line.lstrip('# ').rstrip())
continue
# fields are nested lists of dictionaries
parse_result = try_parse(elements.single_line_fields, line)
if parse_result is not None:
- yield u'{indent}- "{identifier}": !{type} "{definition}"'.format(
+ yield '{indent}- "{identifier}": !{type} "{definition}"'.format(
indent=' ' * (4 + (len(line) - len(line.lstrip()))),
type=parse_result.type,
- identifier=line.split(u'=')[0].strip(),
- definition=line.split(u'=')[1].strip()
+ identifier=line.split('=')[0].strip(),
+ definition=line.split('=')[1].strip()
)
continue
# checkboxes/radios come without identifier
parse_result = try_parse(elements.boxes, line)
if parse_result is not None:
- yield u'{indent}- !{type} "{definition}":'.format(
+ yield '{indent}- !{type} "{definition}":'.format(
indent=' ' * (4 + (len(line) - len(line.lstrip()))),
type=parse_result.type,
definition=line.strip()
@@ -663,7 +663,7 @@ def translate_to_yaml(text):
if not line.endswith('='):
raise errors.InvalidFormSyntax(line=ix + 1)
- yield u'{indent}- "{identifier}":'.format(
+ yield '{indent}- "{identifier}":'.format(
indent=' ' * (4 + (len(line) - len(line.lstrip()))),
identifier=line.strip()
)
diff --git a/onegov/form/parser/grammar.py b/onegov/form/parser/grammar.py
index ac78a75..51eba93 100644
--- a/onegov/form/parser/grammar.py
+++ b/onegov/form/parser/grammar.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-from onegov.form.compat import unicode_characters
from pyparsing import (
alphanums,
Combine,
@@ -20,6 +18,8 @@
# we want newlines to be significant
ParserElement.setDefaultWhitespaceChars(' \t')
+unicode_characters = ''.join(
+ chr(c) for c in range(65536) if not chr(c).isspace())
text = Word(unicode_characters)
numeric = Word(nums)
diff --git a/onegov/form/tests/test_collection.py b/onegov/form/tests/test_collection.py
index 6f5d3cc..06bb49c 100644
--- a/onegov/form/tests/test_collection.py
+++ b/onegov/form/tests/test_collection.py
@@ -1,7 +1,7 @@
import pytest
from datetime import datetime, timedelta
-from onegov.core.compat import BytesIO
+from io import BytesIO
from onegov.form import (
CompleteFormSubmission,
FormCollection,
diff --git a/onegov/form/tests/test_display.py b/onegov/form/tests/test_display.py
index d53278c..02f3861 100644
--- a/onegov/form/tests/test_display.py
+++ b/onegov/form/tests/test_display.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from datetime import datetime, time
from onegov.form import render_field
@@ -36,9 +35,9 @@ def test_render_upload_field():
def test_render_radio_field():
- assert render_field(MockField('RadioField', 'selected')) == u'✓ selected'
+ assert render_field(MockField('RadioField', 'selected')) == '✓ selected'
def test_render_multi_checkbox_field():
assert render_field(MockField('MultiCheckboxField', ['a', 'b']))\
- == u'✓ a
✓ b'
+ == '✓ a
✓ b'
diff --git a/onegov/form/tests/test_fields.py b/onegov/form/tests/test_fields.py
index 0a72c60..13aa770 100644
--- a/onegov/form/tests/test_fields.py
+++ b/onegov/form/tests/test_fields.py
@@ -3,7 +3,7 @@
from cgi import FieldStorage
from gzip import GzipFile
-from onegov.core.compat import BytesIO
+from io import BytesIO
from onegov.form import Form
from onegov.form.fields import UploadField
diff --git a/onegov/form/tests/test_grammar.py b/onegov/form/tests/test_grammar.py
index 0b98b63..222cd51 100644
--- a/onegov/form/tests/test_grammar.py
+++ b/onegov/form/tests/test_grammar.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from onegov.form.parser.grammar import (
checkbox,
date,
diff --git a/onegov/form/tests/test_parser.py b/onegov/form/tests/test_parser.py
index 1dce107..3ed33b8 100644
--- a/onegov/form/tests/test_parser.py
+++ b/onegov/form/tests/test_parser.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import pytest
from onegov.form import Form, errors
@@ -58,7 +57,7 @@ class Test(Form):
def test_unicode():
- text = dedent(u"""
+ text = dedent("""
# Persönliche Informationen
Bürgerort = ___
Geschlecht =
@@ -68,11 +67,11 @@ def test_unicode():
form = parse_form(text)()
- assert form.personliche_informationen_burgerort.label.text == u'Bürgerort'
- assert u'Persönliche Informationen' == form.fieldsets[0].label
+ assert form.personliche_informationen_burgerort.label.text == 'Bürgerort'
+ assert 'Persönliche Informationen' == form.fieldsets[0].label
assert form.personliche_informationen_geschlecht.choices == [
- (u'Männlich', u'Männlich'),
- (u'Weiblich', u'Weiblich')
+ ('Männlich', 'Männlich'),
+ ('Weiblich', 'Weiblich')
]
diff --git a/onegov/form/validators.py b/onegov/form/validators.py
index e95dfdb..d282de0 100644
--- a/onegov/form/validators.py
+++ b/onegov/form/validators.py
@@ -28,7 +28,7 @@ def __call__(self, form, field):
try:
self.format.validate(field.data)
except StdnumValidationError:
- raise ValidationError(field.gettext(u'Invalid input.'))
+ raise ValidationError(field.gettext('Invalid input.'))
class FileSizeLimit(object):
diff --git a/onegov/form/widgets.py b/onegov/form/widgets.py
index 673d9e5..1a2b497 100644
--- a/onegov/form/widgets.py
+++ b/onegov/form/widgets.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
import humanize
from cgi import escape
@@ -31,13 +30,13 @@ def __call__(self, field, **kwargs):
input_html = super(UploadWidget, self).__call__(field, **kwargs)
if force_simple or not field.data:
- return HTMLString(u"""
+ return HTMLString("""