Remove remaining imports/calls to six not automatically removed by pyupgrade.

This commit is contained in:
Ben Sturmfels 2021-03-05 23:42:38 +11:00
parent dec47c7102
commit 9bf3bc1944
74 changed files with 35 additions and 175 deletions

View File

@ -1,15 +1,11 @@
import functools import functools
import warnings import warnings
import six
from email.mime.text import MIMEText from email.mime.text import MIMEText
def encode_to_utf8(method): def encode_to_utf8(method):
def wrapper(self): def wrapper(self):
if six.PY2 and isinstance(method(self), str):
return method(self).encode('utf-8')
return method(self) return method(self)
functools.update_wrapper(wrapper, method, ['__name__', '__doc__']) functools.update_wrapper(wrapper, method, ['__name__', '__doc__'])
return wrapper return wrapper
@ -17,13 +13,4 @@ def encode_to_utf8(method):
# based on django.utils.encoding.python_2_unicode_compatible # based on django.utils.encoding.python_2_unicode_compatible
def py2_unicode(klass): def py2_unicode(klass):
if six.PY2:
if '__str__' not in klass.__dict__:
warnings.warn("@py2_unicode cannot be applied "
"to %s because it doesn't define __str__()." %
klass.__name__)
klass.__unicode__ = klass.__str__
klass.__str__ = encode_to_utf8(klass.__unicode__)
if '__repr__' in klass.__dict__:
klass.__repr__ = encode_to_utf8(klass.__repr__)
return klass return klass

View File

@ -17,7 +17,6 @@
import logging import logging
import six
import wtforms import wtforms
from sqlalchemy import or_ from sqlalchemy import or_

View File

@ -16,8 +16,6 @@
import logging import logging
import six
from itsdangerous import BadSignature from itsdangerous import BadSignature
from mediagoblin import messages, mg_globals from mediagoblin import messages, mg_globals

View File

@ -13,7 +13,6 @@
# #
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# 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 six
import copy import copy
from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.ext.declarative import declarative_base
@ -41,14 +40,14 @@ class FakeCursor:
return FakeCursor(copy.copy(self.cursor), self.mapper, self.filter) return FakeCursor(copy.copy(self.cursor), self.mapper, self.filter)
def __iter__(self): def __iter__(self):
return six.moves.filter(self.filter, six.moves.map(self.mapper, self.cursor)) return filter(self.filter, map(self.mapper, self.cursor))
def __getitem__(self, key): def __getitem__(self, key):
return self.mapper(self.cursor[key]) return self.mapper(self.cursor[key])
def slice(self, *args, **kwargs): def slice(self, *args, **kwargs):
r = self.cursor.slice(*args, **kwargs) r = self.cursor.slice(*args, **kwargs)
return list(six.moves.filter(self.filter, six.moves.map(self.mapper, r))) return list(filter(self.filter, map(self.mapper, r)))
class GMGTableBase: class GMGTableBase:
# Deletion types # Deletion types

View File

@ -18,8 +18,6 @@
import datetime import datetime
import uuid import uuid
import six
try: try:
import migrate import migrate
except ImportError: except ImportError:

View File

@ -44,8 +44,7 @@ from mediagoblin.tools.common import import_component
from mediagoblin.tools.routing import extract_url_arguments from mediagoblin.tools.routing import extract_url_arguments
from mediagoblin.tools.text import convert_to_tag_list_of_dicts from mediagoblin.tools.text import convert_to_tag_list_of_dicts
import six from urllib.parse import urljoin
from six.moves.urllib.parse import urljoin
from pytz import UTC from pytz import UTC
_log = logging.getLogger(__name__) _log = logging.getLogger(__name__)

View File

@ -18,7 +18,6 @@
from contextlib import contextmanager from contextlib import contextmanager
import logging import logging
import six
from sqlalchemy import create_engine, event from sqlalchemy import create_engine, event
from mediagoblin import mg_globals from mediagoblin import mg_globals

View File

@ -19,7 +19,7 @@ from functools import wraps
from werkzeug.exceptions import Forbidden, NotFound from werkzeug.exceptions import Forbidden, NotFound
from oauthlib.oauth1 import ResourceEndpoint from oauthlib.oauth1 import ResourceEndpoint
from six.moves.urllib.parse import urljoin from urllib.parse import urljoin
from mediagoblin import mg_globals as mgg from mediagoblin import mg_globals as mgg
from mediagoblin import messages from mediagoblin import messages

View File

@ -13,8 +13,6 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# 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 six
from datetime import datetime from datetime import datetime
from itsdangerous import BadSignature from itsdangerous import BadSignature
@ -537,4 +535,4 @@ def edit_metadata(request, media):
request, request,
'mediagoblin/edit/metadata.html', 'mediagoblin/edit/metadata.html',
{'form':form, {'form':form,
'media':media}) 'media':media})

View File

@ -18,8 +18,6 @@ import argparse
import os import os
import shutil import shutil
import six
from mediagoblin.tools.common import import_component from mediagoblin.tools.common import import_component
import logging import logging

View File

@ -17,8 +17,6 @@
import os import os
import six
from mediagoblin.db.models import LocalUser from mediagoblin.db.models import LocalUser
from mediagoblin.gmg_commands import util as commands_util from mediagoblin.gmg_commands import util as commands_util
from mediagoblin.submit.lib import ( from mediagoblin.submit.lib import (
@ -93,8 +91,6 @@ def addmedia(args):
# this is kinda terrible # this is kinda terrible
if some_string is None: if some_string is None:
return None return None
if six.PY2:
return str(some_string, 'utf-8')
return some_string return some_string
try: try:

View File

@ -21,8 +21,7 @@ import shutil
import tempfile import tempfile
import requests import requests
import six from urllib.parse import urlparse
from six.moves.urllib.parse import urlparse
from mediagoblin.db.models import LocalUser, MediaEntry from mediagoblin.db.models import LocalUser, MediaEntry
from mediagoblin.gmg_commands import util as commands_util from mediagoblin.gmg_commands import util as commands_util
@ -86,9 +85,6 @@ def batchaddmedia(args):
all_metadata = open(abs_metadata_filename) all_metadata = open(abs_metadata_filename)
media_metadata = csv.DictReader(all_metadata) media_metadata = csv.DictReader(all_metadata)
for index, file_metadata in enumerate(media_metadata): for index, file_metadata in enumerate(media_metadata):
if six.PY2:
file_metadata = {k.decode('utf-8'): v.decode('utf-8') for k, v in file_metadata.items()}
files_attempted += 1 files_attempted += 1
# In case the metadata was not uploaded initialize an empty dictionary. # In case the metadata was not uploaded initialize an empty dictionary.
json_ld_metadata = compact_and_validate({}) json_ld_metadata = compact_and_validate({})
@ -146,8 +142,6 @@ Metadata was not uploaded.""".format(
# `batchaddmedia` to upload a file larger than 200MB. # `batchaddmedia` to upload a file larger than 200MB.
media_file = tempfile.TemporaryFile() media_file = tempfile.TemporaryFile()
shutil.copyfileobj(res.raw, media_file) shutil.copyfileobj(res.raw, media_file)
if six.PY2:
media_file.seek(0)
elif url.scheme == '': elif url.scheme == '':
path = url.path path = url.path

View File

@ -16,7 +16,6 @@
import logging import logging
import six
from alembic import command from alembic import command
from sqlalchemy.orm import sessionmaker from sqlalchemy.orm import sessionmaker

View File

@ -17,8 +17,6 @@
import sys import sys
import six
from mediagoblin.db.models import LocalUser from mediagoblin.db.models import LocalUser
from mediagoblin.gmg_commands import util as commands_util from mediagoblin.gmg_commands import util as commands_util
from mediagoblin import auth from mediagoblin import auth

View File

@ -18,8 +18,6 @@
from mediagoblin import app from mediagoblin import app
import getpass import getpass
import six
def setup_app(args): def setup_app(args):
""" """
@ -35,7 +33,7 @@ def prompt_if_not_set(variable, text, password=False):
""" """
if variable is None: if variable is None:
if not password: if not password:
variable = six.moves.input(text + ' ') variable = input(text + ' ')
else: else:
variable=getpass.getpass(text + ' ') variable=getpass.getpass(text + ' ')

View File

@ -19,8 +19,6 @@ import sys
import datetime import datetime
import logging import logging
import six
from celery import Celery from celery import Celery
from kombu import Exchange, Queue from kombu import Exchange, Queue
from mediagoblin.tools.pluginapi import hook_runall from mediagoblin.tools.pluginapi import hook_runall

View File

@ -22,8 +22,6 @@ except ImportError:
import Image import Image
import logging import logging
import six
from mediagoblin import mg_globals as mgg from mediagoblin import mg_globals as mgg
from mediagoblin.processing import ( from mediagoblin.processing import (
create_pub_filepath, FilenameBuilder, create_pub_filepath, FilenameBuilder,

View File

@ -18,8 +18,6 @@ import argparse
import logging import logging
import os import os
import six
from mediagoblin import mg_globals as mgg from mediagoblin import mg_globals as mgg
from mediagoblin.processing import ( from mediagoblin.processing import (
BadMediaFail, FilenameBuilder, BadMediaFail, FilenameBuilder,

View File

@ -19,8 +19,6 @@ _log = logging.getLogger(__name__)
from datetime import datetime from datetime import datetime
import six
from werkzeug.exceptions import Forbidden from werkzeug.exceptions import Forbidden
from mediagoblin.tools import pluginapi from mediagoblin.tools import pluginapi

View File

@ -23,8 +23,6 @@ import os
import logging import logging
import argparse import argparse
import six
from mediagoblin import mg_globals as mgg from mediagoblin import mg_globals as mgg
from mediagoblin.db.models import Location from mediagoblin.db.models import Location
from mediagoblin.processing import ( from mediagoblin.processing import (

View File

@ -20,8 +20,6 @@ import logging
import datetime import datetime
import celery import celery
import six
from celery import group from celery import group
from mediagoblin import mg_globals as mgg from mediagoblin import mg_globals as mgg
from mediagoblin.processing import ( from mediagoblin.processing import (

View File

@ -21,8 +21,6 @@ import gettext
import pkg_resources import pkg_resources
import threading import threading
import six
############################# #############################
# General mediagoblin globals # General mediagoblin globals
############################# #############################

View File

@ -14,8 +14,6 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# 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 six
from mediagoblin import mg_globals from mediagoblin import mg_globals
from mediagoblin.db.models import User, Privilege, UserBan, LocalUser from mediagoblin.db.models import User, Privilege, UserBan, LocalUser
from mediagoblin.db.base import Session from mediagoblin.db.base import Session

View File

@ -17,8 +17,6 @@
import datetime import datetime
import urllib import urllib
import six
from oauthlib.oauth1.rfc5849.utils import UNICODE_ASCII_CHARACTER_SET from oauthlib.oauth1.rfc5849.utils import UNICODE_ASCII_CHARACTER_SET
from oauthlib.oauth1 import (RequestTokenEndpoint, AuthorizationEndpoint, from oauthlib.oauth1 import (RequestTokenEndpoint, AuthorizationEndpoint,
AccessTokenEndpoint) AccessTokenEndpoint)

View File

@ -21,7 +21,7 @@ from functools import wraps
from werkzeug.exceptions import Forbidden from werkzeug.exceptions import Forbidden
from werkzeug.wrappers import Response from werkzeug.wrappers import Response
from six.moves.urllib.parse import urljoin from urllib.parse import urljoin
from mediagoblin import mg_globals from mediagoblin import mg_globals
from mediagoblin.tools.pluginapi import PluginManager from mediagoblin.tools.pluginapi import PluginManager

View File

@ -17,8 +17,6 @@
import json import json
import logging import logging
import six
from werkzeug.exceptions import BadRequest from werkzeug.exceptions import BadRequest
from werkzeug.wrappers import Response from werkzeug.wrappers import Response

View File

@ -13,8 +13,6 @@
# #
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# 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 six
from mediagoblin.db.models import MediaEntry, User, LocalUser from mediagoblin.db.models import MediaEntry, User, LocalUser
from mediagoblin.plugins.archivalook.models import FeaturedMedia from mediagoblin.plugins.archivalook.models import FeaturedMedia
from mediagoblin.tools.translate import lazy_pass_to_ugettext as _ from mediagoblin.tools.translate import lazy_pass_to_ugettext as _

View File

@ -16,8 +16,6 @@
import bcrypt import bcrypt
import random import random
import six
from mediagoblin import mg_globals from mediagoblin import mg_globals
from mediagoblin.tools.crypto import get_timed_signer_url from mediagoblin.tools.crypto import get_timed_signer_url
from mediagoblin.tools.mail import send_email from mediagoblin.tools.mail import send_email

View File

@ -16,8 +16,6 @@
import logging import logging
import six
from werkzeug.exceptions import Unauthorized from werkzeug.exceptions import Unauthorized
from mediagoblin.auth.tools import check_login_simple from mediagoblin.auth.tools import check_login_simple

View File

@ -16,8 +16,6 @@
import ldap import ldap
import logging import logging
import six
from mediagoblin.tools import pluginapi from mediagoblin.tools import pluginapi
_log = logging.getLogger(__name__) _log = logging.getLogger(__name__)

View File

@ -14,8 +14,6 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# 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 six
from mediagoblin import mg_globals, messages from mediagoblin import mg_globals, messages
from mediagoblin.auth.tools import register_user from mediagoblin.auth.tools import register_user
from mediagoblin.db.models import User, LocalUser from mediagoblin.db.models import User, LocalUser

View File

@ -16,8 +16,6 @@
import base64 import base64
import time import time
import six
from openid.association import Association as OIDAssociation from openid.association import Association as OIDAssociation
from openid.store.interface import OpenIDStore from openid.store.interface import OpenIDStore
from openid.store import nonce from openid.store import nonce

View File

@ -14,8 +14,6 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# 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 six
from openid.consumer import consumer from openid.consumer import consumer
from openid.consumer.discover import DiscoveryFailure from openid.consumer.discover import DiscoveryFailure
from openid.extensions.sreg import SRegRequest, SRegResponse from openid.extensions.sreg import SRegRequest, SRegResponse

View File

@ -17,8 +17,6 @@ import json
import logging import logging
import requests import requests
import six
from werkzeug.exceptions import BadRequest from werkzeug.exceptions import BadRequest
from mediagoblin import messages, mg_globals from mediagoblin import messages, mg_globals

View File

@ -17,7 +17,6 @@
from collections import namedtuple from collections import namedtuple
import logging import logging
import six
import lxml.etree as ET import lxml.etree as ET
from werkzeug.exceptions import MethodNotAllowed, BadRequest from werkzeug.exceptions import MethodNotAllowed, BadRequest

View File

@ -17,8 +17,6 @@
import logging import logging
import re import re
import six
from werkzeug.exceptions import MethodNotAllowed, BadRequest, NotImplemented from werkzeug.exceptions import MethodNotAllowed, BadRequest, NotImplemented
from werkzeug.wrappers import BaseResponse from werkzeug.wrappers import BaseResponse

View File

@ -14,8 +14,6 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# 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 six
from datetime import datetime from datetime import datetime
from itsdangerous import BadSignature from itsdangerous import BadSignature

View File

@ -24,8 +24,6 @@ except:
import logging import logging
import os import os
import six
from mediagoblin import mg_globals as mgg from mediagoblin import mg_globals as mgg
from mediagoblin.db.util import atomic_update from mediagoblin.db.util import atomic_update
from mediagoblin.db.models import MediaEntry from mediagoblin.db.models import MediaEntry

View File

@ -16,7 +16,7 @@
import logging import logging
from six.moves.urllib import request, parse from urllib import request, parse
import celery import celery
from celery.registry import tasks from celery.registry import tasks

View File

@ -18,8 +18,6 @@
import shutil import shutil
import uuid import uuid
import six
from werkzeug.utils import secure_filename from werkzeug.utils import secure_filename
from mediagoblin.tools import common from mediagoblin.tools import common

View File

@ -18,7 +18,7 @@ import io
import os import os
import shutil import shutil
import six.moves.urllib.parse as urlparse import urllib.parse as urlparse
from mediagoblin.storage import ( from mediagoblin.storage import (
StorageInterface, StorageInterface,

View File

@ -15,8 +15,6 @@
# 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 six
from mediagoblin.storage import StorageInterface, clean_listy_filepath from mediagoblin.storage import StorageInterface, clean_listy_filepath

View File

@ -18,8 +18,6 @@ import logging
import uuid import uuid
from os.path import splitext from os.path import splitext
import six
from celery import chord from celery import chord
from werkzeug.utils import secure_filename from werkzeug.utils import secure_filename

View File

@ -14,8 +14,6 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# 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 six
from mediagoblin import messages from mediagoblin import messages
import mediagoblin.mg_globals as mg_globals import mediagoblin.mg_globals as mg_globals

View File

@ -17,9 +17,7 @@
import pkg_resources import pkg_resources
import pytest import pytest
import six import urllib.parse as urlparse
import six.moves.urllib.parse as urlparse
from mediagoblin import mg_globals from mediagoblin import mg_globals
from mediagoblin.db.models import User, LocalUser from mediagoblin.db.models import User, LocalUser

View File

@ -14,7 +14,7 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# 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 six.moves.urllib.parse as urlparse import urllib.parse as urlparse
from mediagoblin.db.models import User, LocalUser from mediagoblin.db.models import User, LocalUser
from mediagoblin.plugins.basic_auth import tools as auth_tools from mediagoblin.plugins.basic_auth import tools as auth_tools

View File

@ -14,8 +14,7 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# 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 six import urllib.parse as urlparse
import six.moves.urllib.parse as urlparse
import pytest import pytest
from mediagoblin import mg_globals from mediagoblin import mg_globals
@ -206,7 +205,6 @@ class TestMetaDataEdit:
context_data = context_data[key] context_data = context_data[key]
return response, context_data return response, context_data
@pytest.mark.skipif(six.PY2, reason='Breaks in Python 2 but seems non-critical')
def test_edit_metadata(self, test_app): def test_edit_metadata(self, test_app):
media_entry = fixture_media_entry(uploader=self.user.id, media_entry = fixture_media_entry(uploader=self.user.id,
state='processed') state='processed')

View File

@ -16,13 +16,12 @@
import pkg_resources import pkg_resources
import pytest import pytest
import six
try: try:
from unittest import mock from unittest import mock
except ImportError: except ImportError:
import unittest.mock as mock import unittest.mock as mock
import six.moves.urllib.parse as urlparse import urllib.parse as urlparse
from mediagoblin import mg_globals from mediagoblin import mg_globals
from mediagoblin.db.base import Session from mediagoblin.db.base import Session

View File

@ -16,7 +16,7 @@
import pytest import pytest
import six.moves.urllib.parse as urlparse import urllib.parse as urlparse
from mediagoblin.tools import template, mail from mediagoblin.tools import template, mail

View File

@ -16,7 +16,7 @@
import pytest import pytest
from six.moves.urllib.parse import parse_qs, urlparse from urllib.parse import parse_qs, urlparse
from oauthlib.oauth1 import Client from oauthlib.oauth1 import Client

View File

@ -16,8 +16,7 @@
import pkg_resources import pkg_resources
import pytest import pytest
import six import urllib.parse as urlparse
import six.moves.urllib.parse as urlparse
try: try:
from unittest import mock from unittest import mock
except ImportError: except ImportError:

View File

@ -16,13 +16,12 @@
import pkg_resources import pkg_resources
import pytest import pytest
import six
try: try:
from unittest import mock from unittest import mock
except ImportError: except ImportError:
import unittest.mock as mock import unittest.mock as mock
import six.moves.urllib.parse as urlparse import urllib.parse as urlparse
pytest.importorskip("requests") pytest.importorskip("requests")

View File

@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# 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 six
import pytest import pytest
from datetime import date, timedelta from datetime import date, timedelta
from webtest import AppError from webtest import AppError
@ -128,7 +127,7 @@ class TestPrivilegeFunctionality:
#---------------------------------------------------------------------- #----------------------------------------------------------------------
with pytest.raises(AppError) as excinfo: with pytest.raises(AppError) as excinfo:
response = self.test_app.get('/submit/') response = self.test_app.get('/submit/')
excinfo = str(excinfo) if six.PY2 else str(excinfo).encode('ascii') excinfo = str(excinfo).encode('ascii')
assert b'Bad response: 403 FORBIDDEN' in excinfo assert b'Bad response: 403 FORBIDDEN' in excinfo
@ -136,7 +135,7 @@ class TestPrivilegeFunctionality:
response = self.do_post({'upload_files':[('file',GOOD_JPG)], response = self.do_post({'upload_files':[('file',GOOD_JPG)],
'title':'Normal Upload 1'}, 'title':'Normal Upload 1'},
url='/submit/') url='/submit/')
excinfo = str(excinfo) if six.PY2 else str(excinfo).encode('ascii') excinfo = str(excinfo).encode('ascii')
assert b'Bad response: 403 FORBIDDEN' in excinfo assert b'Bad response: 403 FORBIDDEN' in excinfo
# Test that a user cannot comment without the commenter privilege # Test that a user cannot comment without the commenter privilege
@ -159,14 +158,14 @@ class TestPrivilegeFunctionality:
response = self.test_app.post( response = self.test_app.post(
media_uri_id + 'comment/add/', media_uri_id + 'comment/add/',
{'comment_content': 'Test comment #42'}) {'comment_content': 'Test comment #42'})
excinfo = str(excinfo) if six.PY2 else str(excinfo).encode('ascii') excinfo = str(excinfo).encode('ascii')
assert b'Bad response: 403 FORBIDDEN' in excinfo assert b'Bad response: 403 FORBIDDEN' in excinfo
# Test that a user cannot report without the reporter privilege # Test that a user cannot report without the reporter privilege
#---------------------------------------------------------------------- #----------------------------------------------------------------------
with pytest.raises(AppError) as excinfo: with pytest.raises(AppError) as excinfo:
response = self.test_app.get(media_uri_slug+"report/") response = self.test_app.get(media_uri_slug+"report/")
excinfo = str(excinfo) if six.PY2 else str(excinfo).encode('ascii') excinfo = str(excinfo).encode('ascii')
assert b'Bad response: 403 FORBIDDEN' in excinfo assert b'Bad response: 403 FORBIDDEN' in excinfo
with pytest.raises(AppError) as excinfo: with pytest.raises(AppError) as excinfo:
@ -174,7 +173,7 @@ class TestPrivilegeFunctionality:
{'report_reason':'Testing Reports #1', {'report_reason':'Testing Reports #1',
'reporter_id':'3'}, 'reporter_id':'3'},
url=(media_uri_slug+"report/")) url=(media_uri_slug+"report/"))
excinfo = str(excinfo) if six.PY2 else str(excinfo).encode('ascii') excinfo = str(excinfo).encode('ascii')
assert b'Bad response: 403 FORBIDDEN' in excinfo assert b'Bad response: 403 FORBIDDEN' in excinfo
# Test that a user cannot access the moderation pages w/o moderator # Test that a user cannot access the moderation pages w/o moderator
@ -182,27 +181,27 @@ class TestPrivilegeFunctionality:
#---------------------------------------------------------------------- #----------------------------------------------------------------------
with pytest.raises(AppError) as excinfo: with pytest.raises(AppError) as excinfo:
response = self.test_app.get("/mod/users/") response = self.test_app.get("/mod/users/")
excinfo = str(excinfo) if six.PY2 else str(excinfo).encode('ascii') excinfo = str(excinfo).encode('ascii')
assert b'Bad response: 403 FORBIDDEN' in excinfo assert b'Bad response: 403 FORBIDDEN' in excinfo
with pytest.raises(AppError) as excinfo: with pytest.raises(AppError) as excinfo:
response = self.test_app.get("/mod/reports/") response = self.test_app.get("/mod/reports/")
excinfo = str(excinfo) if six.PY2 else str(excinfo).encode('ascii') excinfo = str(excinfo).encode('ascii')
assert b'Bad response: 403 FORBIDDEN' in excinfo assert b'Bad response: 403 FORBIDDEN' in excinfo
with pytest.raises(AppError) as excinfo: with pytest.raises(AppError) as excinfo:
response = self.test_app.get("/mod/media/") response = self.test_app.get("/mod/media/")
excinfo = str(excinfo) if six.PY2 else str(excinfo).encode('ascii') excinfo = str(excinfo).encode('ascii')
assert b'Bad response: 403 FORBIDDEN' in excinfo assert b'Bad response: 403 FORBIDDEN' in excinfo
with pytest.raises(AppError) as excinfo: with pytest.raises(AppError) as excinfo:
response = self.test_app.get("/mod/users/1/") response = self.test_app.get("/mod/users/1/")
excinfo = str(excinfo) if six.PY2 else str(excinfo).encode('ascii') excinfo = str(excinfo).encode('ascii')
assert b'Bad response: 403 FORBIDDEN' in excinfo assert b'Bad response: 403 FORBIDDEN' in excinfo
with pytest.raises(AppError) as excinfo: with pytest.raises(AppError) as excinfo:
response = self.test_app.get("/mod/reports/1/") response = self.test_app.get("/mod/reports/1/")
excinfo = str(excinfo) if six.PY2 else str(excinfo).encode('ascii') excinfo = str(excinfo).encode('ascii')
assert b'Bad response: 403 FORBIDDEN' in excinfo assert b'Bad response: 403 FORBIDDEN' in excinfo
self.query_for_users() self.query_for_users()
@ -213,5 +212,5 @@ class TestPrivilegeFunctionality:
'targeted_user':self.admin_user.id}, 'targeted_user':self.admin_user.id},
url='/mod/reports/1/') url='/mod/reports/1/')
self.query_for_users() self.query_for_users()
excinfo = str(excinfo) if six.PY2 else str(excinfo).encode('ascii') excinfo = str(excinfo).encode('ascii')
assert b'Bad response: 403 FORBIDDEN' in excinfo assert b'Bad response: 403 FORBIDDEN' in excinfo

View File

@ -15,8 +15,6 @@
# 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 pytest import pytest
import six
from mediagoblin.tools import template from mediagoblin.tools import template
from mediagoblin.tests.tools import (fixture_add_user, fixture_media_entry, from mediagoblin.tests.tools import (fixture_add_user, fixture_media_entry,
fixture_add_comment, fixture_add_comment_report) fixture_add_comment, fixture_add_comment_report)

View File

@ -14,7 +14,6 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# 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 six
import pytest import pytest
pytest.importorskip("migrate") pytest.importorskip("migrate")
@ -569,7 +568,6 @@ def _get_level3_exits(session, level):
session.query(LevelExit3).filter_by(from_level=level.id)} session.query(LevelExit3).filter_by(from_level=level.id)}
@pytest.mark.skipif(six.PY2, reason='Breaks in Python 2 but migrations seem to run ok')
def test_set1_to_set3(): def test_set1_to_set3():
# Create / connect to database # Create / connect to database
# ---------------------------- # ----------------------------

View File

@ -19,8 +19,6 @@ import os
import tempfile import tempfile
import pytest import pytest
import six
from werkzeug.utils import secure_filename from werkzeug.utils import secure_filename
from mediagoblin import storage from mediagoblin import storage

View File

@ -36,13 +36,6 @@ try:
except ImportError: except ImportError:
SKIP_AUDIO = True SKIP_AUDIO = True
import six
if six.PY2: # this hack only work in Python 2
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import os import os
import pytest import pytest
import webtest.forms import webtest.forms
@ -52,7 +45,7 @@ try:
except ImportError: except ImportError:
import unittest.mock as mock import unittest.mock as mock
import six.moves.urllib.parse as urlparse import urllib.parse as urlparse
from celery import Signature from celery import Signature
from mediagoblin.tests.tools import ( from mediagoblin.tests.tools import (

View File

@ -24,8 +24,6 @@ import pytest
import smtplib import smtplib
import pkg_resources import pkg_resources
import six
from mediagoblin.tests.tools import get_app from mediagoblin.tests.tools import get_app
from mediagoblin import mg_globals from mediagoblin import mg_globals
from mediagoblin.tools import common, url, translate, mail, text, testing from mediagoblin.tools import common, url, translate, mail, text, testing

View File

@ -19,8 +19,6 @@ import os
import pkg_resources import pkg_resources
import shutil import shutil
import six
from paste.deploy import loadapp from paste.deploy import loadapp
from webtest import TestApp from webtest import TestApp

View File

@ -14,8 +14,6 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# 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 six
from exifread import process_file from exifread import process_file
from exifread.utils import Ratio from exifread.utils import Ratio

View File

@ -14,8 +14,6 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# 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 six
from mediagoblin import mg_globals from mediagoblin import mg_globals

View File

@ -17,7 +17,6 @@
import socket import socket
import logging import logging
import six
import smtplib import smtplib
import sys import sys
from mediagoblin import mg_globals, messages from mediagoblin import mg_globals, messages

View File

@ -19,7 +19,7 @@ from math import ceil, floor
from itertools import count from itertools import count
from werkzeug.datastructures import MultiDict from werkzeug.datastructures import MultiDict
from six.moves import urllib import urllib
PAGINATION_DEFAULT_PER_PAGE = 30 PAGINATION_DEFAULT_PER_PAGE = 30

View File

@ -18,7 +18,7 @@ import logging
import json import json
import traceback import traceback
from six.moves.urllib import request, parse from urllib import request, parse
_log = logging.getLogger(__name__) _log = logging.getLogger(__name__)

View File

@ -17,7 +17,6 @@
import json import json
import logging import logging
import six
from werkzeug.http import parse_options_header from werkzeug.http import parse_options_header
from mediagoblin.db.models import User, AccessToken from mediagoblin.db.models import User, AccessToken

View File

@ -16,7 +16,6 @@
import json import json
import six
import werkzeug.utils import werkzeug.utils
from werkzeug.wrappers import Response as wz_Response from werkzeug.wrappers import Response as wz_Response
from mediagoblin.tools.template import render_template from mediagoblin.tools.template import render_template

View File

@ -16,9 +16,7 @@
import logging import logging
import six from urllib.parse import urlparse
from six.moves.urllib.parse import urlparse
from werkzeug.routing import Map, Rule from werkzeug.routing import Map, Rule
from mediagoblin.tools.common import import_component from mediagoblin.tools.common import import_component

View File

@ -24,8 +24,6 @@
import logging import logging
import six
_log = logging.getLogger(__name__) _log = logging.getLogger(__name__)

View File

@ -14,8 +14,6 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# 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 six
import jinja2 import jinja2
from jinja2.ext import Extension from jinja2.ext import Extension
from jinja2.nodes import Include, Const from jinja2.nodes import Include, Const

View File

@ -17,8 +17,6 @@
import gettext import gettext
import pkg_resources import pkg_resources
import six
from babel import localedata from babel import localedata
from babel.support import LazyProxy from babel.support import LazyProxy
@ -147,10 +145,9 @@ def pass_to_ugettext(*args, **kwargs):
The reason we can't have a global ugettext method is because The reason we can't have a global ugettext method is because
mg_globals gets swapped out by the application per-request. mg_globals gets swapped out by the application per-request.
""" """
if six.PY2:
return mg_globals.thread_scope.translations.ugettext(*args, **kwargs)
return mg_globals.thread_scope.translations.gettext(*args, **kwargs) return mg_globals.thread_scope.translations.gettext(*args, **kwargs)
def pass_to_ungettext(*args, **kwargs): def pass_to_ungettext(*args, **kwargs):
""" """
Pass a translation on to the appropriate ungettext method. Pass a translation on to the appropriate ungettext method.
@ -158,8 +155,6 @@ def pass_to_ungettext(*args, **kwargs):
The reason we can't have a global ugettext method is because The reason we can't have a global ugettext method is because
mg_globals gets swapped out by the application per-request. mg_globals gets swapped out by the application per-request.
""" """
if six.PY2:
return mg_globals.thread_scope.translations.ungettext(*args, **kwargs)
return mg_globals.thread_scope.translations.ngettext(*args, **kwargs) return mg_globals.thread_scope.translations.ngettext(*args, **kwargs)

View File

@ -17,8 +17,6 @@
import re import re
from unidecode import unidecode from unidecode import unidecode
import six
_punct_re = re.compile(r'[\t !"#:$%&\'()*\-/<=>?@\[\\\]^_`{|},.]+') _punct_re = re.compile(r'[\t !"#:$%&\'()*\-/<=>?@\[\\\]^_`{|},.]+')

View File

@ -14,7 +14,7 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from six.moves.urllib.parse import urlparse from urllib.parse import urlparse
def validate_email(email): def validate_email(email):
""" """

View File

@ -18,8 +18,6 @@ import os
import shutil import shutil
import tempfile import tempfile
import six
from mediagoblin._compat import py2_unicode from mediagoblin._compat import py2_unicode
# Actual workbench stuff # Actual workbench stuff

View File

@ -18,8 +18,6 @@ import logging
import datetime import datetime
import json import json
import six
from mediagoblin import messages, mg_globals from mediagoblin import messages, mg_globals
from mediagoblin.db.models import (MediaEntry, MediaTag, Collection, Comment, from mediagoblin.db.models import (MediaEntry, MediaTag, Collection, Comment,
CollectionItem, LocalUser, Activity, \ CollectionItem, LocalUser, Activity, \