drop python 2 support
Latest repo should make sure this always runs under Python 3.
Drop support for Python 2 now.
BUG=chromium:1003955
TEST=`repo upload` works
Change-Id: I119c76f196c113e61216412e36b1be478069a55f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/repohooks/+/1958809
Reviewed-by: Will Bradley <wbbradley@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/PRESUBMIT.cfg b/PRESUBMIT.cfg
index f169d57..6dd237a 100644
--- a/PRESUBMIT.cfg
+++ b/PRESUBMIT.cfg
@@ -3,8 +3,7 @@
[Hook Scripts]
cros lint = cros lint ${PRESUBMIT_FILES}
-pre-upload_unittest py2 = python2 ./pre-upload_unittest.py
-pre-upload_unittest py3 = python3 ./pre-upload_unittest.py
+pre-upload_unittest = ./pre-upload_unittest.py
[Hook Overrides]
cros_license_check: true
diff --git a/pre-upload.py b/pre-upload.py
index 511324d..90111f4 100755
--- a/pre-upload.py
+++ b/pre-upload.py
@@ -13,18 +13,16 @@
import argparse
import collections
+import configparser
import datetime
import fnmatch
import functools
-import io
import json
import os
import re
import sys
import stat
-from six.moves import configparser
-
from errors import (VerifyException, HookFailure, PrintErrorForProject,
PrintErrorsForCommit)
@@ -111,7 +109,6 @@
class BadInvocation(Exception):
"""An Exception indicating a bad invocation of the program."""
- pass
# General Helpers
@@ -1493,7 +1490,7 @@
def _kernel_configcheck(_project, commit):
"""Makes sure kernel config changes are not mixed with code changes"""
files = _get_affected_files(commit)
- if not len(_filter_files(files, [r'chromeos/config'])) in [0, len(files)]:
+ if len(_filter_files(files, [r'chromeos/config'])) not in [0, len(files)]:
return HookFailure('Changes to chromeos/config/ and regular files must '
'be in separate commits:\n%s' % '\n'.join(files))
return None
@@ -1628,7 +1625,7 @@
# commit diff, rather than whatever's on disk.
# TODO(vapier): Once we migrate this to Python 3 only, cut it over.
contents = _get_file_content(f, commit)
- parser.readfp(io.StringIO(contents))
+ parser.read_file(contents.splitlines())
except configparser.Error as e:
msg = ('Unable to parse COMMIT-QUEUE.ini file at %s due to %s.' %
(f, e))