Removed further six usage.

- Legacy-Id: 17387
This commit is contained in:
Henrik Levkowetz 2020-03-05 15:54:32 +00:00
parent 566971a6ae
commit 1c808bf63b
8 changed files with 19 additions and 29 deletions

View file

@ -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()

View file

@ -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

View file

@ -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])

View file

@ -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

View file

@ -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: <address>'))
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):

View file

@ -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')

View file

@ -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:

View file

@ -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