Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions mx.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
except ImportError:
from xml.etree.ElementTree import parse as etreeParse

import os, errno, time, subprocess, shlex, types, StringIO, zipfile, signal, tempfile, platform
import os, errno, time, subprocess, shlex, StringIO, zipfile, signal, tempfile, platform
import __builtin__
import textwrap
import socket
Expand Down Expand Up @@ -93,7 +93,7 @@ def update_commands(suite, new_commands):
if any of the format args are instances of callable, then they are called with an 'env' are before being
used in the call to str.format().
"""
suite_name = suite if isinstance(suite, basestring) else suite.name
suite_name = suite if isinstance(suite, str) else suite.name

_length_of_command = 4
for command_name, command_list in new_commands.iteritems():
Expand Down Expand Up @@ -1160,7 +1160,7 @@ def needsUpdate(self, newestInput):
it will be used instead of the usual platform suffix (provided by platformName()).
"""
def maven_artifact_id(self, platform=None):
if hasattr(self, 'maven') and isinstance(self.maven, types.DictType):
if hasattr(self, 'maven') and isinstance(self.maven, dict):
artifact_id = self.maven.get('artifactId', None)
if artifact_id:
return artifact_id
Expand All @@ -1170,7 +1170,7 @@ def maven_artifact_id(self, platform=None):
Provide maven groupId string for distribution.
"""
def maven_group_id(self):
if hasattr(self, 'maven') and isinstance(self.maven, types.DictType):
if hasattr(self, 'maven') and isinstance(self.maven, dict):
group_id = self.maven.get('groupId', None)
if group_id:
return group_id
Expand Down Expand Up @@ -1662,7 +1662,7 @@ def overlay_check(arcname):
# accumulate services
services_versions = sorted([v for v in services.keys() if isinstance(v, int)])
if services_versions:
acummulated_services = {n: set(p) for n, p in services.items() if isinstance(n, basestring)}
acummulated_services = {n: set(p) for n, p in services.items() if isinstance(n, str)}
for v in services_versions:
for service, providers in services[v].items():
providers_set = frozenset(providers)
Expand Down Expand Up @@ -2237,7 +2237,7 @@ def _extract_deps(layout, suite, distribution_name):

@staticmethod
def _as_source_dict(source, distribution_name, destination, path_substitutions=None, string_substitutions=None, distribution_object=None, context=None):
if isinstance(source, basestring):
if isinstance(source, str):
if ':' not in source:
abort("Invalid source '{}' in layout for '{}': should be of the form '<type>:<specification>'\n"
"Type could be `file`, `string`, `link`, `dependency` or `extracted-dependency`.".format(source, distribution_name), context=context)
Expand Down Expand Up @@ -2277,7 +2277,7 @@ def _as_source_dict(source, distribution_name, destination, path_substitutions=N
elif source_type == 'string':
source_dict['_str_'] = "string:" + source_dict['value']
if 'exclude' in source_dict:
if isinstance(source_dict['exclude'], basestring):
if isinstance(source_dict['exclude'], str):
source_dict['exclude'] = [source_dict['exclude']]
if path_substitutions and source_dict.get("path"):
source_dict["path"] = mx_subst.as_engine(path_substitutions).substitute(source_dict["path"], distribution=distribution_object)
Expand Down Expand Up @@ -2531,14 +2531,14 @@ def _rel_arcname(_source_file):
def _verify_layout(self):
output = realpath(self.get_output())
for destination, sources in self.layout.items():
if not isinstance(destination, basestring):
if not isinstance(destination, str):
abort("Destination (layout keys) should be a string", context=self)
if not isinstance(sources, list):
sources = [sources]
if not destination:
abort("Destination (layout keys) can not be empty", context=self)
for source in sources:
if not isinstance(source, (basestring, dict)):
if not isinstance(source, (str, dict)):
abort("Error in '{}': sources should be strings or dicts".format(destination), context=self)
if isabs(destination):
abort("Invalid destination: '{}': destination should not be absolute".format(destination), context=self)
Expand Down Expand Up @@ -7210,7 +7210,7 @@ def _mavenGroupId(suite):
return group_id
name = suite.name
else:
assert isinstance(suite, types.StringTypes)
assert isinstance(suite, str)
name = suite
return 'com.oracle.' + _map_to_maven_dist_name(name)

Expand Down Expand Up @@ -8303,17 +8303,17 @@ def _preload_suite_dict(self):
del sys.path[0]

def expand(value, context):
if isinstance(value, types.DictionaryType):
if isinstance(value, dict):
for n, v in value.iteritems():
value[n] = expand(v, context + [n])
elif isinstance(value, types.ListType):
elif isinstance(value, list):
for i in range(len(value)):
value[i] = expand(value[i], context + [str(i)])
elif isinstance(value, types.StringTypes):
elif isinstance(value, str):
value = expandvars(value)
if '$' in value or '%' in value:
abort('value of ' + '.'.join(context) + ' contains an undefined environment variable: ' + value)
elif isinstance(value, types.BooleanType):
elif isinstance(value, bool):
pass
else:
abort('value of ' + '.'.join(context) + ' is of unexpected type ' + str(type(value)))
Expand Down Expand Up @@ -8755,7 +8755,7 @@ def _load_distribution(self, name, attrs):
maven = attrs.pop('maven', True)
stripConfigFileNames = attrs.pop('strip', None)
assert stripConfigFileNames is None or isinstance(stripConfigFileNames, list)
if isinstance(maven, types.DictType) and maven.get('version', None):
if isinstance(maven, dict) and maven.get('version', None):
abort("'version' is not supported in maven specification for distributions")
if attrs.pop('buildDependencies', None):
abort("'buildDependencies' is not supported for JAR distributions")
Expand Down Expand Up @@ -8806,9 +8806,9 @@ def _merge_os_arch_attrs(attrs, os_arch_attrs, context, path=''):
if k in attrs:
other = attrs[k]
key_path = path + '.' + str(k)
if isinstance(v, types.DictType) and isinstance(other, types.DictType):
if isinstance(v, dict) and isinstance(other, dict):
Suite._merge_os_arch_attrs(other, v, context, key_path)
elif isinstance(v, types.ListType) and isinstance(other, types.ListType):
elif isinstance(v, list) and isinstance(other, list):
attrs[k] = v + other
else:
abort("OS/Arch attribute must not override non-OS/Arch attribute '{}' in {}".format(key_path, context))
Expand Down Expand Up @@ -9900,11 +9900,11 @@ def instantiateDistribution(templateName, args, fatalIfMissing=True, context=Non
abort('Missing parameters while instantiating distribution template ' + t.name + ': ' + ', '.join(missingParams), context=t)

def _patch(v):
if isinstance(v, types.StringType):
if isinstance(v, str):
return _patchTemplateString(v, args, context)
elif isinstance(v, types.DictType):
elif isinstance(v, dict):
return {kk: _patch(vv) for kk, vv in v.items()}
elif isinstance(v, types.ListType):
elif isinstance(v, list):
return [_patch(e) for e in v]
else:
return v
Expand Down Expand Up @@ -10050,7 +10050,7 @@ def classpath_entries(names=None, includeSelf=True, preferProjects=False, exclud
if names is None:
roots = set(dependencies())
else:
if isinstance(names, types.StringTypes):
if isinstance(names, str):
names = [names]
elif isinstance(names, Dependency):
names = [names]
Expand All @@ -10065,7 +10065,7 @@ def classpath_entries(names=None, includeSelf=True, preferProjects=False, exclud
if excludes is None:
excludes = []
else:
if isinstance(excludes, types.StringTypes):
if isinstance(excludes, str):
excludes = [excludes]
elif isinstance(excludes, Dependency):
excludes = [excludes]
Expand Down Expand Up @@ -10654,7 +10654,7 @@ def _is_supported_by_jdt(jdk):
:type jdk: :class:`mx.JDKConfig` or string
:rtype: bool
"""
if isinstance(jdk, basestring):
if isinstance(jdk, str):
jdk = get_jdk(tag=jdk)
else:
assert isinstance(jdk, JDKConfig)
Expand Down Expand Up @@ -10698,7 +10698,7 @@ def get_jdk(versionCheck=None, purpose=None, cancel=None, versionDescription=Non
defaultJdk = kwargs['defaultJdk']

# interpret string and compliance as compliance check
if isinstance(versionCheck, types.StringTypes):
if isinstance(versionCheck, str):
versionCheck = JavaCompliance(versionCheck)
if isinstance(versionCheck, JavaCompliance):
versionCheck, versionDescription = _convert_compliance_to_version_check(versionCheck)
Expand Down Expand Up @@ -11131,7 +11131,7 @@ def run_mx(args, suite=None, mxpy=None, nonZeroIsFatal=True, out=None, err=None,
commands = [sys.executable, '-u', mxpy, '--java-home=' + get_jdk().home]
cwd = None
if suite:
if isinstance(suite, basestring):
if isinstance(suite, str):
commands += ['-p', suite]
cwd = suite
else:
Expand Down Expand Up @@ -11171,9 +11171,9 @@ def run(args, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None, e
out and err if they are callable objects.
"""

assert isinstance(args, types.ListType), "'args' must be a list: " + str(args)
assert isinstance(args, list), "'args' must be a list: " + str(args)
for arg in args:
assert isinstance(arg, types.StringTypes), 'argument is not a string: ' + str(arg)
assert isinstance(arg, str), 'argument is not a string: ' + str(arg)

if env is None:
env = os.environ.copy()
Expand Down Expand Up @@ -11418,7 +11418,7 @@ def __repr__(self):
return str(self) + '..' + str(self._upper_bound)

def __cmp__(self, other):
if isinstance(other, types.StringType):
if isinstance(other, str):
other = JavaCompliance(other)
r = cmp(self.value, other.value)
if r == 0:
Expand Down Expand Up @@ -13405,14 +13405,14 @@ def newest(paths):
def isOlderThan(self, arg):
if not self.timestamp:
return True
if isinstance(arg, types.IntType) or isinstance(arg, types.LongType) or isinstance(arg, types.FloatType):
if isinstance(arg, int) or isinstance(arg, int) or isinstance(arg, float):
return self.timestamp < arg
if isinstance(arg, TimeStampFile):
if arg.timestamp is None:
return False
else:
return arg.timestamp > self.timestamp
elif isinstance(arg, types.ListType):
elif isinstance(arg, list):
files = arg
else:
files = [arg]
Expand All @@ -13424,14 +13424,14 @@ def isOlderThan(self, arg):
def isNewerThan(self, arg):
if not self.timestamp:
return False
if isinstance(arg, types.IntType) or isinstance(arg, types.LongType) or isinstance(arg, types.FloatType):
if isinstance(arg, int) or isinstance(arg, int) or isinstance(arg, float):
return self.timestamp > arg
if isinstance(arg, TimeStampFile):
if arg.timestamp is None:
return False
else:
return arg.timestamp < self.timestamp
elif isinstance(arg, types.ListType):
elif isinstance(arg, list):
files = arg
else:
files = [arg]
Expand Down Expand Up @@ -18134,7 +18134,7 @@ def visit(dep, edge):
if reasonAttr:
abort('"ignore" attribute must be False/"false" or a non-empty string providing the reason the dependency is ignored', context=dep)
else:
assert isinstance(reasonAttr, basestring)
assert isinstance(reasonAttr, str)
strippedReason = reasonAttr.strip()
if len(strippedReason) != 0:
if not strippedReason == "false":
Expand Down
6 changes: 3 additions & 3 deletions mx_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

from __future__ import print_function

import sys, inspect, re, types, bisect
import sys, inspect, re, bisect
from collections import OrderedDict
from os.path import join
import mx
Expand Down Expand Up @@ -389,12 +389,12 @@ def _ensureCompatLoaded():

def flattenClassTree(tree):
root = tree[0][0]
assert isinstance(root, types.TypeType), root
assert isinstance(root, type), root
yield root
if len(tree) > 1:
assert len(tree) == 2
rest = tree[1]
assert isinstance(rest, types.ListType), rest
assert isinstance(rest, list), rest
for c in flattenClassTree(rest):
yield c

Expand Down