dj32: remove use of six (#74843)
This commit is contained in:
parent
2d64de0493
commit
4d2e935fd0
1
setup.py
1
setup.py
|
@ -110,7 +110,6 @@ setup(
|
|||
'isodate',
|
||||
'jsonschema',
|
||||
'gadjo',
|
||||
'six',
|
||||
'djangorestframework>=3.9,<3.13',
|
||||
'pytz',
|
||||
'python-dateutil',
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import io
|
||||
import mock
|
||||
import pytest
|
||||
import sys
|
||||
|
@ -9,12 +10,11 @@ from zoo.zoo_nanterre import utils
|
|||
|
||||
from django.core.management import call_command
|
||||
from django.db.transaction import atomic
|
||||
from django.utils.six import StringIO
|
||||
|
||||
|
||||
def get_output_of_command(command, *args, **kwargs):
|
||||
old_stdout = sys.stdout
|
||||
output = sys.stdout = StringIO()
|
||||
output = sys.stdout = io.StringIO()
|
||||
call_command(command, *args, **kwargs)
|
||||
sys.stdout = old_stdout
|
||||
return output.getvalue()
|
||||
|
|
|
@ -5,6 +5,7 @@ import datetime
|
|||
import isodate
|
||||
import requests
|
||||
import threading
|
||||
import urllib.parse
|
||||
|
||||
import pytest
|
||||
import httmock
|
||||
|
@ -12,7 +13,6 @@ import httmock
|
|||
from django.urls import reverse
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.http import urlencode
|
||||
from django.utils.six.moves.urllib import parse as urlparse
|
||||
from django.utils.timezone import now
|
||||
|
||||
from zoo.zoo_data.models import Entity, Relation, Log, Job
|
||||
|
@ -693,9 +693,9 @@ def test_create_individu(settings, transactional_db, app, app_noauth, rsu_schema
|
|||
more = response.json.get('more')
|
||||
if more:
|
||||
assert 'cookie' in response.json
|
||||
parsed = urlparse.urlparse(response.json['more'])
|
||||
parsed = urllib.parse.urlparse(response.json['more'])
|
||||
query = parsed.query
|
||||
assert urlparse.parse_qs(query)['cookie'] == [response.json['cookie']]
|
||||
assert urllib.parse.parse_qs(query)['cookie'] == [response.json['cookie']]
|
||||
assert sorted(d['id'] for d in all_data) == sorted(qs.values_list('id', flat=True))
|
||||
assert count == qs.count()
|
||||
assert 'more' not in response.json
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import copy
|
||||
import urllib
|
||||
|
||||
from django.urls import reverse
|
||||
from django.core.management import call_command
|
||||
from django.utils.six.moves.urllib import parse as urlparse
|
||||
|
||||
from zoo.zoo_nanterre.models import Duplicate
|
||||
from zoo.zoo_data.models import Log, Entity
|
||||
|
@ -43,8 +43,8 @@ def test_list_doublons(nanterre_classic_family, app):
|
|||
assert response.json['err'] == 0
|
||||
assert 'more' in response.json
|
||||
assert 'cookie' in response.json
|
||||
assert response.json['cookie'] == urlparse.parse_qs(
|
||||
urlparse.urlparse(
|
||||
assert response.json['cookie'] == urllib.parse.parse_qs(
|
||||
urllib.parse.urlparse(
|
||||
response.json['more']).query)['cookie'][0]
|
||||
assert len(response.json['data']) >= 10
|
||||
assert response.json['data'][0]['id'] == d.id
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import csv
|
||||
import io
|
||||
|
||||
from django.utils import six
|
||||
from django.utils.encoding import force_bytes
|
||||
from django.utils.six import StringIO
|
||||
|
||||
from webtest import Upload
|
||||
|
||||
|
@ -33,12 +32,8 @@ def test_synchronize_federations(settings, app, nanterre_classic_family, admin):
|
|||
response = response.click('Rapport')
|
||||
|
||||
def check_csv_response(csv_response):
|
||||
if six.PY3:
|
||||
reader = csv.DictReader(StringIO(csv_response.text))
|
||||
reader.fieldnames = reader.reader.__next__()
|
||||
else:
|
||||
reader = csv.DictReader(StringIO(csv_response.content))
|
||||
reader.fieldnames = reader.reader.next()
|
||||
reader = csv.DictReader(io.StringIO(csv_response.text))
|
||||
reader.fieldnames = reader.reader.__next__()
|
||||
rows = list(reader)
|
||||
|
||||
def rows_by_action(action):
|
||||
|
|
|
@ -856,4 +856,4 @@ c&&c.destroy(),
|
|||
c=new f(this.get(0),a),this.data("jsoneditor",c),
|
||||
// Setup event listeners
|
||||
c.on("change",function(){b.trigger("change")}),c.on("ready",function(){b.trigger("ready")}))}return this}}}(),window.JSONEditor=f}();
|
||||
//# sourceMappingURL=jsoneditor.min.js.map
|
||||
//# sourceMappingURL=jsoneditor.min.js.map
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import datetime
|
||||
import decimal
|
||||
import urllib.parse
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils import six, timezone
|
||||
from django.utils.six.moves.urllib import parse as urlparse
|
||||
from django.utils import timezone
|
||||
|
||||
import requests
|
||||
|
||||
|
@ -36,13 +36,13 @@ class Saga(object):
|
|||
|
||||
@property
|
||||
def creance_url(self):
|
||||
return urlparse.urljoin(
|
||||
return urllib.parse.urljoin(
|
||||
self.url,
|
||||
'/%s/services/etat_facture_creance_literal' % self.base_uri)
|
||||
|
||||
@property
|
||||
def paiement_url(self):
|
||||
return urlparse.urljoin(
|
||||
return urllib.parse.urljoin(
|
||||
self.url,
|
||||
'/%s/services/paiement_internet_ws_literal' % self.base_uri)
|
||||
|
||||
|
@ -194,7 +194,7 @@ class Saga(object):
|
|||
<urlretour_synchrone>{urlretour_synchrone}</urlretour_synchrone>
|
||||
</Transaction>'''
|
||||
assert factures, u'factures ne doit pas être vide'
|
||||
id_facture = u'--'.join(six.text_type(facture.num) for facture in factures)
|
||||
id_facture = u'--'.join(str(facture.num) for facture in factures)
|
||||
montant = sum(facture.reste_a_payer for facture in factures)
|
||||
tree, error = self.soap_call(
|
||||
self.paiement_url, body, 'TransactionReturn',
|
||||
|
|
|
@ -17,15 +17,14 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import csv
|
||||
import io
|
||||
|
||||
from django.core.files.storage import default_storage
|
||||
from django.urls import reverse
|
||||
from django.conf import settings
|
||||
from django.db import DatabaseError
|
||||
from django.db.transaction import atomic
|
||||
from django.utils import six
|
||||
from django.utils.encoding import force_bytes
|
||||
from django.utils.six import StringIO
|
||||
|
||||
from zoo.zoo_meta.models import EntitySchema
|
||||
from zoo.zoo_data.models import Job, Entity, Transaction, Log
|
||||
|
@ -106,15 +105,12 @@ class SynchronizeFederationsImport(object):
|
|||
self.report('report')
|
||||
|
||||
def report(self, target):
|
||||
output_file = StringIO()
|
||||
output_file = io.StringIO()
|
||||
writer = csv.writer(output_file)
|
||||
writer.writerow(['RSU ID', 'prenoms', 'nom de naissance',
|
||||
'nom d\'usage', 'application', 'federation', 'action'])
|
||||
for action in self.actions:
|
||||
if six.PY3:
|
||||
action = [v for v in action]
|
||||
else:
|
||||
action = [force_bytes(v) for v in action]
|
||||
action = [v for v in action]
|
||||
writer.writerow(action)
|
||||
setattr(self.action, target + '_csv_filename',
|
||||
self.action.csv_filename + '-report.csv')
|
||||
|
|
|
@ -44,7 +44,6 @@ from django.db import transaction
|
|||
from django.contrib.auth.hashers import make_password
|
||||
from django.http import HttpResponse
|
||||
|
||||
from django.utils import six
|
||||
from django.utils.timezone import now, make_aware
|
||||
from django.utils.encoding import force_bytes
|
||||
|
||||
|
@ -653,7 +652,7 @@ def integrity_check():
|
|||
def upper_dict(d):
|
||||
'''Transform all string values in d to uppercase'''
|
||||
for key, value in d.items():
|
||||
if isinstance(value, six.text_type):
|
||||
if isinstance(value, str):
|
||||
d[key] = value.upper()
|
||||
|
||||
|
||||
|
@ -1283,18 +1282,11 @@ def individu_caption(individu):
|
|||
|
||||
|
||||
def csv_export_response(rows, filename):
|
||||
if six.PY3:
|
||||
with io.StringIO(newline='') as f:
|
||||
writer = csv.writer(f)
|
||||
for row in rows:
|
||||
writer.writerow(map(str, row))
|
||||
r = HttpResponse(f.getvalue(), content_type='text/csv')
|
||||
else:
|
||||
with io.BytesIO() as f:
|
||||
writer = csv.writer(f)
|
||||
for row in rows:
|
||||
writer.writerow(map(force_bytes, row))
|
||||
r = HttpResponse(f.getvalue(), content_type='text/csv')
|
||||
with io.StringIO(newline='') as f:
|
||||
writer = csv.writer(f)
|
||||
for row in rows:
|
||||
writer.writerow(map(str, row))
|
||||
r = HttpResponse(f.getvalue(), content_type='text/csv')
|
||||
r['Content-Disposition'] = 'attachment; filename="%s"' % filename
|
||||
return r
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ from django.db import connection
|
|||
from django.conf import settings
|
||||
from django.core.cache import cache
|
||||
from django.utils.timezone import now
|
||||
from django.utils import six
|
||||
|
||||
from django.contrib.auth.decorators import permission_required
|
||||
from django.contrib import messages
|
||||
|
@ -117,9 +116,7 @@ def synchronize_federations_report(request, job_id, model_admin, *args, **kwargs
|
|||
if not report:
|
||||
raise Http404('no report')
|
||||
with report:
|
||||
text_report = report
|
||||
if six.PY3:
|
||||
text_report = io.TextIOWrapper(text_report, encoding='utf-8')
|
||||
text_report = io.TextIOWrapper(report, encoding='utf-8')
|
||||
reader = csv.reader(text_report)
|
||||
next(reader)
|
||||
actions = [row for row in reader if row[6] != 'KEEP']
|
||||
|
@ -152,9 +149,7 @@ def synchronize_federations_apply_report(request, job_id, model_admin, *args, **
|
|||
with report:
|
||||
if not report:
|
||||
raise Http404('no report')
|
||||
text_report = report
|
||||
if six.PY3:
|
||||
text_report = io.TextIOWrapper(text_report, encoding='utf-8')
|
||||
text_report = io.TextIOWrapper(report, encoding='utf-8')
|
||||
reader = csv.reader(text_report)
|
||||
next(reader)
|
||||
actions = [row for row in reader if row[6] != 'KEEP']
|
||||
|
|
Loading…
Reference in New Issue