зеркало из https://github.com/electron/electron.git
chore: remove py2 compatibility code (#40375)
This commit is contained in:
Родитель
bc1ba1fe9d
Коммит
425efb5e47
|
@ -1,4 +1,4 @@
|
||||||
from __future__ import print_function
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
import os
|
import os
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from __future__ import print_function
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from __future__ import unicode_literals
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from __future__ import print_function
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from __future__ import print_function
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from __future__ import print_function
|
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from __future__ import print_function
|
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
import ast
|
import ast
|
||||||
import os
|
import os
|
||||||
import pprint
|
import pprint
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,6 @@ Everything here should be project agnostic: it shouldn't rely on project's
|
||||||
structure, or make assumptions about the passed arguments or calls' outcomes.
|
structure, or make assumptions about the passed arguments or calls' outcomes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
import posixpath
|
import posixpath
|
||||||
|
@ -229,14 +227,6 @@ def remove_patch_filename(patch):
|
||||||
force_keep_next_line = l.startswith('Subject: ')
|
force_keep_next_line = l.startswith('Subject: ')
|
||||||
|
|
||||||
|
|
||||||
def to_utf8(patch):
|
|
||||||
"""Python 2/3 compatibility: unicode has been renamed to str in Python3"""
|
|
||||||
if sys.version_info[0] >= 3:
|
|
||||||
return str(patch, "utf-8")
|
|
||||||
|
|
||||||
return unicode(patch, "utf-8")
|
|
||||||
|
|
||||||
|
|
||||||
def export_patches(repo, out_dir, patch_range=None, dry_run=False):
|
def export_patches(repo, out_dir, patch_range=None, dry_run=False):
|
||||||
if not os.path.exists(repo):
|
if not os.path.exists(repo):
|
||||||
sys.stderr.write(
|
sys.stderr.write(
|
||||||
|
@ -263,7 +253,7 @@ def export_patches(repo, out_dir, patch_range=None, dry_run=False):
|
||||||
for patch in patches:
|
for patch in patches:
|
||||||
filename = get_file_name(patch)
|
filename = get_file_name(patch)
|
||||||
filepath = posixpath.join(out_dir, filename)
|
filepath = posixpath.join(out_dir, filename)
|
||||||
existing_patch = to_utf8(io.open(filepath, 'rb').read())
|
existing_patch = str(io.open(filepath, 'rb').read(), 'utf-8')
|
||||||
formatted_patch = join_patch(patch)
|
formatted_patch = join_patch(patch)
|
||||||
if formatted_patch != existing_patch:
|
if formatted_patch != existing_patch:
|
||||||
bad_patches.append(filename)
|
bad_patches.append(filename)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from __future__ import print_function
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -10,11 +10,6 @@ PYYAML_LIB_DIR = os.path.join(SRC_DIR, 'third_party', 'pyyaml', 'lib')
|
||||||
sys.path.append(PYYAML_LIB_DIR)
|
sys.path.append(PYYAML_LIB_DIR)
|
||||||
import yaml #pylint: disable=wrong-import-position,wrong-import-order
|
import yaml #pylint: disable=wrong-import-position,wrong-import-order
|
||||||
|
|
||||||
try:
|
|
||||||
basestring # Python 2
|
|
||||||
except NameError: # Python 3
|
|
||||||
basestring = str # pylint: disable=redefined-builtin
|
|
||||||
|
|
||||||
|
|
||||||
class Verbosity:
|
class Verbosity:
|
||||||
CHATTY = 'chatty' # stdout and stderr
|
CHATTY = 'chatty' # stdout and stderr
|
||||||
|
@ -148,7 +143,7 @@ class TestsList():
|
||||||
if isinstance(value, dict):
|
if isinstance(value, dict):
|
||||||
return value
|
return value
|
||||||
|
|
||||||
if isinstance(value, basestring):
|
if isinstance(value, str):
|
||||||
return {value: None}
|
return {value: None}
|
||||||
|
|
||||||
raise AssertionError("unexpected shorthand type: {}".format(type(value)))
|
raise AssertionError("unexpected shorthand type: {}".format(type(value)))
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
import contextlib
|
import contextlib
|
||||||
import errno
|
import errno
|
||||||
import json
|
import json
|
||||||
|
@ -8,11 +7,7 @@ import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
# Python 3 / 2 compat import
|
from urllib.request import urlopen
|
||||||
try:
|
|
||||||
from urllib.request import urlopen
|
|
||||||
except ImportError:
|
|
||||||
from urllib2 import urlopen
|
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
# from lib.config import is_verbose_mode
|
# from lib.config import is_verbose_mode
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
|
@ -168,13 +166,7 @@ def main():
|
||||||
traceback.print_exc(file=sys.stderr)
|
traceback.print_exc(file=sys.stderr)
|
||||||
return 0
|
return 0
|
||||||
elif args.operation == "set":
|
elif args.operation == "set":
|
||||||
# Python 2/3 compatibility
|
answer = input(
|
||||||
try:
|
|
||||||
user_input = raw_input
|
|
||||||
except NameError:
|
|
||||||
user_input = input
|
|
||||||
|
|
||||||
answer = user_input(
|
|
||||||
"WARNING: Manually setting mtimes could mess up your build. "
|
"WARNING: Manually setting mtimes could mess up your build. "
|
||||||
"If you're sure, type yes: "
|
"If you're sure, type yes: "
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
import argparse
|
import argparse
|
||||||
import datetime
|
import datetime
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
|
@ -7,8 +7,6 @@ It runs over multiple files and directories in parallel.
|
||||||
A diff output is produced and a sensible exit code is returned.
|
A diff output is produced and a sensible exit code is returned.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import print_function, unicode_literals
|
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import codecs
|
import codecs
|
||||||
import difflib
|
import difflib
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from __future__ import print_function
|
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from __future__ import print_function
|
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from __future__ import print_function
|
|
||||||
import argparse
|
import argparse
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
import argparse
|
import argparse
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
|
|
Загрузка…
Ссылка в новой задаче