Projet

Général

Profil

0001-trivial-apply-isort-pyupgrade-60931.patch

Paul Marillonnet, 21 janvier 2022 13:10

Télécharger (9,06 ko)

Voir les différences:

Subject: [PATCH 1/2] trivial: apply isort & pyupgrade (#60931)

 setup.py                                     | 12 ++++++------
 src/authentic2_auth_fedict/__init__.py       |  4 ++--
 src/authentic2_auth_fedict/adapters.py       | 15 ++++++---------
 src/authentic2_auth_fedict/app_settings.py   |  2 +-
 src/authentic2_auth_fedict/authenticators.py |  6 ++----
 src/authentic2_auth_fedict/fields.py         | 14 ++++++--------
 src/authentic2_auth_fedict/urls.py           |  2 +-
 src/authentic2_auth_fedict/views.py          |  6 +++---
 8 files changed, 27 insertions(+), 34 deletions(-)
setup.py
1 1
#!/usr/bin/python
2
import sys
3 2
import os
4 3
import subprocess
5

  
6
from setuptools import setup, find_packages
7
from setuptools.command.install_lib import install_lib as _install_lib
4
import sys
5
from distutils.cmd import Command
8 6
from distutils.command.build import build as _build
9 7
from distutils.command.sdist import sdist
10
from distutils.cmd import Command
8

  
9
from setuptools import find_packages, setup
10
from setuptools.command.install_lib import install_lib as _install_lib
11 11

  
12 12

  
13 13
class compile_translations(Command):
......
60 60

  
61 61
def get_version():
62 62
    if os.path.exists('VERSION'):
63
        with open('VERSION', 'r') as v:
63
        with open('VERSION') as v:
64 64
            return v.read()
65 65
    if os.path.exists('.git'):
66 66
        p = subprocess.Popen(
src/authentic2_auth_fedict/__init__.py
17 17
import json
18 18

  
19 19
import django.apps
20
from django.utils.translation import ugettext_lazy as _
21 20
from django.contrib.auth.signals import user_logged_in
21
from django.utils.translation import ugettext_lazy as _
22 22

  
23 23

  
24 24
class AppConfig(django.apps.AppConfig):
......
39 39
default_app_config = 'authentic2_auth_fedict.AppConfig'
40 40

  
41 41

  
42
class Plugin(object):
42
class Plugin:
43 43
    def get_before_urls(self):
44 44
        from . import urls
45 45

  
src/authentic2_auth_fedict/adapters.py
20 20
import os
21 21
import time
22 22

  
23
import lasso
24
import mellon.utils as mellon_utils
23 25
import requests
24

  
26
from authentic2.a2_rbac.utils import get_default_ou
27
from authentic2.models import Attribute
25 28
from django.conf import settings
26 29
from django.contrib.auth import get_user_model
27 30
from django.core.files.storage import default_storage
28 31
from django.utils.encoding import force_bytes, force_text
29

  
30
import lasso
31

  
32 32
from mellon.adapters import DefaultAdapter, app_settings
33
import mellon.utils as mellon_utils
34
from authentic2.models import Attribute
35
from authentic2.a2_rbac.utils import get_default_ou
36 33

  
37 34
try:
38 35
    import authentic2.utils.misc as a2_utils_misc
......
95 92
        saml_attributes['name_id_content_orig'] = saml_attributes['name_id_content']
96 93
        saml_attributes['name_id_content'] = saml_attributes['urn:be:fedict:iam:attr:fedid'][0]
97 94
        saml_attributes['name_id_format'] = lasso.SAML2_NAME_IDENTIFIER_FORMAT_UNSPECIFIED
98
        user = super(AuthenticAdapter, self).lookup_user(idp, saml_attributes)
95
        user = super().lookup_user(idp, saml_attributes)
99 96
        if not user.ou_id:
100 97
            user.ou = get_default_ou()
101 98
            user.save()
......
164 161
                pass
165 162

  
166 163
    def provision_attribute(self, user, idp, saml_attributes):
167
        super(AuthenticAdapter, self).provision_attribute(user, idp, saml_attributes)
164
        super().provision_attribute(user, idp, saml_attributes)
168 165
        if not user.email:
169 166
            # make sure the account is not usable for now
170 167
            user.is_active = False
src/authentic2_auth_fedict/app_settings.py
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17

  
18
class AppSettings(object):
18
class AppSettings:
19 19
    '''Thanks django-allauth'''
20 20

  
21 21
    __SENTINEL = object()
src/authentic2_auth_fedict/authenticators.py
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
from django.template.loader import render_to_string
17
from authentic2.authenticators import BaseAuthenticator
18 18
from django.shortcuts import render
19
from django.template.loader import render_to_string
19 20
from django.utils.translation import ugettext_lazy as _
20

  
21 21
from mellon.utils import get_idp, get_idps
22 22

  
23
from authentic2.authenticators import BaseAuthenticator
24

  
25 23
try:
26 24
    from authentic2.utils import redirect_to_login
27 25
except ImportError:
src/authentic2_auth_fedict/fields.py
1
# -*- coding: utf-8 -*-
2 1
# authentic2_auth_fedict - Fedict authentication for Authentic
3 2
# Copyright (C) 2016  Entr'ouvert
4 3
#
......
16 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 16

  
18 17
import re
19
import requests
20 18
import time
21 19
from urllib.parse import urljoin
22 20

  
21
import requests
23 22
from django import forms
24 23
from django.conf import settings
25 24
from django.utils.translation import ugettext_lazy as _
26

  
27 25
from gadjo.templatetags.gadjo import xstatic
28 26

  
29 27

  
30 28
class NrnField(forms.CharField):
31 29
    def validate(self, value):
32
        super(NrnField, self).validate(value)
30
        super().validate(value)
33 31
        if not value:
34 32
            return
35 33
        try:
......
62 60
    widget = DateWidget
63 61

  
64 62
    def validate(self, value):
65
        super(DateField, self).validate(value)
63
        super().validate(value)
66 64
        if not value:
67 65
            return
68 66
        for format_string in ('%d/%m/%Y', '%Y-%m-%d'):
......
133 131

  
134 132
class NumHouseField(forms.CharField):
135 133
    def validate(self, value):
136
        super(NumHouseField, self).validate(value)
134
        super().validate(value)
137 135
        if not value:
138 136
            return
139 137
        try:
......
145 143

  
146 144
class NumPhoneField(forms.CharField):
147 145
    def validate(self, value):
148
        super(NumPhoneField, self).validate(value)
146
        super().validate(value)
149 147
        if not value:
150 148
            return
151 149
        try:
152
            if not re.match("^(0|\\+|00)(\d{8,})", value):
150
            if not re.match("^(0|\\+|00)(\\d{8,})", value):
153 151
                raise ValueError()
154 152
        except ValueError:
155 153
            raise forms.ValidationError(getattr(settings, 'A2_NUMPHONE_ERROR_MESSAGE', _('Invalid format')))
src/authentic2_auth_fedict/urls.py
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
from django.conf.urls import url, include
17
from django.conf.urls import include, url
18 18

  
19 19
from . import views
20 20

  
src/authentic2_auth_fedict/views.py
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
import urllib.parse
18 17
import random
18
import urllib.parse
19 19

  
20 20
from django.conf import settings
21 21
from django.core import signing
22
from django.urls import reverse
23 22
from django.db import transaction
24 23
from django.http import HttpResponseRedirect
25 24
from django.shortcuts import resolve_url
25
from django.urls import reverse
26 26
from django.views.decorators.csrf import csrf_exempt
27 27
from django.views.generic import View
28 28

  
......
65 65
            return HttpResponseRedirect(a2_utils_misc.build_activation_url(request, **data))
66 66
        user.is_active = True
67 67
        user.save()
68
        return super(LoginView, self).authenticate(request, login, attributes)
68
        return super().authenticate(request, login, attributes)
69 69

  
70 70

  
71 71
login = transaction.non_atomic_requests(csrf_exempt(LoginView.as_view()))
72
-