fixup! fixup! [#8415] py2 removal - removal of six.PY2 checks
diff --git a/Allura/allura/lib/utils.py b/Allura/allura/lib/utils.py
index f98cfc2..6639734 100644
--- a/Allura/allura/lib/utils.py
+++ b/Allura/allura/lib/utils.py
@@ -23,7 +23,6 @@
import hashlib
import binascii
import logging.handlers
-import codecs
import os.path
import datetime
import random
diff --git a/Allura/allura/scripts/trac_export.py b/Allura/allura/scripts/trac_export.py
index cb131a5..6b2949b 100644
--- a/Allura/allura/scripts/trac_export.py
+++ b/Allura/allura/scripts/trac_export.py
@@ -28,7 +28,6 @@
import re
from optparse import OptionParser
from itertools import islice
-import codecs
from io import TextIOWrapper
from bs4 import BeautifulSoup, NavigableString
@@ -329,7 +328,7 @@
out_file = sys.stdout
if options.out_filename:
- out_file = codecs.open(options.out_filename, 'w', encoding='utf-8')
+ out_file = open(options.out_filename, 'w', encoding='utf-8')
out_file.write(
json.dumps(doc, cls=DateJSONEncoder, indent=2, sort_keys=True))
# It's bad habit not to terminate lines
diff --git a/Allura/allura/tasks/export_tasks.py b/Allura/allura/tasks/export_tasks.py
index 90b0369..13bb6f4 100644
--- a/Allura/allura/tasks/export_tasks.py
+++ b/Allura/allura/tasks/export_tasks.py
@@ -19,7 +19,6 @@
import os.path
import logging
import shutil
-import codecs
import tg
from tg import app_globals as g, tmpl_context as c
@@ -100,7 +99,7 @@
tool = app.config.options.mount_point
json_file = os.path.join(export_path, '%s.json' % tool)
try:
- with codecs.open(json_file, 'w', encoding='utf-8') as f:
+ with open(json_file, 'w', encoding='utf-8') as f:
app.bulk_export(f, export_path, with_attachments)
except Exception:
log.error('Error exporting: %s on %s', tool,
diff --git a/ForgeImporters/forgeimporters/base.py b/ForgeImporters/forgeimporters/base.py
index 5004f7e..0d9d359 100644
--- a/ForgeImporters/forgeimporters/base.py
+++ b/ForgeImporters/forgeimporters/base.py
@@ -28,7 +28,6 @@
from six.moves.urllib.parse import urlparse
from six.moves.urllib.parse import unquote
from datetime import datetime
-import codecs
import six
from bs4 import BeautifulSoup
@@ -664,6 +663,6 @@
except OSError as e:
if e.errno != errno.EEXIST:
raise
- with codecs.open(dest_file, 'w', encoding='utf-8') as fp:
+ with open(dest_file, 'w', encoding='utf-8') as fp:
fp.write(data)
return dest_file
diff --git a/ForgeImporters/forgeimporters/tests/test_base.py b/ForgeImporters/forgeimporters/tests/test_base.py
index 8b9dc07..44595cb 100644
--- a/ForgeImporters/forgeimporters/tests/test_base.py
+++ b/ForgeImporters/forgeimporters/tests/test_base.py
@@ -363,13 +363,13 @@
os.path.join = lambda *a: '/'.join(a)
giup.return_value = 'path'
os.makedirs.side_effect = OSError(errno.EEXIST, 'foo')
- _open = mock.MagicMock()
- fp = _open.return_value.__enter__.return_value
- with mock.patch.object(base.codecs, 'open', _open):
+ with mock.patch('forgeimporters.base.open') as m_open:
+ m_open = mock.mock_open(m_open)
+ fp = m_open.return_value.__enter__.return_value
base.save_importer_upload('project', 'file', 'data')
- os.makedirs.assert_called_once_with('path')
- _open.assert_called_once_with('path/file', 'w', encoding='utf-8')
- fp.write.assert_called_once_with('data')
+ os.makedirs.assert_called_once_with('path')
+ m_open.assert_called_once_with('path/file', 'w', encoding='utf-8')
+ fp.write.assert_called_once_with('data')
os.makedirs.side_effect = OSError(errno.EACCES, 'foo')
assert_raises(OSError, base.save_importer_upload,
diff --git a/run_tests b/run_tests
index c4ff7b4..23b8d3d 100755
--- a/run_tests
+++ b/run_tests
@@ -17,9 +17,6 @@
# specific language governing permissions and limitations
# under the License.
-from __future__ import unicode_literals
-from __future__ import absolute_import
-from __future__ import print_function
import argparse
from glob import glob
import multiprocessing
diff --git a/scripts/teamforge-import.py b/scripts/teamforge-import.py
index 9fc2926..8b375ec 100644
--- a/scripts/teamforge-import.py
+++ b/scripts/teamforge-import.py
@@ -33,7 +33,6 @@
from six.moves.configparser import ConfigParser
import random
import string
-import codecs
import sqlalchemy
from suds.client import Client
@@ -158,7 +157,7 @@
get_news(project)
if not options.skip_unsupported_check:
check_unsupported_tools(project)
- with codecs.open(os.path.join(options.output_dir, 'users.json'), 'w', encoding='utf-8') as user_file:
+ with open(os.path.join(options.output_dir, 'users.json'), 'w', encoding='utf-8') as user_file:
json.dump(users, user_file, default=str)
except Exception:
log.exception('Error extracting %s' % pid)
@@ -678,7 +677,7 @@
out_file = os.path.join(options.output_dir, project.id, *paths)
if not os.path.exists(os.path.dirname(out_file)):
os.makedirs(os.path.dirname(out_file))
- with codecs.open(out_file, 'w', encoding='utf-8') as out:
+ with open(out_file, 'w', encoding='utf-8') as out:
out.write(content.encode('utf-8'))
@@ -714,7 +713,7 @@
'returnToUrl': url,
'sfsubmit': 'submit'
}))
- with codecs.open(out_file, 'w', encoding='utf-8') as out:
+ with open(out_file, 'w', encoding='utf-8') as out:
out.write(resp.fp.read())
return out_file
diff --git a/scripts/trac_export_wiki.py b/scripts/trac_export_wiki.py
index 650206b..3a18955 100755
--- a/scripts/trac_export_wiki.py
+++ b/scripts/trac_export_wiki.py
@@ -19,7 +19,6 @@
import sys
from optparse import OptionParser
-import codecs
from tracwikiimporter.scripts.wiki_from_trac.extractors import WikiExporter
@@ -52,6 +51,6 @@
out = sys.stdout
if options.out_filename:
- out = codecs.open(options.out_filename, 'w', encoding='utf-8')
+ out = open(options.out_filename, 'w', encoding='utf-8')
exporter.export(out)
diff --git a/tox.ini b/tox.ini
index 4239c0c..5eff60b 100644
--- a/tox.ini
+++ b/tox.ini
@@ -21,7 +21,7 @@
# for full test suite runs, use ./run_tests within the virtualenv
[tox]
-envlist = py{27,37}
+envlist = py{37}
# since we don't have one top-level setup.py:
skipsdist = True