diff --git a/payment_sixpay/indico_sixpay/__init__.py b/payment_sixpay/indico_sixpay/__init__.py index 592baf9..64a76f2 100644 --- a/payment_sixpay/indico_sixpay/__init__.py +++ b/payment_sixpay/indico_sixpay/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # This file is part of the SixPay Indico EPayment Plugin. # Copyright (C) 2017 - 2018 Max Fischer diff --git a/payment_sixpay/indico_sixpay/blueprint.py b/payment_sixpay/indico_sixpay/blueprint.py index 1bbae7e..b948f5d 100644 --- a/payment_sixpay/indico_sixpay/blueprint.py +++ b/payment_sixpay/indico_sixpay/blueprint.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # This file is part of the SixPay Indico EPayment Plugin. # Copyright (C) 2017 - 2018 Max Fischer @@ -17,7 +16,6 @@ # along with SixPay Indico EPayment Plugin; # if not, see . """Definition of callbacks exposed by the Indico server.""" -from __future__ import unicode_literals from indico.core.plugins import IndicoPluginBlueprint diff --git a/payment_sixpay/indico_sixpay/plugin.py b/payment_sixpay/indico_sixpay/plugin.py index 15d08c4..ed14ad5 100644 --- a/payment_sixpay/indico_sixpay/plugin.py +++ b/payment_sixpay/indico_sixpay/plugin.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # This file is part of the SixPay Indico EPayment Plugin. # Copyright (C) 2017 - 2018 Max Fischer # @@ -22,7 +21,6 @@ The entry point for indico is the :py:class:`~.SixpayPaymentPlugin`. It handles configuration via the settings forms, initiates payments and provides callbacks for finished payments via its blueprint. """ -from __future__ import absolute_import, unicode_literals import requests from urllib.parse import urljoin @@ -64,7 +62,7 @@ from .utility import (get_request_header, get_terminal_id, gettext, provider, sa # - validators: Input validation, see wtforms.validators # - description: help text of the field, an internationalised text -class FormatField(object): +class FormatField: """Validator for format fields, i.e. strings with ``{key}`` placeholders. :param max_length: optional maximum length, checked on a test formatting @@ -112,13 +110,13 @@ class FormatField(object): try: test_format = field.data.format(**self.field_map) except KeyError as err: - raise ValidationError('Invalid format string key: {}'.format(err)) + raise ValidationError(f'Invalid format string key: {err}') except ValueError as err: - raise ValidationError('Malformed format string: {}'.format(err)) + raise ValidationError(f'Malformed format string: {err}') if len(test_format) > self.max_length: raise ValidationError( 'Too long format string:' - ' shortest replacement with {0}, expected {1}' + ' shortest replacement with {}, expected {}' .format( len(test_format), self.max_length ) @@ -301,7 +299,7 @@ class SixpayPaymentPlugin(PaymentPluginMixin, IndicoPlugin): 'event_id': registration.event_id, 'event_title': registration.event.title, 'eventuser_id': - 'e{0}u{1}'.format(registration.event_id, registration.user_id), + f'e{registration.event_id}u{registration.user_id}', 'registration_title': registration.registration_form.title } diff --git a/payment_sixpay/indico_sixpay/request_handlers.py b/payment_sixpay/indico_sixpay/request_handlers.py index 37037b7..98a2786 100644 --- a/payment_sixpay/indico_sixpay/request_handlers.py +++ b/payment_sixpay/indico_sixpay/request_handlers.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # This file is part of the SixPay Indico EPayment Plugin. # Copyright (C) 2017 - 2018 Max Fischer @@ -17,7 +16,6 @@ # along with SixPay Indico EPayment Plugin; # if not, see . """Callbacks for asynchronous replies by Saferpay and to redirect the user.""" -from __future__ import unicode_literals import requests from urllib.parse import urljoin @@ -84,12 +82,12 @@ class SixPayResponseHandler(BaseRequestHandler): def __init__(self): """Initialize request handler.""" - super(SixPayResponseHandler, self).__init__() + super().__init__() # registration context is not initialised before `self._process_args` self.sixpay_url = None # type: str def _process_args(self): - super(SixPayResponseHandler, self)._process_args() + super()._process_args() self.sixpay_url = get_setting('url') def _process(self): @@ -325,7 +323,7 @@ class UserSuccessHandler(SixPayResponseHandler): self._process_confirmation() except TransactionFailure as err: current_plugin.logger.warning( - 'SixPay transaction failed during %s: %s' % ( + 'SixPay transaction failed during {}: {}'.format( err.step, err.details ) ) diff --git a/payment_sixpay/indico_sixpay/utility.py b/payment_sixpay/indico_sixpay/utility.py index cf86594..613630c 100644 --- a/payment_sixpay/indico_sixpay/utility.py +++ b/payment_sixpay/indico_sixpay/utility.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # This file is part of the SixPay Indico EPayment Plugin. # Copyright (C) 2017 - 2018 Max Fischer @@ -17,7 +16,6 @@ # along with SixPay Indico EPayment Plugin; # if not, see . """Utility functions used by the Sixpay payment plugin.""" -from __future__ import division, unicode_literals import uuid