Skip to content

Commit f481f5c

Browse files
committed
Replaced use of six with the equivalent pure python3 constructs.
- Legacy-Id: 16428
1 parent 671b403 commit f481f5c

File tree

16 files changed

+24
-55
lines changed

16 files changed

+24
-55
lines changed

ietf/api/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Copyright The IETF Trust 2014-2019, All Rights Reserved
22
import re
3-
import six
43
import datetime
54
from urllib.parse import urlencode
65

@@ -76,7 +75,7 @@ def convert(self, value):
7675
if value is None:
7776
return None
7877

79-
if isinstance(value, six.string_types):
78+
if isinstance(value, str):
8079
match = TIMEDELTA_REGEX.search(value)
8180

8281
if match:
@@ -91,7 +90,7 @@ def hydrate(self, bundle):
9190
value = super(TimedeltaField, self).hydrate(bundle)
9291

9392
if value and not hasattr(value, 'seconds'):
94-
if isinstance(value, six.string_types):
93+
if isinstance(value, str):
9594
try:
9695
match = TIMEDELTA_REGEX.search(value)
9796

@@ -117,7 +116,7 @@ def dehydrate(self, bundle, for_list=True):
117116
if callable(self.attribute):
118117
previous_obj = bundle.obj
119118
foreign_obj = self.attribute(bundle)
120-
elif isinstance(self.attribute, six.string_types):
119+
elif isinstance(self.attribute, str):
121120
foreign_obj = bundle.obj
122121

123122
for attr in self._attrs:

ietf/doc/models.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import logging
66
import os
77
import rfc2html
8-
import six
98

109
from django.db import models
1110
from django.core import checks
@@ -430,7 +429,7 @@ def all_relations_that(self, relationship, related=None):
430429

431430
def relations_that_doc(self, relationship):
432431
"""Return the related-document objects that describe a given relationship from self to other documents."""
433-
if isinstance(relationship, six.string_types):
432+
if isinstance(relationship, str):
434433
relationship = ( relationship, )
435434
if not isinstance(relationship, tuple):
436435
raise TypeError("Expected a string or tuple, received %s" % type(relationship))

ietf/group/tests_info.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import datetime
88
import io
99
import bleach
10-
import six
1110

1211
from pyquery import PyQuery
1312
from tempfile import NamedTemporaryFile

ietf/liaisons/forms.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import datetime, os
55
import operator
6-
import six
76
from email.utils import parseaddr
87
from form_utils.forms import BetterModelForm
98

@@ -199,7 +198,7 @@ def prepare_value(self, value):
199198
if isinstance(value, QuerySet):
200199
return value
201200
if (hasattr(value, '__iter__') and
202-
not isinstance(value, six.text_type) and
201+
not isinstance(value, str) and
203202
not hasattr(value, '_meta')):
204203
return [super(CustomModelMultipleChoiceField, self).prepare_value(v) for v in value]
205204
return super(CustomModelMultipleChoiceField, self).prepare_value(value)

ietf/person/fields.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Copyright The IETF Trust 2012-2019, All Rights Reserved
22
import json
3-
import six
43

54
from collections import Counter
65
from urllib.parse import urlencode
@@ -110,7 +109,7 @@ def clean(self, value):
110109
#if self.only_users:
111110
# objs = objs.exclude(person__user=None)
112111

113-
found_pks = [ six.text_type(o.pk) for o in objs]
112+
found_pks = [ str(o.pk) for o in objs]
114113
failed_pks = [x for x in pks if x not in found_pks]
115114
if failed_pks:
116115
raise forms.ValidationError("Could not recognize the following {model_name}s: {pks}. You can only input {model_name}s already registered in the Datatracker.".format(pks=", ".join(failed_pks), model_name=self.model.__name__.lower()))

ietf/person/models.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import datetime
44
import email.utils
55
import email.header
6-
import six
76
import uuid
87

98
from hashids import Hashids
@@ -360,7 +359,7 @@ def hash(self):
360359
for v in (str(self.id), str(self.person.id), self.created.isoformat(), self.endpoint, str(self.valid), self.salt, settings.SECRET_KEY):
361360
v = smart_bytes(v)
362361
hash.update(v)
363-
key = struct.pack(KEY_STRUCT, self.id, six.binary_type(self.salt), hash.digest())
362+
key = struct.pack(KEY_STRUCT, self.id, bytes(self.salt), hash.digest())
364363
self._cached_hash = base64.urlsafe_b64encode(key).decode('ascii')
365364
return self._cached_hash
366365

ietf/stats/backfill_data.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import os
88
import os.path
99
import argparse
10-
import six
1110
import time
1211

1312
basedir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
@@ -129,10 +128,10 @@ def str(text):
129128
# it's an extra author - skip those extra authors
130129
seen = set()
131130
for full, _, _, _, _, email, country, company in d.get_author_list():
132-
assert full is None or isinstance(full, six.text_type)
133-
assert email is None or isinstance(email, six.text_type)
134-
assert country is None or isinstance(country, six.text_type)
135-
assert company is None or isinstance(company, six.text_type)
131+
assert full is None or isinstance(full, str)
132+
assert email is None or isinstance(email, str)
133+
assert country is None or isinstance(country, str)
134+
assert company is None or isinstance(company, str)
136135
#full, email, country, company = [ unicode(s) for s in [full, email, country, company, ] ]
137136
if email in seen:
138137
continue

ietf/submit/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import datetime
55
import os
66
import re
7-
import six # pyflakes:ignore
87
import xml2rfc
98

109
from django.conf import settings
@@ -457,7 +456,7 @@ def ensure_person_email_info_exists(name, email, docname):
457456
person = Person()
458457
person.name = name
459458
person.name_from_draft = name
460-
log.assertion('isinstance(person.name, six.text_type)')
459+
log.assertion('isinstance(person.name, str)')
461460
person.ascii = unidecode_name(person.name)
462461
person.save()
463462
else:

ietf/utils/draft.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import os.path
4141
import re
4242
import stat
43-
import six
4443
import sys
4544
import time
4645

@@ -129,7 +128,7 @@ def acronym_match(s, l):
129128
class Draft():
130129

131130
def __init__(self, text, source, name_from_source=False):
132-
assert isinstance(text, six.text_type)
131+
assert isinstance(text, str)
133132
self.source = source
134133
self.rawtext = text
135134
self.name_from_source = name_from_source

ietf/utils/fields.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Copyright The IETF Trust 2012-2019, All Rights Reserved
22

33
import re
4-
import six
54
import datetime
65

76
import debug # pyflakes:ignore
@@ -104,7 +103,7 @@ def parse_duration_ext(value):
104103
return parse_duration(value)
105104
else:
106105
kw = match.groupdict()
107-
kw = {k: float(v) for k, v in six.iteritems(kw) if v is not None}
106+
kw = {k: float(v) for k, v in kw.items() if v is not None}
108107
return datetime.timedelta(**kw)
109108

110109
class DurationField(forms.DurationField):

0 commit comments

Comments
 (0)