Projet

Général

Profil

0001-misc-remove-usage-of-six-module-64409.patch

Thomas Noël, 21 avril 2022 10:29

Télécharger (7,61 ko)

Voir les différences:

Subject: [PATCH 1/3] misc: remove usage of "six" module (#64409)

 passerelle_minint/minint_maarch/soap.py  |  2 +-
 passerelle_minint/minint_maarch/views.py | 23 +++++++++++------------
 passerelle_minint/minint_seisin/soap.py  |  2 +-
 tests/conftest.py                        |  4 ----
 tests/utils.py                           |  4 ++--
 5 files changed, 15 insertions(+), 20 deletions(-)
passerelle_minint/minint_maarch/soap.py
17 17
# borrowed from https://pypi.python.org/pypi/suds_requests
18 18
# and https://docs.oracle.com/cd/E50245_01/E50253/html/vmprg-soap-example-authentication-python.html
19 19

  
20
from io import BytesIO
20 21
import requests
21 22

  
22 23
from django.conf import settings
23
from django.utils.six import BytesIO
24 24
from suds.transport.http import HttpAuthenticated
25 25
from suds.transport import Reply
26 26
from suds.client import Client
passerelle_minint/minint_maarch/views.py
19 19
import logging
20 20
import re
21 21
import requests
22
import urllib.parse
22 23

  
23 24
from django.views.generic import DetailView as GenericDetailView
24
from django.utils import six
25 25
from django.utils.decorators import method_decorator
26 26
from django.utils.encoding import force_text
27
from django.utils.six.moves.urllib import parse as urlparse
28 27
from django.views.decorators.csrf import csrf_exempt
29 28

  
30 29
from passerelle.compat import json_loads
......
96 95

  
97 96
        # get formdef schema from wcs API
98 97
        url = formdata['url']
99
        p = urlparse.urlsplit(url)
98
        p = urllib.parse.urlsplit(url)
100 99
        scheme, netloc, path, query, fragment = \
101 100
            p.scheme, p.netloc, p.path, p.query, p.fragment
102 101
        schema_path = path.rsplit('/', 2)[0] + '/schema'
103
        schema_url = urlparse.urlunsplit((scheme, netloc, schema_path, query, fragment))
102
        schema_url = urllib.parse.urlunsplit((scheme, netloc, schema_path, query, fragment))
104 103
        schema = requests.get(schema_url).json()
105 104

  
106 105
        # storeAttachmentResource attachments: list, build from formdata file fields
......
204 203
                    data.type = 'date'
205 204
                    value = datetime.strptime(value[:19], '%Y-%m-%dT%H:%M:%S')
206 205
                    value = value.strftime('%d-%m-%Y %H:%M:%S')
207
                elif isinstance(value, six.string_types):
206
                elif isinstance(value, str):
208 207
                    data.type = 'string'
209 208
                elif isinstance(value, int):
210 209
                    data.type = 'integer'
......
233 232
                    data.type = 'date'
234 233
                    value = datetime.strptime(value[:19], '%Y-%m-%dT%H:%M:%S')
235 234
                    value = value.strftime('%d-%m-%Y %H:%M:%S')
236
                elif isinstance(value, six.string_types):
235
                elif isinstance(value, str):
237 236
                    data.type = 'string'
238 237
                elif isinstance(value, int):
239 238
                    data.type = 'int'
......
393 392

  
394 393
        # get formdef schema from wcs API
395 394
        url = formdata['url']
396
        p = urlparse.urlsplit(url)
395
        p = urllib.parse.urlsplit(url)
397 396
        scheme, netloc, path, query, fragment = \
398 397
            p.scheme, p.netloc, p.path, p.query, p.fragment
399 398
        schema_path = path.rsplit('/', 2)[0] + '/schema'
400
        schema_url = urlparse.urlunsplit((scheme, netloc, schema_path, query, fragment))
399
        schema_url = urllib.parse.urlunsplit((scheme, netloc, schema_path, query, fragment))
401 400
        schema = requests.get(schema_url).json()
402 401

  
403 402
        regexp_filename_search_pattern_in_label, filename_result_pattern = self.prepare_regexp_filename_replacement(extras)
......
494 493

  
495 494
        # get formdef schema from wcs API
496 495
        url = formdata['url']
497
        p = urlparse.urlsplit(url)
496
        p = urllib.parse.urlsplit(url)
498 497
        scheme, netloc, path, query, fragment = \
499 498
            p.scheme, p.netloc, p.path, p.query, p.fragment
500 499
        schema_path = path.rsplit('/', 2)[0] + '/schema'
501
        schema_url = urlparse.urlunsplit((scheme, netloc, schema_path, query, fragment))
500
        schema_url = urllib.parse.urlunsplit((scheme, netloc, schema_path, query, fragment))
502 501
        schema = requests.get(schema_url).json()
503 502

  
504 503
        # storeAttachmentResource attachments: list, build from formdata file fields
......
608 607
                    data.type = 'date'
609 608
                    value = datetime.strptime(value[:19], '%Y-%m-%dT%H:%M:%S')
610 609
                    value = value.strftime('%d-%m-%Y %H:%M:%S')
611
                elif isinstance(value, six.string_types):
610
                elif isinstance(value, str):
612 611
                    data.type = 'string'
613 612
                elif isinstance(value, int):
614 613
                    data.type = 'integer'
......
637 636
                    data.type = 'date'
638 637
                    value = datetime.strptime(value[:19], '%Y-%m-%dT%H:%M:%S')
639 638
                    value = value.strftime('%d-%m-%Y %H:%M:%S')
640
                elif isinstance(value, six.string_types):
639
                elif isinstance(value, str):
641 640
                    data.type = 'string'
642 641
                elif isinstance(value, int):
643 642
                    data.type = 'int'
passerelle_minint/minint_seisin/soap.py
17 17
# borrowed from https://pypi.python.org/pypi/suds_requests
18 18
# and https://docs.oracle.com/cd/E50245_01/E50253/html/vmprg-soap-example-authentication-python.html
19 19

  
20
from io import BytesIO
20 21
import requests
21 22

  
22 23
from django.conf import settings
23
from django.utils.six import BytesIO
24 24
from suds.transport.http import HttpAuthenticated
25 25
from suds.transport import Reply
26 26
from suds.client import Client
tests/conftest.py
5 5

  
6 6
from django.core.files import File
7 7
from django.core.cache import cache
8
from django.utils import six
9 8
from io import BytesIO
10 9

  
11 10
from utils import make_resource
12 11

  
13
if six.PY2:
14
    collect_ignore = ['wcs/']
15

  
16 12

  
17 13
@pytest.fixture(autouse=True)
18 14
def media(settings, tmpdir):
tests/utils.py
2 2

  
3 3
import mock
4 4
import httmock
5
import urllib.parse
5 6

  
6 7
from django.contrib.contenttypes.models import ContentType
7 8
from django.urls import reverse
8
from django.utils.six.moves.urllib import parse as urlparse
9 9

  
10 10
from passerelle.base.models import ApiUser, AccessRight
11 11
from passerelle.compat import json_loads
......
35 35
def mock_url(url=None, response='', status_code=200, headers=None):
36 36
    urlmatch_kwargs = {}
37 37
    if url:
38
        parsed = urlparse.urlparse(url)
38
        parsed = urllib.parse.urlparse(url)
39 39
        if parsed.netloc:
40 40
            urlmatch_kwargs['netloc'] = parsed.netloc
41 41
        if parsed.path:
42
-