Skip to content

Commit c53b637

Browse files
dreamer-codingjpakkane
authored andcommitted
switch python2 %s for python3 .format
1 parent 182f40d commit c53b637

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

mesonbuild/envconfig.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@ def from_config_parser(cls, parser: configparser.ConfigParser) -> T.Dict[str, T.
9393
# Windows paths...
9494
value = value.replace('\\', '\\\\')
9595
if ' ' in entry or '\t' in entry or "'" in entry or '"' in entry:
96-
raise EnvironmentException('Malformed variable name %s in cross file..' % entry)
96+
raise EnvironmentException('Malformed variable name {} in cross file..'.format(entry))
9797
try:
9898
res = eval(value, {'__builtins__': None}, {'true': True, 'false': False})
9999
except Exception:
100-
raise EnvironmentException('Malformed value in cross file variable %s.' % entry)
100+
raise EnvironmentException('Malformed value in cross file variable {}.'.format(entry))
101101

102102
for i in (res if isinstance(res, list) else [res]):
103103
if not isinstance(i, (str, int, bool)):
104-
raise EnvironmentException('Malformed value in cross file variable %s.' % entry)
104+
raise EnvironmentException('Malformed value in cross file variable {}.'.format(entry))
105105

106106
section[entry] = res
107107

@@ -224,11 +224,11 @@ def from_literal(cls, literal: T.Dict[str, str]) -> 'MachineInfo':
224224

225225
cpu_family = literal['cpu_family']
226226
if cpu_family not in known_cpu_families:
227-
mlog.warning('Unknown CPU family %s, please report this at https://github.com/mesonbuild/meson/issues/new' % cpu_family)
227+
mlog.warning('Unknown CPU family {}, please report this at https://github.com/mesonbuild/meson/issues/new'.format(cpu_family))
228228

229229
endian = literal['endian']
230230
if endian not in ('little', 'big'):
231-
mlog.warning('Unknown endian %s' % endian)
231+
mlog.warning('Unknown endian {}'.format(endian))
232232

233233
return cls(literal['system'], cpu_family, literal['cpu'], endian)
234234

mesonbuild/environment.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,7 @@ def detect_java_compiler(self, for_machine):
13601360
try:
13611361
p, out, err = Popen_safe(exelist + ['-version'])
13621362
except OSError:
1363-
raise EnvironmentException('Could not execute Java compiler "%s"' % ' '.join(exelist))
1363+
raise EnvironmentException('Could not execute Java compiler "{}"'.format(' '.join(exelist)))
13641364
if 'javac' in out or 'javac' in err:
13651365
version = search_version(err if 'javac' in err else out)
13661366
if not version or version == 'unknown version':
@@ -1408,7 +1408,7 @@ def detect_vala_compiler(self, for_machine):
14081408
try:
14091409
p, out = Popen_safe(exelist + ['--version'])[0:2]
14101410
except OSError:
1411-
raise EnvironmentException('Could not execute Vala compiler "%s"' % ' '.join(exelist))
1411+
raise EnvironmentException('Could not execute Vala compiler "{}"'.format(' '.join(exelist)))
14121412
version = search_version(out)
14131413
if 'Vala' in out:
14141414
comp_class = ValaCompiler
@@ -1610,7 +1610,7 @@ def detect_swift_compiler(self, for_machine):
16101610
try:
16111611
p, _, err = Popen_safe(exelist + ['-v'])
16121612
except OSError:
1613-
raise EnvironmentException('Could not execute Swift compiler "%s"' % ' '.join(exelist))
1613+
raise EnvironmentException('Could not execute Swift compiler "{}"'.format(' '.join(exelist)))
16141614
version = search_version(err)
16151615
if 'Swift' in err:
16161616
# As for 5.0.1 swiftc *requires* a file to check the linker:
@@ -1730,7 +1730,7 @@ def detect_static_linker(self, compiler):
17301730
if p.returncode == 1 and err.startswith('ar: bad option: --'): # Solaris
17311731
return ArLinker(linker)
17321732
self._handle_exceptions(popen_exceptions, linkers, 'linker')
1733-
raise EnvironmentException('Unknown static linker "%s"' % ' '.join(linkers))
1733+
raise EnvironmentException('Unknown static linker "{}"'.format(' '.join(linkers)))
17341734

17351735
def get_source_dir(self):
17361736
return self.source_dir

mesonbuild/linkers.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def can_linker_accept_rsp(self) -> bool:
201201
return False
202202

203203
def get_output_args(self, target: str) -> T.List[str]:
204-
return ['-output=%s' % target]
204+
return ['-output={}'.format(target)]
205205

206206
def get_linker_always_args(self) -> T.List[str]:
207207
return ['-nologo', '-form=library']
@@ -217,7 +217,7 @@ def can_linker_accept_rsp(self) -> bool:
217217
return False
218218

219219
def get_output_args(self, target: str) -> T.List[str]:
220-
return ['%s' % target]
220+
return ['{}'.format(target)]
221221

222222
def get_linker_always_args(self) -> T.List[str]:
223223
return ['rcs']
@@ -233,7 +233,7 @@ def can_linker_accept_rsp(self) -> bool:
233233
return False
234234

235235
def get_output_args(self, target: str) -> T.List[str]:
236-
return ['%s' % target]
236+
return ['{}'.format(target)]
237237

238238
def get_linker_always_args(self) -> T.List[str]:
239239
return ['-r']
@@ -781,7 +781,7 @@ def get_std_shared_lib_args(self) -> T.List[str]:
781781
return []
782782

783783
def get_output_args(self, outputname: str) -> T.List[str]:
784-
return ['-output=%s' % outputname]
784+
return ['-output={}'.format(outputname)]
785785

786786
def get_search_args(self, dirname: str) -> 'T.NoReturn':
787787
raise EnvironmentError('rlink.exe does not have a search dir argument')
@@ -819,7 +819,7 @@ def get_std_shared_lib_args(self) -> T.List[str]:
819819
return []
820820

821821
def get_output_args(self, outputname: str) -> T.List[str]:
822-
return ['-o%s' % outputname]
822+
return ['-o{}'.format(outputname)]
823823

824824
def get_search_args(self, dirname: str) -> 'T.NoReturn':
825825
raise EnvironmentError('xc16-gcc.exe does not have a search dir argument')
@@ -862,7 +862,7 @@ def get_std_shared_lib_args(self) -> T.List[str]:
862862
return []
863863

864864
def get_output_args(self, outputname: str) -> T.List[str]:
865-
return ['-z', '--output_file=%s' % outputname]
865+
return ['-z', '--output_file={}'.format(outputname)]
866866

867867
def get_search_args(self, dirname: str) -> 'T.NoReturn':
868868
raise EnvironmentError('cl2000.exe does not have a search dir argument')

mesonbuild/mesonmain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def ensure_stdout_accepts_unicode():
182182
def run(original_args, mainfile):
183183
if sys.version_info < (3, 5):
184184
print('Meson works correctly only with python 3.5+.')
185-
print('You have python %s.' % sys.version)
185+
print('You have python {}.'.format(sys.version))
186186
print('Please update your environment')
187187
return 1
188188

mesonbuild/mlog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def exception(e: Exception, prefix: T.Optional[AnsiDecorator] = None) -> None:
302302
# Mypy doesn't follow hasattr, and it's pretty easy to visually inspect
303303
# that this is correct, so we'll just ignore it.
304304
path = get_relative_path(Path(e.file), Path(os.getcwd())) # type: ignore
305-
args.append('%s:%d:%d:' % (path, e.lineno, e.colno)) # type: ignore
305+
args.append('{}:{}:{}:'.format(path, e.lineno, e.colno)) # type: ignore
306306
if prefix:
307307
args.append(prefix)
308308
args.append(str(e))

mesonbuild/modules/sourceset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def apply_method(self, args, kwargs):
150150
if isinstance(config_data, dict):
151151
def _get_from_config_data(key):
152152
if strict and key not in config_data:
153-
raise InterpreterException('Entry %s not in configuration dictionary.' % key)
153+
raise InterpreterException('Entry {} not in configuration dictionary.'.format(key))
154154
return config_data.get(key, False)
155155
else:
156156
config_cache = dict()

0 commit comments

Comments
 (0)