switch python2 %s for python3 .format

pull/7002/head
Michael 5 years ago committed by Jussi Pakkanen
parent 182f40d25a
commit c53b637959
  1. 10
      mesonbuild/envconfig.py
  2. 8
      mesonbuild/environment.py
  3. 12
      mesonbuild/linkers.py
  4. 2
      mesonbuild/mesonmain.py
  5. 2
      mesonbuild/mlog.py
  6. 2
      mesonbuild/modules/sourceset.py

@ -93,15 +93,15 @@ class MesonConfigFile:
# Windows paths...
value = value.replace('\\', '\\\\')
if ' ' in entry or '\t' in entry or "'" in entry or '"' in entry:
raise EnvironmentException('Malformed variable name %s in cross file..' % entry)
raise EnvironmentException('Malformed variable name {} in cross file..'.format(entry))
try:
res = eval(value, {'__builtins__': None}, {'true': True, 'false': False})
except Exception:
raise EnvironmentException('Malformed value in cross file variable %s.' % entry)
raise EnvironmentException('Malformed value in cross file variable {}.'.format(entry))
for i in (res if isinstance(res, list) else [res]):
if not isinstance(i, (str, int, bool)):
raise EnvironmentException('Malformed value in cross file variable %s.' % entry)
raise EnvironmentException('Malformed value in cross file variable {}.'.format(entry))
section[entry] = res
@ -224,11 +224,11 @@ class MachineInfo:
cpu_family = literal['cpu_family']
if cpu_family not in known_cpu_families:
mlog.warning('Unknown CPU family %s, please report this at https://github.com/mesonbuild/meson/issues/new' % cpu_family)
mlog.warning('Unknown CPU family {}, please report this at https://github.com/mesonbuild/meson/issues/new'.format(cpu_family))
endian = literal['endian']
if endian not in ('little', 'big'):
mlog.warning('Unknown endian %s' % endian)
mlog.warning('Unknown endian {}'.format(endian))
return cls(literal['system'], cpu_family, literal['cpu'], endian)

@ -1360,7 +1360,7 @@ class Environment:
try:
p, out, err = Popen_safe(exelist + ['-version'])
except OSError:
raise EnvironmentException('Could not execute Java compiler "%s"' % ' '.join(exelist))
raise EnvironmentException('Could not execute Java compiler "{}"'.format(' '.join(exelist)))
if 'javac' in out or 'javac' in err:
version = search_version(err if 'javac' in err else out)
if not version or version == 'unknown version':
@ -1408,7 +1408,7 @@ class Environment:
try:
p, out = Popen_safe(exelist + ['--version'])[0:2]
except OSError:
raise EnvironmentException('Could not execute Vala compiler "%s"' % ' '.join(exelist))
raise EnvironmentException('Could not execute Vala compiler "{}"'.format(' '.join(exelist)))
version = search_version(out)
if 'Vala' in out:
comp_class = ValaCompiler
@ -1610,7 +1610,7 @@ class Environment:
try:
p, _, err = Popen_safe(exelist + ['-v'])
except OSError:
raise EnvironmentException('Could not execute Swift compiler "%s"' % ' '.join(exelist))
raise EnvironmentException('Could not execute Swift compiler "{}"'.format(' '.join(exelist)))
version = search_version(err)
if 'Swift' in err:
# As for 5.0.1 swiftc *requires* a file to check the linker:
@ -1730,7 +1730,7 @@ class Environment:
if p.returncode == 1 and err.startswith('ar: bad option: --'): # Solaris
return ArLinker(linker)
self._handle_exceptions(popen_exceptions, linkers, 'linker')
raise EnvironmentException('Unknown static linker "%s"' % ' '.join(linkers))
raise EnvironmentException('Unknown static linker "{}"'.format(' '.join(linkers)))
def get_source_dir(self):
return self.source_dir

@ -201,7 +201,7 @@ class CcrxLinker(StaticLinker):
return False
def get_output_args(self, target: str) -> T.List[str]:
return ['-output=%s' % target]
return ['-output={}'.format(target)]
def get_linker_always_args(self) -> T.List[str]:
return ['-nologo', '-form=library']
@ -217,7 +217,7 @@ class Xc16Linker(StaticLinker):
return False
def get_output_args(self, target: str) -> T.List[str]:
return ['%s' % target]
return ['{}'.format(target)]
def get_linker_always_args(self) -> T.List[str]:
return ['rcs']
@ -233,7 +233,7 @@ class C2000Linker(StaticLinker):
return False
def get_output_args(self, target: str) -> T.List[str]:
return ['%s' % target]
return ['{}'.format(target)]
def get_linker_always_args(self) -> T.List[str]:
return ['-r']
@ -781,7 +781,7 @@ class CcrxDynamicLinker(DynamicLinker):
return []
def get_output_args(self, outputname: str) -> T.List[str]:
return ['-output=%s' % outputname]
return ['-output={}'.format(outputname)]
def get_search_args(self, dirname: str) -> 'T.NoReturn':
raise EnvironmentError('rlink.exe does not have a search dir argument')
@ -819,7 +819,7 @@ class Xc16DynamicLinker(DynamicLinker):
return []
def get_output_args(self, outputname: str) -> T.List[str]:
return ['-o%s' % outputname]
return ['-o{}'.format(outputname)]
def get_search_args(self, dirname: str) -> 'T.NoReturn':
raise EnvironmentError('xc16-gcc.exe does not have a search dir argument')
@ -862,7 +862,7 @@ class C2000DynamicLinker(DynamicLinker):
return []
def get_output_args(self, outputname: str) -> T.List[str]:
return ['-z', '--output_file=%s' % outputname]
return ['-z', '--output_file={}'.format(outputname)]
def get_search_args(self, dirname: str) -> 'T.NoReturn':
raise EnvironmentError('cl2000.exe does not have a search dir argument')

@ -182,7 +182,7 @@ def ensure_stdout_accepts_unicode():
def run(original_args, mainfile):
if sys.version_info < (3, 5):
print('Meson works correctly only with python 3.5+.')
print('You have python %s.' % sys.version)
print('You have python {}.'.format(sys.version))
print('Please update your environment')
return 1

@ -302,7 +302,7 @@ def exception(e: Exception, prefix: T.Optional[AnsiDecorator] = None) -> None:
# Mypy doesn't follow hasattr, and it's pretty easy to visually inspect
# that this is correct, so we'll just ignore it.
path = get_relative_path(Path(e.file), Path(os.getcwd())) # type: ignore
args.append('%s:%d:%d:' % (path, e.lineno, e.colno)) # type: ignore
args.append('{}:{}:{}:'.format(path, e.lineno, e.colno)) # type: ignore
if prefix:
args.append(prefix)
args.append(str(e))

@ -150,7 +150,7 @@ class SourceSetHolder(MutableInterpreterObject, ObjectHolder):
if isinstance(config_data, dict):
def _get_from_config_data(key):
if strict and key not in config_data:
raise InterpreterException('Entry %s not in configuration dictionary.' % key)
raise InterpreterException('Entry {} not in configuration dictionary.'.format(key))
return config_data.get(key, False)
else:
config_cache = dict()

Loading…
Cancel
Save