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