Skip to content
This repository has been archived by the owner on Sep 5, 2019. It is now read-only.

Commit

Permalink
Removes Python 2.x support
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Krienbühl committed Oct 9, 2015
1 parent 2c12591 commit 102e7b9
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 50 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: python

python: "3.4"
env:
- TOXENV=py27
- TOXENV=py34
- TOXENV=pep8
install:
Expand Down
3 changes: 3 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Changelog
Unreleased
~~~~~~~~~~

- Removes Python 2.x support.
[href]

0.7.3 (2015-10-08)
~~~~~~~~~~~~~~~~~~~

Expand Down
12 changes: 0 additions & 12 deletions onegov/form/compat.py

This file was deleted.

6 changes: 2 additions & 4 deletions onegov/form/display.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

""" Contains renderers to display form fields. """

import humanize
Expand Down Expand Up @@ -111,15 +109,15 @@ 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')
class MultiCheckboxFieldRenderer(BaseRenderer):

def __call__(self, field):
return "".join(
u"✓ " + self.escape(value) + '<br>' for value in field.data
"✓ " + self.escape(value) + '<br>' for value in field.data
)[:-4]


Expand Down
2 changes: 1 addition & 1 deletion onegov/form/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion onegov/form/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
12 changes: 6 additions & 6 deletions onegov/form/parser/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
)
Expand Down
4 changes: 2 additions & 2 deletions onegov/form/parser/grammar.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from onegov.form.compat import unicode_characters
from pyparsing import (
alphanums,
Combine,
Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion onegov/form/tests/test_collection.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
5 changes: 2 additions & 3 deletions onegov/form/tests/test_display.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from datetime import datetime, time
from onegov.form import render_field

Expand Down Expand Up @@ -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<br>✓ b'
== '✓ a<br>✓ b'
2 changes: 1 addition & 1 deletion onegov/form/tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion onegov/form/tests/test_grammar.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from onegov.form.parser.grammar import (
checkbox,
date,
Expand Down
11 changes: 5 additions & 6 deletions onegov/form/tests/test_parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import pytest

from onegov.form import Form, errors
Expand Down Expand Up @@ -58,7 +57,7 @@ class Test(Form):


def test_unicode():
text = dedent(u"""
text = dedent("""
# Persönliche Informationen
Bürgerort = ___
Geschlecht =
Expand All @@ -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')
]


Expand Down
2 changes: 1 addition & 1 deletion onegov/form/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 2 additions & 3 deletions onegov/form/widgets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import humanize

from cgi import escape
Expand Down Expand Up @@ -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("""
<div class="upload-widget without-data">
{}
</div>
""".format(input_html))
else:
return HTMLString(u"""
return HTMLString("""
<div class="upload-widget with-data">
<p>{existing_file_label}: {filename} ({filesize}) ✓</p>
<ul>
Expand Down
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

from setuptools import setup, find_packages

name = 'onegov.form'
Expand Down Expand Up @@ -70,8 +68,9 @@ def get_long_description():
},
classifiers=[
'Intended Audience :: Developers',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Topic :: Software Development :: Libraries :: Python Modules',
'License :: OSI Approved :: GNU General Public License v2 (GPLv2)',
]
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py27,py34,pep8
envlist = py34,pep8

[testenv]
deps = git+git://github.com/OneGov/onegov.testing.git#egg=onegov.testing
Expand All @@ -11,7 +11,7 @@ commands = coverage run --source onegov.form -m py.test {posargs}
coverage report

[testenv:pep8]
basepython = python2
basepython = python3
deps = flake8
commands = flake8

Expand Down

0 comments on commit 102e7b9

Please sign in to comment.