Bug 1967109 - Remove usages of six in python directory. r=firefox-build-system-reviewers,glandium
Also removes six from deps of mozterm's setup.py as only usages of six in it were removed last month in D245270. Differential Revision: https://phabricator.services.mozilla.com/D249889
This commit is contained in:
committed by
ahochheiden@mozilla.com
parent
0888571e1e
commit
b9c9bb727f
@@ -25,11 +25,10 @@ import binascii
|
|||||||
import hashlib
|
import hashlib
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import urllib.parse as urlparse
|
||||||
|
|
||||||
import dlmanager
|
import dlmanager
|
||||||
import mozpack.path as mozpath
|
import mozpack.path as mozpath
|
||||||
import six
|
|
||||||
import six.moves.urllib.parse as urlparse
|
|
||||||
|
|
||||||
from mozbuild.dirutils import mkdir
|
from mozbuild.dirutils import mkdir
|
||||||
|
|
||||||
@@ -179,7 +178,7 @@ class ArtifactCache:
|
|||||||
# extract the build ID from the downloaded artifact and use it to make a
|
# extract the build ID from the downloaded artifact and use it to make a
|
||||||
# human readable unique name, but extracting build IDs is time consuming
|
# human readable unique name, but extracting build IDs is time consuming
|
||||||
# (especially on Mac OS X, where we must mount a large DMG file).
|
# (especially on Mac OS X, where we must mount a large DMG file).
|
||||||
hash = hashlib.sha256(six.ensure_binary(url)).hexdigest()[:16]
|
hash = hashlib.sha256(url.encode()).hexdigest()[:16]
|
||||||
# Strip query string and fragments.
|
# Strip query string and fragments.
|
||||||
basename = os.path.basename(urlparse.urlparse(url).path)
|
basename = os.path.basename(urlparse.urlparse(url).path)
|
||||||
fname = hash + "-" + basename
|
fname = hash + "-" + basename
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import sys
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import mozpack.path as mozpath
|
import mozpack.path as mozpath
|
||||||
import six
|
|
||||||
from mach.mixin.process import ProcessExecutionMixin
|
from mach.mixin.process import ProcessExecutionMixin
|
||||||
from mozboot.mozconfig import MozconfigFindException
|
from mozboot.mozconfig import MozconfigFindException
|
||||||
from mozfile import which
|
from mozfile import which
|
||||||
@@ -279,7 +278,7 @@ class MozbuildObject(ProcessExecutionMixin):
|
|||||||
# the environment variable, which has an impact on autodetection (when
|
# the environment variable, which has an impact on autodetection (when
|
||||||
# path is MozconfigLoader.AUTODETECT), and memoization wouldn't account
|
# path is MozconfigLoader.AUTODETECT), and memoization wouldn't account
|
||||||
# for it without the explicit (unused) argument.
|
# for it without the explicit (unused) argument.
|
||||||
out = six.StringIO()
|
out = io.StringIO()
|
||||||
env = os.environ
|
env = os.environ
|
||||||
if path and path != MozconfigLoader.AUTODETECT:
|
if path and path != MozconfigLoader.AUTODETECT:
|
||||||
env = dict(env)
|
env = dict(env)
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import xml.etree.ElementTree as ET
|
|||||||
from types import SimpleNamespace
|
from types import SimpleNamespace
|
||||||
|
|
||||||
import mozpack.path as mozpath
|
import mozpack.path as mozpath
|
||||||
import six
|
|
||||||
import yaml
|
import yaml
|
||||||
from mach.decorators import Command, CommandArgument, SubCommand
|
from mach.decorators import Command, CommandArgument, SubCommand
|
||||||
from mach.main import Mach
|
from mach.main import Mach
|
||||||
@@ -1847,7 +1846,7 @@ def _parse_xml_output(path, clang_output):
|
|||||||
list of patches, and calculates line level informations from the
|
list of patches, and calculates line level informations from the
|
||||||
character level provided changes.
|
character level provided changes.
|
||||||
"""
|
"""
|
||||||
content = six.ensure_str(open(path).read())
|
content = open(path).read()
|
||||||
|
|
||||||
def _nb_of_lines(start, end):
|
def _nb_of_lines(start, end):
|
||||||
return len(content[start:end].splitlines())
|
return len(content[start:end].splitlines())
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import os
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
import mozpack.path as mozpath
|
import mozpack.path as mozpath
|
||||||
import six
|
|
||||||
|
|
||||||
from mozbuild.util import hash_file
|
from mozbuild.util import hash_file
|
||||||
|
|
||||||
@@ -253,7 +252,7 @@ class WarningsDatabase:
|
|||||||
normalized = list(v2)
|
normalized = list(v2)
|
||||||
obj["files"][k][k2] = normalized
|
obj["files"][k][k2] = normalized
|
||||||
|
|
||||||
to_write = six.ensure_text(json.dumps(obj, indent=2))
|
to_write = json.dumps(obj, indent=2)
|
||||||
fh.write(to_write)
|
fh.write(to_write)
|
||||||
|
|
||||||
def deserialize(self, fh):
|
def deserialize(self, fh):
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
import codecs
|
import builtins
|
||||||
import inspect
|
import inspect
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
@@ -14,8 +14,6 @@ from contextlib import contextmanager
|
|||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
import mozpack.path as mozpath
|
import mozpack.path as mozpath
|
||||||
import six
|
|
||||||
from six.moves import builtins as __builtin__
|
|
||||||
|
|
||||||
from mozbuild.configure.help import HelpFormatter
|
from mozbuild.configure.help import HelpFormatter
|
||||||
from mozbuild.configure.options import (
|
from mozbuild.configure.options import (
|
||||||
@@ -32,7 +30,6 @@ from mozbuild.util import (
|
|||||||
ReadOnlyNamespace,
|
ReadOnlyNamespace,
|
||||||
memoize,
|
memoize,
|
||||||
memoized_property,
|
memoized_property,
|
||||||
system_encoding,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# TRACE logging level, below (thus more verbose than) DEBUG
|
# TRACE logging level, below (thus more verbose than) DEBUG
|
||||||
@@ -299,7 +296,7 @@ class ConfigureSandbox(dict):
|
|||||||
# files more python3-ready.
|
# files more python3-ready.
|
||||||
BUILTINS = ReadOnlyDict(
|
BUILTINS = ReadOnlyDict(
|
||||||
{
|
{
|
||||||
b: getattr(__builtin__, b, None)
|
b: getattr(builtins, b, None)
|
||||||
for b in (
|
for b in (
|
||||||
"AssertionError",
|
"AssertionError",
|
||||||
"False",
|
"False",
|
||||||
@@ -433,7 +430,7 @@ class ConfigureSandbox(dict):
|
|||||||
def wrapped(*args, **kwargs):
|
def wrapped(*args, **kwargs):
|
||||||
out_args = [
|
out_args = [
|
||||||
(
|
(
|
||||||
six.ensure_text(arg, encoding=encoding or "utf-8")
|
arg.decode(encoding=encoding or "utf-8")
|
||||||
if isinstance(arg, bytes)
|
if isinstance(arg, bytes)
|
||||||
else arg
|
else arg
|
||||||
)
|
)
|
||||||
@@ -1055,45 +1052,12 @@ class ConfigureSandbox(dict):
|
|||||||
|
|
||||||
return ReadOnlyNamespace(**wrapped_subprocess)
|
return ReadOnlyNamespace(**wrapped_subprocess)
|
||||||
|
|
||||||
@memoized_property
|
|
||||||
def _wrapped_six(self):
|
|
||||||
if six.PY3:
|
|
||||||
return six
|
|
||||||
wrapped_six = {}
|
|
||||||
exec("from six import *", {}, wrapped_six)
|
|
||||||
wrapped_six_moves = {}
|
|
||||||
exec("from six.moves import *", {}, wrapped_six_moves)
|
|
||||||
wrapped_six_moves_builtins = {}
|
|
||||||
exec("from six.moves.builtins import *", {}, wrapped_six_moves_builtins)
|
|
||||||
|
|
||||||
# Special case for the open() builtin, because otherwise, using it
|
|
||||||
# fails with "IOError: file() constructor not accessible in
|
|
||||||
# restricted mode". We also make open() look more like python 3's,
|
|
||||||
# decoding to unicode strings unless the mode says otherwise.
|
|
||||||
def wrapped_open(name, mode=None, buffering=None):
|
|
||||||
args = (name,)
|
|
||||||
kwargs = {}
|
|
||||||
if buffering is not None:
|
|
||||||
kwargs["buffering"] = buffering
|
|
||||||
if mode is not None:
|
|
||||||
args += (mode,)
|
|
||||||
if "b" in mode:
|
|
||||||
return open(*args, **kwargs)
|
|
||||||
kwargs["encoding"] = system_encoding
|
|
||||||
return codecs.open(*args, **kwargs)
|
|
||||||
|
|
||||||
wrapped_six_moves_builtins["open"] = wrapped_open
|
|
||||||
wrapped_six_moves["builtins"] = ReadOnlyNamespace(**wrapped_six_moves_builtins)
|
|
||||||
wrapped_six["moves"] = ReadOnlyNamespace(**wrapped_six_moves)
|
|
||||||
|
|
||||||
return ReadOnlyNamespace(**wrapped_six)
|
|
||||||
|
|
||||||
def _get_one_import(self, _from, _import, _as, glob):
|
def _get_one_import(self, _from, _import, _as, glob):
|
||||||
"""Perform the given import, placing the result into the dict glob."""
|
"""Perform the given import, placing the result into the dict glob."""
|
||||||
if not _from and _import == "__builtin__":
|
if not _from and _import == "__builtin__":
|
||||||
raise Exception("Importing __builtin__ is forbidden")
|
raise Exception("Importing __builtin__ is forbidden")
|
||||||
if _from == "__builtin__":
|
if _from == "__builtin__":
|
||||||
_from = "six.moves.builtins"
|
_from = "builtins"
|
||||||
# The special `__sandbox__` module gives access to the sandbox
|
# The special `__sandbox__` module gives access to the sandbox
|
||||||
# instance.
|
# instance.
|
||||||
if not _from and _import == "__sandbox__":
|
if not _from and _import == "__sandbox__":
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
import codecs
|
|
||||||
import io
|
import io
|
||||||
import itertools
|
import itertools
|
||||||
import locale
|
import locale
|
||||||
@@ -12,7 +11,6 @@ import sys
|
|||||||
from collections import deque
|
from collections import deque
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
|
||||||
import six
|
|
||||||
from looseversion import LooseVersion
|
from looseversion import LooseVersion
|
||||||
|
|
||||||
|
|
||||||
@@ -76,24 +74,8 @@ class ConfigureOutputHandler(logging.Handler):
|
|||||||
def __init__(self, stdout=sys.stdout, stderr=sys.stderr, maxlen=20):
|
def __init__(self, stdout=sys.stdout, stderr=sys.stderr, maxlen=20):
|
||||||
super(ConfigureOutputHandler, self).__init__()
|
super(ConfigureOutputHandler, self).__init__()
|
||||||
|
|
||||||
# Python has this feature where it sets the encoding of pipes to
|
self._stdout = stdout
|
||||||
# ascii, which blatantly fails when trying to print out non-ascii.
|
self._stderr = stderr if stdout != stderr else self._stdout
|
||||||
def fix_encoding(fh):
|
|
||||||
if six.PY3:
|
|
||||||
return fh
|
|
||||||
try:
|
|
||||||
isatty = fh.isatty()
|
|
||||||
except AttributeError:
|
|
||||||
isatty = True
|
|
||||||
|
|
||||||
if not isatty:
|
|
||||||
encoding = getpreferredencoding()
|
|
||||||
if encoding:
|
|
||||||
return codecs.getwriter(encoding)(fh)
|
|
||||||
return fh
|
|
||||||
|
|
||||||
self._stdout = fix_encoding(stdout)
|
|
||||||
self._stderr = fix_encoding(stderr) if stdout != stderr else self._stdout
|
|
||||||
try:
|
try:
|
||||||
fd1 = self._stdout.fileno()
|
fd1 = self._stdout.fileno()
|
||||||
fd2 = self._stderr.fileno()
|
fd2 = self._stderr.fileno()
|
||||||
@@ -126,7 +108,7 @@ class ConfigureOutputHandler(logging.Handler):
|
|||||||
try:
|
try:
|
||||||
if record.levelno == logging.INFO:
|
if record.levelno == logging.INFO:
|
||||||
stream = self._stdout
|
stream = self._stdout
|
||||||
msg = six.ensure_text(record.getMessage())
|
msg = record.getMessage()
|
||||||
if self._stdout_waiting == self.INTERRUPTED and self._same_output:
|
if self._stdout_waiting == self.INTERRUPTED and self._same_output:
|
||||||
msg = " ... %s" % msg
|
msg = " ... %s" % msg
|
||||||
self._stdout_waiting = msg.endswith("... ")
|
self._stdout_waiting = msg.endswith("... ")
|
||||||
@@ -210,7 +192,8 @@ class LineIO:
|
|||||||
self._errors = errors
|
self._errors = errors
|
||||||
|
|
||||||
def write(self, buf):
|
def write(self, buf):
|
||||||
buf = six.ensure_text(buf, encoding=self._encoding or "utf-8")
|
if isinstance(buf, bytes):
|
||||||
|
buf = buf.decode(encoding=self._encoding or "utf-8")
|
||||||
lines = buf.splitlines()
|
lines = buf.splitlines()
|
||||||
if not lines:
|
if not lines:
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ from collections import Counter, OrderedDict, namedtuple
|
|||||||
from itertools import dropwhile, islice, takewhile
|
from itertools import dropwhile, islice, takewhile
|
||||||
from textwrap import TextWrapper
|
from textwrap import TextWrapper
|
||||||
|
|
||||||
import six
|
|
||||||
from mach.site import CommandSiteManager
|
from mach.site import CommandSiteManager
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -362,8 +361,8 @@ class BuildMonitor(MozbuildObject):
|
|||||||
with open(
|
with open(
|
||||||
build_resources_profile_path, "w", encoding="utf-8", newline="\n"
|
build_resources_profile_path, "w", encoding="utf-8", newline="\n"
|
||||||
) as fh:
|
) as fh:
|
||||||
to_write = six.ensure_text(
|
to_write = json.dumps(
|
||||||
json.dumps(self.resources.as_profile(), separators=(",", ":"))
|
self.resources.as_profile(), separators=(",", ":")
|
||||||
)
|
)
|
||||||
fh.write(to_write)
|
fh.write(to_write)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -914,7 +913,6 @@ class CCacheStats:
|
|||||||
self._parse_line(line)
|
self._parse_line(line)
|
||||||
|
|
||||||
def _parse_line(self, line):
|
def _parse_line(self, line):
|
||||||
line = six.ensure_text(line)
|
|
||||||
for stat_key, stat_description in self.STATS_KEYS:
|
for stat_key, stat_description in self.STATS_KEYS:
|
||||||
if line.startswith(stat_description):
|
if line.startswith(stat_description):
|
||||||
raw_value = self._strip_prefix(line, stat_description)
|
raw_value = self._strip_prefix(line, stat_description)
|
||||||
@@ -1714,17 +1712,16 @@ class BuildDriver(MozbuildObject):
|
|||||||
def _write_mozconfig_json(self):
|
def _write_mozconfig_json(self):
|
||||||
mozconfig_json = mozpath.join(self.topobjdir, ".mozconfig.json")
|
mozconfig_json = mozpath.join(self.topobjdir, ".mozconfig.json")
|
||||||
with FileAvoidWrite(mozconfig_json) as fh:
|
with FileAvoidWrite(mozconfig_json) as fh:
|
||||||
to_write = six.ensure_text(
|
to_write = json.dumps(
|
||||||
json.dumps(
|
{
|
||||||
{
|
"topsrcdir": self.topsrcdir,
|
||||||
"topsrcdir": self.topsrcdir,
|
"topobjdir": self.topobjdir,
|
||||||
"topobjdir": self.topobjdir,
|
"mozconfig": self.mozconfig,
|
||||||
"mozconfig": self.mozconfig,
|
},
|
||||||
},
|
sort_keys=True,
|
||||||
sort_keys=True,
|
indent=2,
|
||||||
indent=2,
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# json.dumps in python2 inserts some trailing whitespace while
|
# json.dumps in python2 inserts some trailing whitespace while
|
||||||
# json.dumps in python3 does not, which defeats the FileAvoidWrite
|
# json.dumps in python3 does not, which defeats the FileAvoidWrite
|
||||||
# mechanism. Strip the trailing whitespace to avoid rewriting this
|
# mechanism. Strip the trailing whitespace to avoid rewriting this
|
||||||
@@ -1852,7 +1849,7 @@ class BuildDriver(MozbuildObject):
|
|||||||
# We'll just use an empty substs if there is no config.
|
# We'll just use an empty substs if there is no config.
|
||||||
pass
|
pass
|
||||||
clobberer = Clobberer(self.topsrcdir, self.topobjdir, substs)
|
clobberer = Clobberer(self.topsrcdir, self.topobjdir, substs)
|
||||||
clobber_output = six.StringIO()
|
clobber_output = io.StringIO()
|
||||||
res = clobberer.maybe_do_clobber(os.getcwd(), auto_clobber, clobber_output)
|
res = clobberer.maybe_do_clobber(os.getcwd(), auto_clobber, clobber_output)
|
||||||
clobber_output.seek(0)
|
clobber_output.seek(0)
|
||||||
for line in clobber_output.readlines():
|
for line in clobber_output.readlines():
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ from collections import Counter, OrderedDict
|
|||||||
from types import FunctionType
|
from types import FunctionType
|
||||||
|
|
||||||
import mozpack.path as mozpath
|
import mozpack.path as mozpath
|
||||||
import six
|
|
||||||
|
|
||||||
from mozbuild.util import (
|
from mozbuild.util import (
|
||||||
HierarchicalStringList,
|
HierarchicalStringList,
|
||||||
@@ -827,7 +826,7 @@ class PathMeta(type):
|
|||||||
return super(PathMeta, cls).__call__(context, value)
|
return super(PathMeta, cls).__call__(context, value)
|
||||||
|
|
||||||
|
|
||||||
class Path(six.with_metaclass(PathMeta, ContextDerivedValue, str)):
|
class Path(ContextDerivedValue, str, metaclass=PathMeta):
|
||||||
"""Stores and resolves a source path relative to a given context
|
"""Stores and resolves a source path relative to a given context
|
||||||
|
|
||||||
This class is used as a backing type for some of the sandbox variables.
|
This class is used as a backing type for some of the sandbox variables.
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ from collections.abc import Iterable
|
|||||||
import gyp
|
import gyp
|
||||||
import gyp.msvs_emulation
|
import gyp.msvs_emulation
|
||||||
import mozpack.path as mozpath
|
import mozpack.path as mozpath
|
||||||
import six
|
|
||||||
from mozpack.files import FileFinder
|
from mozpack.files import FileFinder
|
||||||
|
|
||||||
from mozbuild import shellutil
|
from mozbuild import shellutil
|
||||||
@@ -227,7 +226,7 @@ def process_gyp_result(
|
|||||||
elif spec["type"] in ("static_library", "shared_library", "executable"):
|
elif spec["type"] in ("static_library", "shared_library", "executable"):
|
||||||
# Remove leading 'lib' from the target_name if any, and use as
|
# Remove leading 'lib' from the target_name if any, and use as
|
||||||
# library name.
|
# library name.
|
||||||
name = six.ensure_text(spec["target_name"])
|
name = spec["target_name"]
|
||||||
if spec["type"] in ("static_library", "shared_library"):
|
if spec["type"] in ("static_library", "shared_library"):
|
||||||
if name.startswith("lib"):
|
if name.startswith("lib"):
|
||||||
name = name[3:]
|
name = name[3:]
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import weakref
|
import weakref
|
||||||
|
|
||||||
import six
|
|
||||||
from mozpack.files import FileFinder
|
from mozpack.files import FileFinder
|
||||||
|
|
||||||
from mozbuild.util import ReadOnlyDict
|
from mozbuild.util import ReadOnlyDict
|
||||||
@@ -154,7 +153,7 @@ class Sandbox(dict):
|
|||||||
assert os.path.isabs(path)
|
assert os.path.isabs(path)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
source = six.ensure_text(self._finder.get(path).read())
|
source = self._finder.get(path).read().decode()
|
||||||
except Exception:
|
except Exception:
|
||||||
raise SandboxLoadError(
|
raise SandboxLoadError(
|
||||||
self._context.source_stack, sys.exc_info()[2], read_error=path
|
self._context.source_stack, sys.exc_info()[2], read_error=path
|
||||||
|
|||||||
@@ -1687,6 +1687,8 @@ def _run_android(
|
|||||||
no_attach=False,
|
no_attach=False,
|
||||||
use_existing_process=False,
|
use_existing_process=False,
|
||||||
):
|
):
|
||||||
|
from shlex import quote as shlex_quote
|
||||||
|
|
||||||
from mozrunner.devices.android_device import (
|
from mozrunner.devices.android_device import (
|
||||||
InstallIntent,
|
InstallIntent,
|
||||||
UninstallIntent,
|
UninstallIntent,
|
||||||
@@ -1694,7 +1696,6 @@ def _run_android(
|
|||||||
metadata_for_app,
|
metadata_for_app,
|
||||||
verify_android_device,
|
verify_android_device,
|
||||||
)
|
)
|
||||||
from six.moves import shlex_quote
|
|
||||||
|
|
||||||
metadata = metadata_for_app(app)
|
metadata = metadata_for_app(app)
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import subprocess
|
|||||||
from mozboot.util import get_tools_dir
|
from mozboot.util import get_tools_dir
|
||||||
from mozfile import which
|
from mozfile import which
|
||||||
from packaging.version import Version
|
from packaging.version import Version
|
||||||
from six import PY3
|
|
||||||
|
|
||||||
NODE_MIN_VERSION = Version("12.22.12")
|
NODE_MIN_VERSION = Version("12.22.12")
|
||||||
NPM_MIN_VERSION = Version("6.14.16")
|
NPM_MIN_VERSION = Version("6.14.16")
|
||||||
@@ -54,7 +53,7 @@ def check_executable_version(exe, wrap_call_with_node=False):
|
|||||||
if binary:
|
if binary:
|
||||||
out = (
|
out = (
|
||||||
subprocess.check_output(
|
subprocess.check_output(
|
||||||
[binary, exe, "--version"], universal_newlines=PY3
|
[binary, exe, "--version"], universal_newlines=True
|
||||||
)
|
)
|
||||||
.lstrip("v")
|
.lstrip("v")
|
||||||
.rstrip()
|
.rstrip()
|
||||||
@@ -64,7 +63,7 @@ def check_executable_version(exe, wrap_call_with_node=False):
|
|||||||
# direct.
|
# direct.
|
||||||
if not out:
|
if not out:
|
||||||
out = (
|
out = (
|
||||||
subprocess.check_output([exe, "--version"], universal_newlines=PY3)
|
subprocess.check_output([exe, "--version"], universal_newlines=True)
|
||||||
.lstrip("v")
|
.lstrip("v")
|
||||||
.rstrip()
|
.rstrip()
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
import configparser
|
||||||
|
|
||||||
from mozpack.files import FileFinder
|
from mozpack.files import FileFinder
|
||||||
from six import string_types
|
|
||||||
from six.moves import configparser
|
|
||||||
|
|
||||||
|
|
||||||
def get_application_ini_value(
|
def get_application_ini_value(
|
||||||
@@ -36,7 +36,7 @@ def get_application_ini_values(finder_or_application_directory, *args):
|
|||||||
|
|
||||||
Raises an `Exception` if any string is not found."""
|
Raises an `Exception` if any string is not found."""
|
||||||
|
|
||||||
if isinstance(finder_or_application_directory, string_types):
|
if isinstance(finder_or_application_directory, str):
|
||||||
finder = FileFinder(finder_or_application_directory)
|
finder = FileFinder(finder_or_application_directory)
|
||||||
else:
|
else:
|
||||||
finder = finder_or_application_directory
|
finder = finder_or_application_directory
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import time
|
|||||||
import urllib
|
import urllib
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from shlex import quote as shlex_quote
|
||||||
|
|
||||||
import mozpack.path as mozpath
|
import mozpack.path as mozpath
|
||||||
from mach.util import get_state_dir
|
from mach.util import get_state_dir
|
||||||
@@ -31,7 +32,6 @@ from mozpack.files import FileFinder, JarFinder
|
|||||||
from mozpack.manifests import InstallManifest
|
from mozpack.manifests import InstallManifest
|
||||||
from mozpack.mozjar import JarReader
|
from mozpack.mozjar import JarReader
|
||||||
from mozpack.packager.unpack import UnpackFinder
|
from mozpack.packager.unpack import UnpackFinder
|
||||||
from six.moves import shlex_quote
|
|
||||||
|
|
||||||
from mozbuild.configure import confvars
|
from mozbuild.configure import confvars
|
||||||
from mozbuild.dirutils import ensureParentDir
|
from mozbuild.dirutils import ensureParentDir
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ import sys
|
|||||||
from io import BytesIO, StringIO
|
from io import BytesIO, StringIO
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from mozbuild.dirutils import ensureParentDir
|
from mozbuild.dirutils import ensureParentDir
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -201,7 +199,9 @@ class FileAvoidWrite(BytesIO):
|
|||||||
self._binary_mode = "b" in readmode
|
self._binary_mode = "b" in readmode
|
||||||
|
|
||||||
def write(self, buf):
|
def write(self, buf):
|
||||||
BytesIO.write(self, six.ensure_binary(buf))
|
if isinstance(buf, str):
|
||||||
|
buf = buf.encode()
|
||||||
|
BytesIO.write(self, buf)
|
||||||
|
|
||||||
def avoid_writing_to_file(self):
|
def avoid_writing_to_file(self):
|
||||||
self._write_to_file = False
|
self._write_to_file = False
|
||||||
@@ -218,8 +218,12 @@ class FileAvoidWrite(BytesIO):
|
|||||||
of the result.
|
of the result.
|
||||||
"""
|
"""
|
||||||
# Use binary data if the caller explicitly asked for it.
|
# Use binary data if the caller explicitly asked for it.
|
||||||
ensure = six.ensure_binary if self._binary_mode else six.ensure_text
|
buf = self.getvalue()
|
||||||
buf = ensure(self.getvalue())
|
if self._binary_mode:
|
||||||
|
if isinstance(buf, str):
|
||||||
|
buf = buf.encode()
|
||||||
|
elif isinstance(buf, bytes):
|
||||||
|
buf = buf.decode()
|
||||||
|
|
||||||
BytesIO.close(self)
|
BytesIO.close(self)
|
||||||
existed = False
|
existed = False
|
||||||
@@ -247,9 +251,6 @@ class FileAvoidWrite(BytesIO):
|
|||||||
writemode = "w"
|
writemode = "w"
|
||||||
if self._binary_mode:
|
if self._binary_mode:
|
||||||
writemode += "b"
|
writemode += "b"
|
||||||
buf = six.ensure_binary(buf)
|
|
||||||
else:
|
|
||||||
buf = six.ensure_text(buf)
|
|
||||||
path = Path(self.name)
|
path = Path(self.name)
|
||||||
if path.is_symlink():
|
if path.is_symlink():
|
||||||
# Migration to code autogeneration can encounter with existing symlinks, e.g. bug 1953858.
|
# Migration to code autogeneration can encounter with existing symlinks, e.g. bug 1953858.
|
||||||
@@ -402,11 +403,7 @@ class List(list):
|
|||||||
)
|
)
|
||||||
if key.step:
|
if key.step:
|
||||||
raise ValueError("List cannot be sliced with a nonzero step " "value")
|
raise ValueError("List cannot be sliced with a nonzero step " "value")
|
||||||
# Python 2 and Python 3 do this differently for some reason.
|
return super(List, self).__setitem__(key, val)
|
||||||
if six.PY2:
|
|
||||||
return super(List, self).__setslice__(key.start, key.stop, val)
|
|
||||||
else:
|
|
||||||
return super(List, self).__setitem__(key, val)
|
|
||||||
return super(List, self).__setitem__(key, val)
|
return super(List, self).__setitem__(key, val)
|
||||||
|
|
||||||
def __setslice__(self, i, j, sequence):
|
def __setslice__(self, i, j, sequence):
|
||||||
@@ -1071,13 +1068,13 @@ def group_unified_files(files, unified_prefix, unified_suffix, files_per_unified
|
|||||||
dummy_fill_value = ("dummy",)
|
dummy_fill_value = ("dummy",)
|
||||||
|
|
||||||
def filter_out_dummy(iterable):
|
def filter_out_dummy(iterable):
|
||||||
return six.moves.filter(lambda x: x != dummy_fill_value, iterable)
|
return filter(lambda x: x != dummy_fill_value, iterable)
|
||||||
|
|
||||||
# From the itertools documentation, slightly modified:
|
# From the itertools documentation, slightly modified:
|
||||||
def grouper(n, iterable):
|
def grouper(n, iterable):
|
||||||
"grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
|
"grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
|
||||||
args = [iter(iterable)] * n
|
args = [iter(iterable)] * n
|
||||||
return six.moves.zip_longest(fillvalue=dummy_fill_value, *args)
|
return itertools.zip_longest(fillvalue=dummy_fill_value, *args)
|
||||||
|
|
||||||
for i, unified_group in enumerate(grouper(files_per_unified_file, files)):
|
for i, unified_group in enumerate(grouper(files_per_unified_file, files)):
|
||||||
just_the_filenames = list(filter_out_dummy(unified_group))
|
just_the_filenames = list(filter_out_dummy(unified_group))
|
||||||
@@ -1093,7 +1090,7 @@ def pair(iterable):
|
|||||||
[(1,2), (3,4), (5,6)]
|
[(1,2), (3,4), (5,6)]
|
||||||
"""
|
"""
|
||||||
i = iter(iterable)
|
i = iter(iterable)
|
||||||
return six.moves.zip_longest(i, i)
|
return itertools.zip_longest(i, i)
|
||||||
|
|
||||||
|
|
||||||
def pairwise(iterable):
|
def pairwise(iterable):
|
||||||
@@ -1239,7 +1236,6 @@ def hexdump(buf):
|
|||||||
"""
|
"""
|
||||||
Returns a list of hexdump-like lines corresponding to the given input buffer.
|
Returns a list of hexdump-like lines corresponding to the given input buffer.
|
||||||
"""
|
"""
|
||||||
assert six.PY3
|
|
||||||
off_format = f"%0{len(str(len(buf)))}x "
|
off_format = f"%0{len(str(len(buf)))}x "
|
||||||
lines = []
|
lines = []
|
||||||
for off in range(0, len(buf), 16):
|
for off in range(0, len(buf), 16):
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
VERSION = "1.0.0"
|
VERSION = "1.0.0"
|
||||||
DEPS = ["six >= 1.13.0"]
|
DEPS = []
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="mozterm",
|
name="mozterm",
|
||||||
|
|||||||
Reference in New Issue
Block a user