From 1c808bf63ba1415cb3f5f303415550ea46fb948b Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Thu, 5 Mar 2020 15:54:32 +0000 Subject: [PATCH] Removed further six usage. - Legacy-Id: 17387 --- ietf/group/models.py | 2 +- ietf/mailtrigger/forms.py | 3 ++- ietf/utils/draft.py | 5 ++--- ietf/utils/markup_txt.py | 1 - ietf/utils/test_smtpserver.py | 19 ++++++------------- ietf/utils/tests_restapi.py | 5 ++--- ietf/utils/text.py | 5 ++--- ietf/utils/urls.py | 8 ++++---- 8 files changed, 19 insertions(+), 29 deletions(-) diff --git a/ietf/group/models.py b/ietf/group/models.py index 833b2c68a..09820841a 100644 --- a/ietf/group/models.py +++ b/ietf/group/models.py @@ -96,7 +96,7 @@ class Group(GroupInfo): return e[0] if e else None def has_role(self, user, role_names): - if isinstance(role_names, str): + if not isinstance(role_names, (list, tuple)): role_names = [role_names] return user.is_authenticated and self.role_set.filter(name__in=role_names, person__user=user).exists() diff --git a/ietf/mailtrigger/forms.py b/ietf/mailtrigger/forms.py index 9fad2b85c..7cc08156f 100644 --- a/ietf/mailtrigger/forms.py +++ b/ietf/mailtrigger/forms.py @@ -1,8 +1,9 @@ # Copyright The IETF Trust 2015-2020, All Rights Reserved # -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals + from typing import Dict, List # pyflakes:ignore from django import forms diff --git a/ietf/utils/draft.py b/ietf/utils/draft.py index d19e671b1..cc0b77985 100755 --- a/ietf/utils/draft.py +++ b/ietf/utils/draft.py @@ -45,12 +45,11 @@ import io import os import os.path import re -import six import stat import sys import time -if six.PY3: - from typing import Dict, List # pyflakes:ignore + +from typing import Dict, List # pyflakes:ignore version = "0.35" program = os.path.basename(sys.argv[0]) diff --git a/ietf/utils/markup_txt.py b/ietf/utils/markup_txt.py index b45f7b75b..fe5fc7600 100644 --- a/ietf/utils/markup_txt.py +++ b/ietf/utils/markup_txt.py @@ -37,7 +37,6 @@ from __future__ import absolute_import, print_function, unicode_literals import re -import six # pyflakes:ignore from django.utils.html import escape diff --git a/ietf/utils/test_smtpserver.py b/ietf/utils/test_smtpserver.py index b74797e52..21644a643 100644 --- a/ietf/utils/test_smtpserver.py +++ b/ietf/utils/test_smtpserver.py @@ -1,4 +1,4 @@ -# Copyright The IETF Trust 2014-2019, All Rights Reserved +# Copyright The IETF Trust 2014-2020, All Rights Reserved # -*- coding: utf-8 -*- @@ -7,7 +7,6 @@ from __future__ import absolute_import, print_function, unicode_literals import smtpd import threading import asyncore -import six import debug # pyflakes:ignore @@ -39,25 +38,19 @@ class SMTPTestChannel(smtpd.SMTPChannel): # mail_options = ['BODY=8BITMIME', 'SMTPUTF8'] def smtp_RCPT(self, arg): - if (six.PY2 and not self._SMTPChannel__mailfrom) or (six.PY3 and not self.mailfrom): + if not self.mailfrom: self.push(str('503 Error: need MAIL command')) return - if six.PY2: - address = self._SMTPChannel__getaddr('TO:', arg) if arg else None - else: - arg = self._strip_command_keyword('TO:', arg) - address, __ = self._getaddr(arg) + arg = self._strip_command_keyword('TO:', arg) + address, __ = self._getaddr(arg) if not address: self.push(str('501 Syntax: RCPT TO:
')) return if "poison" in address: self.push(str('550 Error: Not touching that')) return - if six.PY2: - self._SMTPChannel__rcpttos.append(address) - else: - self.rcpt_options = [] - self.rcpttos.append(address) + self.rcpt_options = [] + self.rcpttos.append(address) self.push(str('250 Ok')) class SMTPTestServer(smtpd.SMTPServer): diff --git a/ietf/utils/tests_restapi.py b/ietf/utils/tests_restapi.py index b8eb591b6..a6b3c53e1 100644 --- a/ietf/utils/tests_restapi.py +++ b/ietf/utils/tests_restapi.py @@ -1,10 +1,9 @@ -# Copyright The IETF Trust 2014-2019, All Rights Reserved +# Copyright The IETF Trust 2014-2020, All Rights Reserved # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, unicode_literals -import six import sys import debug @@ -84,6 +83,6 @@ class RestApi(ResourceTestCaseMixin, TestCase): for doc in doclist: for key in doc: value = doc[key] - if isinstance(value, six.string_types) and value.startswith('%s/'%apitop): + if isinstance(value, str) and value.startswith('%s/'%apitop): self.api_client.get(value, format='json') diff --git a/ietf/utils/text.py b/ietf/utils/text.py index ee01fbbe0..0346e1e78 100644 --- a/ietf/utils/text.py +++ b/ietf/utils/text.py @@ -5,7 +5,6 @@ from __future__ import absolute_import, print_function, unicode_literals import re -import six import textwrap import unicodedata @@ -60,7 +59,7 @@ def fill(text, width): def wordwrap(text, width=80): """Wraps long lines without loosing the formatting and indentation of short lines""" - if not isinstance(text, six.string_types): + if not isinstance(text, str): return text def block_separator(s): "Look for lines of identical symbols, at least three long" @@ -142,7 +141,7 @@ def maybe_split(text, split=True, pos=5000): return text def decode(raw): - assert isinstance(raw, six.binary_type) + assert isinstance(raw, bytes) try: text = raw.decode('utf-8') except UnicodeDecodeError: diff --git a/ietf/utils/urls.py b/ietf/utils/urls.py index a6a3abe9d..e3b5a0856 100644 --- a/ietf/utils/urls.py +++ b/ietf/utils/urls.py @@ -1,16 +1,16 @@ -# Copyright The IETF Trust 2016-2019, All Rights Reserved +# Copyright The IETF Trust 2016-2020, All Rights Reserved # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, unicode_literals import debug # pyflakes:ignore -import six from inspect import isclass from django.conf.urls import url as django_url from django.views.generic import View +from django.utils.encoding import force_str def url(regex, view, kwargs=None, name=None): if callable(view) and hasattr(view, '__name__'): @@ -22,9 +22,9 @@ def url(regex, view, kwargs=None, name=None): branch = 'name' elif isinstance(view, (list, tuple)): branch = 'list' - elif isinstance(view, six.string_types): + elif isinstance(view, (str, bytes)): branch = 'string' - name = view + name = force_str(view) elif callable(view) and hasattr(view, '__name__'): branch = 'callable' name = view_name