gn2bp: delete compat.py
gn2bp does not need to support python2.
Test: none
Change-Id: I00223ec3e53bf629342380eadf5f867c333863f6
diff --git a/tools/gn2bp/compat.py b/tools/gn2bp/compat.py
deleted file mode 100755
index db587a2..0000000
--- a/tools/gn2bp/compat.py
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin/env python3
-# Copyright (C) 2022 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-try:
- from shlex import quote
-except ImportError:
- from pipes import quote
-
-try:
- from urllib.request import urlretrieve
-except ImportError:
- from urllib import urlretrieve
-
-try:
- xrange = xrange
-except NameError:
- xrange = range
-
-try:
- basestring = basestring
-except NameError:
- basestring = str
-
-
-def itervalues(o):
- try:
- return o.itervalues()
- except AttributeError:
- return o.values()
-
-
-def iteritems(o):
- try:
- return o.iteritems()
- except AttributeError:
- return o.items()
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index 4cacf7c..0b2893f 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -34,8 +34,6 @@
import gn_utils
-from compat import itervalues
-
ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Arguments for the GN output directory.
@@ -617,7 +615,7 @@
self.modules[module.name] = module
def to_string(self, output):
- for m in sorted(itervalues(self.modules), key=lambda m: m.name):
+ for m in sorted(self.modules.values(), key=lambda m: m.name):
m.to_string(output)
diff --git a/tools/gn2bp/gn_utils.py b/tools/gn2bp/gn_utils.py
index 91d7a32..7b54213 100644
--- a/tools/gn2bp/gn_utils.py
+++ b/tools/gn2bp/gn_utils.py
@@ -25,7 +25,6 @@
import shutil
import subprocess
import sys
-from compat import iteritems
BUILDFLAGS_TARGET = '//gn:gen_buildflags'
GEN_VERSION_TARGET = '//src/base:version_gen_h'
@@ -362,7 +361,7 @@
def __repr__(self):
return json.dumps({
k: (list(sorted(v)) if isinstance(v, set) else v)
- for (k, v) in iteritems(self.__dict__)
+ for (k, v) in self.__dict__.items()
},
indent=4,
sort_keys=True)