use python3 in hack

This commit is contained in:
kidddddddddddddddddddddd 2023-01-11 11:45:42 +08:00
parent ca5c522080
commit cb6a1886c0
7 changed files with 15 additions and 21 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2015 The Kubernetes Authors.
#
@ -14,8 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
import argparse
import datetime
import difflib
@ -231,7 +229,7 @@ def get_regexs():
def main():
regexs = get_regexs()
refs = get_refs()
filenames = get_files(refs.keys())
filenames = get_files(list(refs.keys()))
for filename in filenames:
if not file_passes(filename, refs, regexs):

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2016 The Kubernetes Authors.
#
@ -48,5 +48,5 @@ class TestBoilerplate(unittest.TestCase):
sys.stdout = old_stdout
self.assertEquals(
self.assertEqual(
output, ['././fail.go', '././fail.py'])

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2015 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2015 The Kubernetes Authors.
#

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2015 The Kubernetes Authors.
#
@ -14,8 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
import argparse
import os
import re
@ -107,7 +105,7 @@ def check_underscore_in_flags(rootdir, files):
print("Are you certain this flag should not have been declared with an - instead?")
l = list(new_excluded_flags)
l.sort()
print("%s" % "\n".join(l))
print(("%s" % "\n".join(l)))
sys.exit(1)
def main():

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2019 The Kubernetes Authors.
#
@ -14,8 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
import fnmatch
import os
import sys
@ -26,7 +24,7 @@ def get_gomod_dependencies(rootdir, components):
all_dependencies = {}
for component in components:
with open(os.path.join(rootdir, component, "go.mod")) as f:
print(component + " dependencies")
print((component + " dependencies"))
all_dependencies[component] = []
lines = list(set(f))
lines.sort()
@ -36,7 +34,7 @@ def get_gomod_dependencies(rootdir, components):
continue
if ("k8s.io/" + dep + " =>") not in line:
continue
print("\t"+dep)
print(("\t"+dep))
if dep not in all_dependencies[component]:
all_dependencies[component].append(dep)
return all_dependencies
@ -62,7 +60,7 @@ def main():
try:
import yaml
except ImportError:
print("Please install missing pyyaml module and re-run %s" % sys.argv[0])
print(("Please install missing pyyaml module and re-run %s" % sys.argv[0]))
sys.exit(1)
rules_dependencies = get_rules_dependencies(rootdir + rules_file)
@ -95,7 +93,7 @@ def main():
if "go" in branch:
raise Exception("go version must not be specified for master branch for destination %s" % rule["destination"])
print("processing : %s" % rule["destination"])
print(("processing : %s" % rule["destination"]))
if rule["destination"] not in gomod_dependencies:
raise Exception("missing go.mod for %s" % rule["destination"])
processed_repos.append(rule["destination"])
@ -116,7 +114,7 @@ def main():
if not found:
raise Exception("Please add %s as a dependency under destination %s in %s" % (dep, rule["destination"], rules_file))
else:
print(" found dependency %s" % dep)
print((" found dependency %s" % dep))
extraDeps = set(processed_deps) - set(gomod_dependencies[rule["destination"]])
if len(extraDeps) > 0:
raise Exception("extra dependencies in rules for %s: %s" % (rule["destination"], ','.join(str(s) for s in extraDeps)))

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# Copyright 2017 The Kubernetes Authors.
#