various python neatness cleanups

All changes were created by running

"pyupgrade --py3-only --keep-percent-format"

and committing the results. I have not touched string formatting for
now.

- use set literals
- simplify .format() parameter naming
- remove __future__
- remove default "r" mode for open()
- use OSError rather than compatibility aliases
- remove stray parentheses in function(generator) scopes
pull/8475/head
Eli Schwartz 4 years ago
parent 76df995ba6
commit 4340bf34fa
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 2
      mesonbuild/backend/backends.py
  2. 42
      mesonbuild/build.py
  3. 18
      mesonbuild/compilers/compilers.py
  4. 4
      mesonbuild/compilers/cuda.py
  5. 24
      mesonbuild/compilers/d.py
  6. 6
      mesonbuild/compilers/mixins/clike.py
  7. 4
      mesonbuild/coredata.py
  8. 2
      mesonbuild/dependencies/cuda.py
  9. 2
      mesonbuild/dependencies/hdf5.py
  10. 4
      mesonbuild/environment.py
  11. 20
      mesonbuild/interpreter.py
  12. 6
      mesonbuild/linkers.py
  13. 2
      mesonbuild/mconf.py
  14. 2
      mesonbuild/mintro.py
  15. 4
      mesonbuild/mlog.py
  16. 4
      mesonbuild/modules/cmake.py
  17. 2
      mesonbuild/modules/dlang.py
  18. 2
      mesonbuild/modules/fs.py
  19. 2
      mesonbuild/modules/keyval.py
  20. 6
      mesonbuild/modules/python.py
  21. 12
      mesonbuild/mtest.py
  22. 2
      mesonbuild/optinterpreter.py
  23. 4
      mesonbuild/rewriter.py
  24. 2
      mesonbuild/scripts/meson_exe.py
  25. 2
      mesonbuild/scripts/symbolextractor.py
  26. 2
      mesonbuild/wrap/wrap.py
  27. 2
      packaging/createmsi.py
  28. 2
      run_project_tests.py
  29. 2
      run_tests.py
  30. 62
      run_unittests.py
  31. 1
      skip_ci.py
  32. 2
      test cases/common/106 generatorcustom/catter.py
  33. 2
      test cases/common/106 generatorcustom/gen.py
  34. 2
      test cases/common/126 configure file in generator/src/gen.py
  35. 2
      test cases/common/14 configure file/file_contains.py
  36. 1
      test cases/common/52 run target/fakeburner.py
  37. 1
      test cases/common/71 external test program/mytest.py
  38. 2
      test cases/common/72 ctarget dependency/gen1.py
  39. 2
      test cases/common/72 ctarget dependency/gen2.py
  40. 1
      test cases/common/96 manygen/subdir/manygen.py
  41. 1
      test cases/unit/11 cross prog/some_cross_tool.py
  42. 1
      test cases/unit/11 cross prog/sometool.py
  43. 2
      test cases/windows/12 resources with custom targets/res/gen-res.py
  44. 2
      tools/dircondenser.py
  45. 2
      tools/regenerate_docs.py

@ -505,7 +505,7 @@ class Backend:
data = bytes(str(es.env) + str(es.cmd_args) + str(es.workdir) + str(capture),
encoding='utf-8')
digest = hashlib.sha1(data).hexdigest()
scratch_file = 'meson_exe_{0}_{1}.dat'.format(basename, digest)
scratch_file = 'meson_exe_{}_{}.dat'.format(basename, digest)
exe_data = os.path.join(self.environment.get_scratch_dir(), scratch_file)
with open(exe_data, 'wb') as f:
pickle.dump(es, f)

@ -43,9 +43,9 @@ if T.TYPE_CHECKING:
from .mesonlib import FileMode, FileOrString
from .mesonlib.backend import Backend
pch_kwargs = set(['c_pch', 'cpp_pch'])
pch_kwargs = {'c_pch', 'cpp_pch'}
lang_arg_kwargs = set([
lang_arg_kwargs = {
'c_args',
'cpp_args',
'cuda_args',
@ -61,13 +61,13 @@ lang_arg_kwargs = set([
'rust_args',
'vala_args',
'cs_args',
])
}
vala_kwargs = set(['vala_header', 'vala_gir', 'vala_vapi'])
rust_kwargs = set(['rust_crate_type'])
cs_kwargs = set(['resources', 'cs_args'])
vala_kwargs = {'vala_header', 'vala_gir', 'vala_vapi'}
rust_kwargs = {'rust_crate_type'}
cs_kwargs = {'resources', 'cs_args'}
buildtarget_kwargs = set([
buildtarget_kwargs = {
'build_by_default',
'build_rpath',
'dependencies',
@ -92,7 +92,7 @@ buildtarget_kwargs = set([
'gnu_symbol_visibility',
'link_language',
'win_subsystem',
])
}
known_build_target_kwargs = (
buildtarget_kwargs |
@ -1723,8 +1723,8 @@ class Executable(BuildTarget):
if not isinstance(kwargs.get('implib', False), bool):
implib_basename = kwargs['implib']
if m.is_windows() or m.is_cygwin():
self.vs_import_filename = '{0}.lib'.format(implib_basename)
self.gcc_import_filename = 'lib{0}.a'.format(implib_basename)
self.vs_import_filename = '{}.lib'.format(implib_basename)
self.gcc_import_filename = 'lib{}.a'.format(implib_basename)
if self.get_using_msvc():
self.import_filename = self.vs_import_filename
else:
@ -1787,7 +1787,7 @@ class StaticLibrary(BuildTarget):
self.rust_crate_type = 'rlib'
# Don't let configuration proceed with a non-static crate type
elif self.rust_crate_type not in ['rlib', 'staticlib']:
raise InvalidArguments('Crate type "{0}" invalid for static libraries; must be "rlib" or "staticlib"'.format(self.rust_crate_type))
raise InvalidArguments('Crate type "{}" invalid for static libraries; must be "rlib" or "staticlib"'.format(self.rust_crate_type))
# By default a static library is named libfoo.a even on Windows because
# MSVC does not have a consistent convention for what static libraries
# are called. The MSVC CRT uses libfoo.lib syntax but nothing else uses
@ -1828,7 +1828,7 @@ class StaticLibrary(BuildTarget):
if isinstance(rust_crate_type, str):
self.rust_crate_type = rust_crate_type
else:
raise InvalidArguments('Invalid rust_crate_type "{0}": must be a string.'.format(rust_crate_type))
raise InvalidArguments('Invalid rust_crate_type "{}": must be a string.'.format(rust_crate_type))
def is_linkable_target(self):
return True
@ -1859,7 +1859,7 @@ class SharedLibrary(BuildTarget):
self.rust_crate_type = 'dylib'
# Don't let configuration proceed with a non-dynamic crate type
elif self.rust_crate_type not in ['dylib', 'cdylib']:
raise InvalidArguments('Crate type "{0}" invalid for dynamic libraries; must be "dylib" or "cdylib"'.format(self.rust_crate_type))
raise InvalidArguments('Crate type "{}" invalid for dynamic libraries; must be "dylib" or "cdylib"'.format(self.rust_crate_type))
if not hasattr(self, 'prefix'):
self.prefix = None
if not hasattr(self, 'suffix'):
@ -1919,13 +1919,13 @@ class SharedLibrary(BuildTarget):
# For all other targets/platforms import_filename stays None
elif env.machines[self.for_machine].is_windows():
suffix = 'dll'
self.vs_import_filename = '{0}{1}.lib'.format(self.prefix if self.prefix is not None else '', self.name)
self.gcc_import_filename = '{0}{1}.dll.a'.format(self.prefix if self.prefix is not None else 'lib', self.name)
self.vs_import_filename = '{}{}.lib'.format(self.prefix if self.prefix is not None else '', self.name)
self.gcc_import_filename = '{}{}.dll.a'.format(self.prefix if self.prefix is not None else 'lib', self.name)
if self.uses_rust():
# Shared library is of the form foo.dll
prefix = ''
# Import library is called foo.dll.lib
self.import_filename = '{0}.dll.lib'.format(self.name)
self.import_filename = '{}.dll.lib'.format(self.name)
create_debug_file = True
elif self.get_using_msvc():
# Shared library is of the form foo.dll
@ -1946,7 +1946,7 @@ class SharedLibrary(BuildTarget):
self.filename_tpl = '{0.prefix}{0.name}.{0.suffix}'
elif env.machines[self.for_machine].is_cygwin():
suffix = 'dll'
self.gcc_import_filename = '{0}{1}.dll.a'.format(self.prefix if self.prefix is not None else 'lib', self.name)
self.gcc_import_filename = '{}{}.dll.a'.format(self.prefix if self.prefix is not None else 'lib', self.name)
# Shared library is of the form cygfoo.dll
# (ld --dll-search-prefix=cyg is the default)
prefix = 'cyg'
@ -2045,7 +2045,7 @@ class SharedLibrary(BuildTarget):
if not isinstance(self.ltversion, str):
raise InvalidArguments('Shared library version needs to be a string, not ' + type(self.ltversion).__name__)
if not re.fullmatch(r'[0-9]+(\.[0-9]+){0,2}', self.ltversion):
raise InvalidArguments('Invalid Shared library version "{0}". Must be of the form X.Y.Z where all three are numbers. Y and Z are optional.'.format(self.ltversion))
raise InvalidArguments('Invalid Shared library version "{}". Must be of the form X.Y.Z where all three are numbers. Y and Z are optional.'.format(self.ltversion))
# Try to extract/deduce the soversion
if 'soversion' in kwargs:
self.soversion = kwargs['soversion']
@ -2092,7 +2092,7 @@ class SharedLibrary(BuildTarget):
if isinstance(rust_crate_type, str):
self.rust_crate_type = rust_crate_type
else:
raise InvalidArguments('Invalid rust_crate_type "{0}": must be a string.'.format(rust_crate_type))
raise InvalidArguments('Invalid rust_crate_type "{}": must be a string.'.format(rust_crate_type))
def get_import_filename(self):
"""
@ -2199,7 +2199,7 @@ class CommandBase:
return final_cmd
class CustomTarget(Target, CommandBase):
known_kwargs = set([
known_kwargs = {
'input',
'output',
'command',
@ -2216,7 +2216,7 @@ class CustomTarget(Target, CommandBase):
'override_options',
'console',
'env',
])
}
def __init__(self, name: str, subdir: str, subproject: str, kwargs: T.Dict[str, T.Any],
absolute_paths: bool = False, backend: T.Optional['Backend'] = None):

@ -762,7 +762,7 @@ class Compiler(metaclass=abc.ABCMeta):
contents = code
elif isinstance(code, mesonlib.File):
srcname = code.fname
with open(code.fname, 'r') as f:
with open(code.fname) as f:
contents = f.read()
# Construct the compiler command-line
@ -1009,16 +1009,16 @@ class Compiler(metaclass=abc.ABCMeta):
return []
def get_crt_compile_args(self, crt_val: str, buildtype: str) -> T.List[str]:
raise EnvironmentError('This compiler does not support Windows CRT selection')
raise OSError('This compiler does not support Windows CRT selection')
def get_crt_link_args(self, crt_val: str, buildtype: str) -> T.List[str]:
raise EnvironmentError('This compiler does not support Windows CRT selection')
raise OSError('This compiler does not support Windows CRT selection')
def get_compile_only_args(self) -> T.List[str]:
return []
def get_preprocess_only_args(self) -> T.List[str]:
raise EnvironmentError('This compiler does not have a preprocessor')
raise OSError('This compiler does not have a preprocessor')
def get_default_include_dirs(self) -> T.List[str]:
return []
@ -1095,7 +1095,7 @@ class Compiler(metaclass=abc.ABCMeta):
return objfile + '.' + self.get_depfile_suffix()
def get_depfile_suffix(self) -> str:
raise EnvironmentError('{} does not implement get_depfile_suffix'.format(self.id))
raise OSError('{} does not implement get_depfile_suffix'.format(self.id))
def get_no_stdinc_args(self) -> T.List[str]:
"""Arguments to turn off default inclusion of standard libraries."""
@ -1112,13 +1112,13 @@ class Compiler(metaclass=abc.ABCMeta):
pass
def get_module_incdir_args(self) -> T.Tuple[str, ...]:
raise EnvironmentError('{} does not implement get_module_incdir_args'.format(self.id))
raise OSError('{} does not implement get_module_incdir_args'.format(self.id))
def get_module_outdir_args(self, path: str) -> T.List[str]:
raise EnvironmentError('{} does not implement get_module_outdir_args'.format(self.id))
raise OSError('{} does not implement get_module_outdir_args'.format(self.id))
def module_name_to_filename(self, module_name: str) -> str:
raise EnvironmentError('{} does not implement module_name_to_filename'.format(self.id))
raise OSError('{} does not implement module_name_to_filename'.format(self.id))
def get_compiler_check_args(self, mode: CompileCheckMode) -> T.List[str]:
"""Arguments to pass the compiler and/or linker for checks.
@ -1212,7 +1212,7 @@ class Compiler(metaclass=abc.ABCMeta):
def get_feature_args(self, kwargs: T.Dict[str, T.Any], build_to_src: str) -> T.List[str]:
"""Used by D for extra language features."""
# TODO: using a TypeDict here would improve this
raise EnvironmentError('{} does not implement get_feature_args'.format(self.id))
raise OSError('{} does not implement get_feature_args'.format(self.id))
def get_prelink_args(self, prelink_name: str, obj_list: T.List[str]) -> T.List[str]:
raise EnvironmentException('{} does not know how to do prelinking.'.format(self.id))

@ -514,7 +514,7 @@ class CudaCompiler(Compiler):
mlog.debug(stde)
mlog.debug('-----')
if pc.returncode != 0:
raise EnvironmentException('Compiler {0} can not compile programs.'.format(self.name_string()))
raise EnvironmentException('Compiler {} can not compile programs.'.format(self.name_string()))
# Run sanity check (if possible)
if self.is_cross:
@ -533,7 +533,7 @@ class CudaCompiler(Compiler):
mlog.debug('-----')
pe.wait()
if pe.returncode != 0:
raise EnvironmentException('Executables created by {0} compiler {1} are not runnable.'.format(self.language, self.name_string()))
raise EnvironmentException('Executables created by {} compiler {} are not runnable.'.format(self.language, self.name_string()))
# Interpret the result of the sanity test.
# As mentioned above, it is not only a sanity test but also a GPU

@ -183,10 +183,10 @@ class DmdLikeCompilerMixin(CompilerMixinBase):
if int(d) > debug_level:
debug_level = int(d)
else:
res.append('{0}={1}'.format(debug_arg, d))
res.append('{}={}'.format(debug_arg, d))
if debug_level >= 0:
res.append('{0}={1}'.format(debug_arg, debug_level))
res.append('{}={}'.format(debug_arg, debug_level))
if 'versions' in kwargs:
version_level = -1
@ -207,10 +207,10 @@ class DmdLikeCompilerMixin(CompilerMixinBase):
if int(v) > version_level:
version_level = int(v)
else:
res.append('{0}={1}'.format(version_arg, v))
res.append('{}={}'.format(version_arg, v))
if version_level >= 0:
res.append('{0}={1}'.format(version_arg, version_level))
res.append('{}={}'.format(version_arg, version_level))
if 'import_dirs' in kwargs:
import_dirs = kwargs.pop('import_dirs')
@ -230,8 +230,8 @@ class DmdLikeCompilerMixin(CompilerMixinBase):
else:
expdir = basedir
srctreedir = os.path.join(build_to_src, expdir)
res.append('{0}{1}'.format(import_dir_arg, srctreedir))
res.append('{0}{1}'.format(import_dir_arg, bldtreedir))
res.append('{}{}'.format(import_dir_arg, srctreedir))
res.append('{}{}'.format(import_dir_arg, bldtreedir))
if kwargs:
raise EnvironmentException('Unknown D compiler feature(s) selected: %s' % ', '.join(kwargs.keys()))
@ -560,10 +560,10 @@ class DCompiler(Compiler):
if int(d) > debug_level:
debug_level = int(d)
else:
res.append('{0}={1}'.format(debug_arg, d))
res.append('{}={}'.format(debug_arg, d))
if debug_level >= 0:
res.append('{0}={1}'.format(debug_arg, debug_level))
res.append('{}={}'.format(debug_arg, debug_level))
if 'versions' in kwargs:
version_level = -1
@ -584,10 +584,10 @@ class DCompiler(Compiler):
if int(v) > version_level:
version_level = int(v)
else:
res.append('{0}={1}'.format(version_arg, v))
res.append('{}={}'.format(version_arg, v))
if version_level >= 0:
res.append('{0}={1}'.format(version_arg, version_level))
res.append('{}={}'.format(version_arg, version_level))
if 'import_dirs' in kwargs:
import_dirs = kwargs.pop('import_dirs')
@ -607,8 +607,8 @@ class DCompiler(Compiler):
else:
expdir = basedir
srctreedir = os.path.join(build_to_src, expdir)
res.append('{0}{1}'.format(import_dir_arg, srctreedir))
res.append('{0}{1}'.format(import_dir_arg, bldtreedir))
res.append('{}{}'.format(import_dir_arg, srctreedir))
res.append('{}{}'.format(import_dir_arg, bldtreedir))
if kwargs:
raise EnvironmentException('Unknown D compiler feature(s) selected: %s' % ', '.join(kwargs.keys()))

@ -321,7 +321,7 @@ class CLikeCompiler(Compiler):
mlog.debug(stde)
mlog.debug('-----')
if pc.returncode != 0:
raise mesonlib.EnvironmentException('Compiler {0} can not compile programs.'.format(self.name_string()))
raise mesonlib.EnvironmentException('Compiler {} can not compile programs.'.format(self.name_string()))
# Run sanity check
if self.is_cross:
if self.exe_wrapper is None:
@ -337,7 +337,7 @@ class CLikeCompiler(Compiler):
raise mesonlib.EnvironmentException('Could not invoke sanity test executable: %s.' % str(e))
pe.wait()
if pe.returncode != 0:
raise mesonlib.EnvironmentException('Executables created by {0} compiler {1} are not runnable.'.format(self.language, self.name_string()))
raise mesonlib.EnvironmentException('Executables created by {} compiler {} are not runnable.'.format(self.language, self.name_string()))
def sanity_check(self, work_dir: str, environment: 'Environment') -> None:
code = 'int main(void) { int class=0; return class; }\n'
@ -810,7 +810,7 @@ class CLikeCompiler(Compiler):
if val is not None:
if isinstance(val, bool):
return val, False
raise mesonlib.EnvironmentException('Cross variable {0} is not a boolean.'.format(varname))
raise mesonlib.EnvironmentException('Cross variable {} is not a boolean.'.format(varname))
# TODO: we really need a protocol for this,
#

@ -235,7 +235,7 @@ class UserArrayOption(UserOption[T.List[str]]):
mlog.deprecation(msg)
for i in newvalue:
if not isinstance(i, str):
raise MesonException('String array element "{0}" is not a string.'.format(str(newvalue)))
raise MesonException('String array element "{}" is not a string.'.format(str(newvalue)))
if self.choices:
bad = [x for x in newvalue if x not in self.choices]
if bad:
@ -434,7 +434,7 @@ class CoreData:
# the contents of that file into the meson private (scratch)
# directory so that it can be re-read when wiping/reconfiguring
copy = os.path.join(scratch_dir, '{}.{}.ini'.format(uuid.uuid4(), ftype))
with open(f, 'r') as rf:
with open(f) as rf:
with open(copy, 'w') as wf:
wf.write(rf.read())
real.append(copy)

@ -130,7 +130,7 @@ class CudaDependency(ExternalDependency):
def _default_path_env_var(self):
env_vars = ['CUDA_PATH'] if self._is_windows() else ['CUDA_PATH', 'CUDA_HOME', 'CUDA_ROOT']
env_vars = [var for var in env_vars if var in os.environ]
user_defaults = set([os.environ[var] for var in env_vars])
user_defaults = {os.environ[var] for var in env_vars}
if len(user_defaults) > 1:
mlog.warning('Environment variables {} point to conflicting toolkit locations ({}). Toolkit selection might produce unexpected results.'.format(', '.join(env_vars), ', '.join(user_defaults)))
return env_vars[0] if env_vars else None

@ -167,7 +167,7 @@ def hdf5_factory(env: 'Environment', for_machine: 'MachineChoice',
universal_newlines=True)
if ret.returncode == 0:
for pkg in ret.stdout.split('\n'):
if pkg.startswith(('hdf5')):
if pkg.startswith('hdf5'):
pkgconfig_files.add(pkg.split(' ', 1)[0])
for pkg in pkgconfig_files:

@ -1020,7 +1020,7 @@ class Environment:
if exceptions:
errmsg += '\nThe following exception(s) were encountered:'
for (c, e) in exceptions.items():
errmsg += '\nRunning "{0}" gave "{1}"'.format(c, e)
errmsg += '\nRunning "{}" gave "{}"'.format(c, e)
raise EnvironmentException(errmsg)
@staticmethod
@ -1208,7 +1208,7 @@ class Environment:
compiler = [compiler]
compiler_name = os.path.basename(compiler[0])
if not set(['cl', 'cl.exe', 'clang-cl', 'clang-cl.exe']).isdisjoint(compiler):
if not {'cl', 'cl.exe', 'clang-cl', 'clang-cl.exe'}.isdisjoint(compiler):
# Watcom C provides it's own cl.exe clone that mimics an older
# version of Microsoft's compiler. Since Watcom's cl.exe is
# just a wrapper, we skip using it if we detect its presence

@ -1039,25 +1039,25 @@ class SubprojectHolder(InterpreterObject, ObjectHolder[T.Optional['Interpreter']
if len(args) == 2:
return args[1]
raise InvalidArguments('Requested variable "{0}" not found.'.format(varname))
raise InvalidArguments('Requested variable "{}" not found.'.format(varname))
header_permitted_kwargs = set([
header_permitted_kwargs = {
'required',
'prefix',
'no_builtin_args',
'include_directories',
'args',
'dependencies',
])
}
find_library_permitted_kwargs = set([
find_library_permitted_kwargs = {
'has_headers',
'required',
'dirs',
'static',
])
}
find_library_permitted_kwargs |= set(['header_' + k for k in header_permitted_kwargs])
find_library_permitted_kwargs |= {'header_' + k for k in header_permitted_kwargs}
class CompilerHolder(InterpreterObject):
def __init__(self, compiler: 'Compiler', env: 'Environment', subproject: str):
@ -1585,7 +1585,7 @@ class CompilerHolder(InterpreterObject):
raise InterpreterException('Prefix argument of has_header_symbol must be a string.')
disabled, required, feature = extract_required_kwarg(kwargs, self.subproject, default=False)
if disabled:
mlog.log('Header <{0}> has symbol'.format(hname), mlog.bold(symbol, True), 'skipped: feature', mlog.bold(feature), 'disabled')
mlog.log('Header <{}> has symbol'.format(hname), mlog.bold(symbol, True), 'skipped: feature', mlog.bold(feature), 'disabled')
return False
extra_args = functools.partial(self.determine_args, kwargs)
deps, msg = self.determine_dependencies(kwargs)
@ -1599,7 +1599,7 @@ class CompilerHolder(InterpreterObject):
else:
h = mlog.red('NO')
cached = mlog.blue('(cached)') if cached else ''
mlog.log('Header <{0}> has symbol'.format(hname), mlog.bold(symbol, True), msg, h, cached)
mlog.log('Header <{}> has symbol'.format(hname), mlog.bold(symbol, True), msg, h, cached)
return haz
def notfound_library(self, libname):
@ -4346,7 +4346,7 @@ This will become a hard error in the future.''' % kwargs['input'], location=self
def func_configure_file(self, node, args, kwargs):
if 'output' not in kwargs:
raise InterpreterException('Required keyword argument "output" not defined.')
actions = set(['configuration', 'command', 'copy']).intersection(kwargs.keys())
actions = {'configuration', 'command', 'copy'}.intersection(kwargs.keys())
if len(actions) == 0:
raise InterpreterException('Must specify an action with one of these '
'keyword arguments: \'configuration\', '
@ -4483,7 +4483,7 @@ This will become a hard error in the future.''' % kwargs['input'], location=self
mesonlib.replace_if_different(ofile_abs, dst_tmp)
if depfile:
mlog.log('Reading depfile:', mlog.bold(depfile))
with open(depfile, 'r') as f:
with open(depfile) as f:
df = DepFile(f.readlines())
deps = df.get_all_dependencies(ofile_fname)
for dep in deps:

@ -838,7 +838,7 @@ class CcrxDynamicLinker(DynamicLinker):
return ['-output={}'.format(outputname)]
def get_search_args(self, dirname: str) -> 'T.NoReturn':
raise EnvironmentError('rlink.exe does not have a search dir argument')
raise OSError('rlink.exe does not have a search dir argument')
def get_allow_undefined_args(self) -> T.List[str]:
return []
@ -878,7 +878,7 @@ class Xc16DynamicLinker(DynamicLinker):
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')
raise OSError('xc16-gcc.exe does not have a search dir argument')
def get_allow_undefined_args(self) -> T.List[str]:
return []
@ -966,7 +966,7 @@ class C2000DynamicLinker(DynamicLinker):
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')
raise OSError('cl2000.exe does not have a search dir argument')
def get_allow_undefined_args(self) -> T.List[str]:
return []

@ -123,7 +123,7 @@ class Conf:
def add_option(self, name, descr, value, choices):
if isinstance(value, list):
value = '[{0}]'.format(', '.join(make_lower_case(value)))
value = '[{}]'.format(', '.join(make_lower_case(value)))
else:
value = make_lower_case(value)

@ -394,7 +394,7 @@ def get_info_file(infodir: str, kind: T.Optional[str] = None) -> str:
'meson-info.json' if not kind else 'intro-{}.json'.format(kind))
def load_info_file(infodir: str, kind: T.Optional[str] = None) -> T.Any:
with open(get_info_file(infodir, kind), 'r') as fp:
with open(get_info_file(infodir, kind)) as fp:
return json.load(fp)
def run(options: argparse.Namespace) -> int:

@ -142,10 +142,10 @@ class AnsiText:
self.args = args
def __len__(self) -> int:
return sum((len(x) for x in self.args))
return sum(len(x) for x in self.args)
def __str__(self) -> str:
return ''.join((str(x) for x in self.args))
return ''.join(str(x) for x in self.args)
def bold(text: str, quoted: bool = False) -> AnsiDecorator:

@ -235,7 +235,7 @@ class CmakeModule(ExtensionModule):
cmakebin = dependencies.ExternalProgram('cmake', silent=False)
p, stdout, stderr = mesonlib.Popen_safe(cmakebin.get_command() + ['--system-information', '-G', 'Ninja'])[0:3]
if p.returncode != 0:
mlog.log('error retrieving cmake information: returnCode={0} stdout={1} stderr={2}'.format(p.returncode, stdout, stderr))
mlog.log('error retrieving cmake information: returnCode={} stdout={} stderr={}'.format(p.returncode, stdout, stderr))
return False
match = re.search('\nCMAKE_ROOT \\"([^"]+)"\n', stdout.strip())
@ -295,7 +295,7 @@ class CmakeModule(ExtensionModule):
package_init += PACKAGE_INIT_SET_AND_CHECK
try:
with open(infile, "r") as fin:
with open(infile) as fin:
data = fin.readlines()
except Exception as e:
raise mesonlib.MesonException('Could not read input file %s: %s' % (infile, str(e)))

@ -70,7 +70,7 @@ class DlangModule(ExtensionModule):
config_path = os.path.join(args[1], 'dub.json')
if os.path.exists(config_path):
with open(config_path, 'r', encoding='utf8') as ofile:
with open(config_path, encoding='utf8') as ofile:
try:
config = json.load(ofile)
except ValueError:

@ -211,7 +211,7 @@ class FSModule(ExtensionModule):
if path_is_in_root(Path(path), Path(build_dir), resolve=True):
raise MesonException('path must not be in the build tree')
try:
with open(path, 'r', encoding=encoding) as f:
with open(path, encoding=encoding) as f:
data = f.read()
except UnicodeDecodeError:
raise MesonException(f'decoding failed for {path}')

@ -42,7 +42,7 @@ class KeyvalModule(ExtensionModule):
except ValueError:
continue
result[name.strip()] = val.strip()
except IOError as e:
except OSError as e:
raise mesonlib.MesonException('Failed to load {}: {}'.format(path_to_config, e))
return result

@ -36,9 +36,9 @@ from ..dependencies.base import (
NonExistingExternalProgram, NotFoundDependency
)
mod_kwargs = set(['subdir'])
mod_kwargs = {'subdir'}
mod_kwargs.update(known_shmod_kwargs)
mod_kwargs -= set(['name_prefix', 'name_suffix'])
mod_kwargs -= {'name_prefix', 'name_suffix'}
class PythonDependency(ExternalDependency):
@ -544,7 +544,7 @@ class PythonModule(ExtensionModule):
for mod in want_modules:
p, out, err = mesonlib.Popen_safe(
python.command +
['-c', 'import {0}'.format(mod)])
['-c', 'import {}'.format(mod)])
if p.returncode != 0:
missing_modules.append(mod)
else:

@ -902,8 +902,8 @@ class TestRun:
return returncode_to_status(self.returncode)
if self.results:
# running or succeeded
passed = sum((x.result.is_ok() for x in self.results))
ran = sum((x.result is not TestResult.SKIP for x in self.results))
passed = sum(x.result.is_ok() for x in self.results)
ran = sum(x.result is not TestResult.SKIP for x in self.results)
if passed == ran:
return '{} subtests passed'.format(passed)
else:
@ -928,7 +928,7 @@ class TestRun:
return None
test_only_env = set(self.env.items()) - set(os.environ.items())
return env_tuple_to_str(test_only_env) + \
' '.join((sh_quote(x) for x in self.cmd))
' '.join(sh_quote(x) for x in self.cmd)
def complete_skip(self, message: str) -> None:
self.starttime = time.time()
@ -1634,13 +1634,13 @@ class TestHarness:
os.chdir(self.options.wd)
runners = [] # type: T.List[SingleTestRunner]
for i in range(self.options.repeat):
runners.extend((self.get_test_runner(test) for test in tests))
runners.extend(self.get_test_runner(test) for test in tests)
if i == 0:
self.duration_max_len = max([len(str(int(runner.timeout or 99)))
for runner in runners])
# Disable the progress report if it gets in the way
self.need_console = any((runner.console_mode is not ConsoleUser.LOGGER
for runner in runners))
self.need_console = any(runner.console_mode is not ConsoleUser.LOGGER
for runner in runners)
self.test_count = len(runners)
self.run_tests(runners)

@ -142,7 +142,7 @@ class OptionInterpreter:
def process(self, option_file: str) -> None:
try:
with open(option_file, 'r', encoding='utf8') as f:
with open(option_file, encoding='utf8') as f:
ast = mparser.Parser(f.read(), option_file).parse()
except mesonlib.MesonException as me:
me.file = option_file

@ -820,7 +820,7 @@ class Rewriter:
if not os.path.exists(fpath):
with open(fpath, 'w'):
pass
with open(fpath, 'r') as fp:
with open(fpath) as fp:
fdata = fp.read()
# Generate line offsets numbers
@ -923,7 +923,7 @@ def generate_def_opts(options) -> T.List[dict]:
def generate_cmd(options) -> T.List[dict]:
if os.path.exists(options.json):
with open(options.json, 'r') as fp:
with open(options.json) as fp:
return json.load(fp)
else:
return json.loads(options.json)

@ -82,7 +82,7 @@ def run_exe(exe: ExecutableSerialisation, extra_env: T.Optional[dict] = None) ->
try:
with open(exe.capture, 'rb') as cur:
skip_write = cur.read() == stdout
except IOError:
except OSError:
pass
if not skip_write:
with open(exe.capture, 'wb') as output:

@ -43,7 +43,7 @@ def dummy_syms(outfilename: str) -> None:
def write_if_changed(text: str, outfilename: str) -> None:
try:
with open(outfilename, 'r') as f:
with open(outfilename) as f:
oldtext = f.read()
if text == oldtext:
return

@ -442,7 +442,7 @@ class Resolver:
def is_git_full_commit_id(self, revno: str) -> bool:
result = False
if len(revno) in (40, 64): # 40 for sha1, 64 for upcoming sha256
result = all((ch in '0123456789AaBbCcDdEeFf' for ch in revno))
result = all(ch in '0123456789AaBbCcDdEeFf' for ch in revno)
return result
def get_hg(self) -> None:

@ -277,7 +277,7 @@ class PackageGenerator:
with open(self.main_xml, 'w') as open_file:
open_file.write(doc.toprettyxml())
# One last fix, add CDATA.
with open(self.main_xml, 'r') as open_file:
with open(self.main_xml) as open_file:
data = open_file.read()
data = data.replace('X'*len(WINVER_CHECK), WINVER_CHECK)
with open(self.main_xml, 'w') as open_file:

@ -1352,7 +1352,7 @@ if __name__ == '__main__':
except UnicodeError:
print(l.encode('ascii', errors='replace').decode(), '\n')
for name, dirs, _ in all_tests:
dir_names = list(set(x.path.name for x in dirs))
dir_names = list({x.path.name for x in dirs})
for k, g in itertools.groupby(dir_names, key=lambda x: x.split()[0]):
tests = list(g)
if len(tests) != 1:

@ -190,7 +190,7 @@ def find_vcxproj_with_target(builddir, target):
for _, _, files in os.walk(builddir):
for f in fnmatch.filter(files, '*.vcxproj'):
f = os.path.join(builddir, f)
with open(f, 'r', encoding='utf-8') as o:
with open(f, encoding='utf-8') as o:
if re.search(p, o.read(), flags=re.MULTILINE):
return f
raise RuntimeError('No vcxproj matching {!r} in {!r}'.format(p, builddir))

@ -1583,10 +1583,10 @@ class DataTests(unittest.TestCase):
self.assertEqual(len(found_entries & options), 0)
found_entries |= options
self.assertEqual(found_entries, set([
self.assertEqual(found_entries, {
*[str(k) for k in mesonbuild.coredata.BUILTIN_OPTIONS],
*[str(k) for k in mesonbuild.coredata.BUILTIN_OPTIONS_PER_MACHINE],
]))
})
# Check that `buildtype` table inside `Core options` matches how
# setting of builtin options behaves
@ -1682,7 +1682,7 @@ class DataTests(unittest.TestCase):
data_files += [(p.relative_to(mesonbuild_dir).as_posix(), hashlib.sha256(p.read_bytes()).hexdigest())]
current_files = set(mesondata.keys())
scanned_files = set([x[0] for x in data_files])
scanned_files = {x[0] for x in data_files}
self.assertSetEqual(current_files, scanned_files, err_msg + 'Data files were added or removed\n')
errors = []
@ -1764,7 +1764,7 @@ class BasePlatformTests(unittest.TestCase):
if not os.path.isfile(log):
print("{!r} doesn't exist".format(log))
return
with open(log, 'r', encoding='utf-8') as f:
with open(log, encoding='utf-8') as f:
print(f.read())
def tearDown(self):
@ -1925,7 +1925,7 @@ class BasePlatformTests(unittest.TestCase):
compiler, rsp = each['command'].split(' @')
rsp = os.path.join(self.builddir, rsp)
# Replace the command with its contents
with open(rsp, 'r', encoding='utf-8') as f:
with open(rsp, encoding='utf-8') as f:
each['command'] = compiler + ' ' + f.read()
return contents
@ -2952,7 +2952,7 @@ class AllPlatformTests(BasePlatformTests):
self.assertNotEqual(commands['cpp-c-asm']['c'], commands['cpp-c-asm']['cpp'])
# Check that the c-asm target is always linked with the C linker
build_ninja = os.path.join(self.builddir, 'build.ninja')
with open(build_ninja, 'r', encoding='utf-8') as f:
with open(build_ninja, encoding='utf-8') as f:
contents = f.read()
m = re.search('build c-asm.*: c_LINKER', contents)
self.assertIsNotNone(m, msg=contents)
@ -4245,7 +4245,7 @@ class AllPlatformTests(BasePlatformTests):
with tempfile.NamedTemporaryFile(mode='w', delete=False) as crossfile:
crossfile.write(textwrap.dedent(
'''[binaries]
pkgconfig = '{0}'
pkgconfig = '{}'
[properties]
@ -4275,7 +4275,7 @@ class AllPlatformTests(BasePlatformTests):
pkgconfig = 'pkg-config'
[properties]
pkg_config_libdir = ['{0}']
pkg_config_libdir = ['{}']
[host_machine]
system = 'linux'
@ -4372,26 +4372,26 @@ class AllPlatformTests(BasePlatformTests):
def test_introspect_projectinfo_without_configured_build(self):
testfile = os.path.join(self.common_test_dir, '34 run program', 'meson.build')
res = self.introspect_directory(testfile, '--projectinfo')
self.assertEqual(set(res['buildsystem_files']), set(['meson.build']))
self.assertEqual(set(res['buildsystem_files']), {'meson.build'})
self.assertEqual(res['version'], 'undefined')
self.assertEqual(res['descriptive_name'], 'run command')
self.assertEqual(res['subprojects'], [])
testfile = os.path.join(self.common_test_dir, '41 options', 'meson.build')
res = self.introspect_directory(testfile, '--projectinfo')
self.assertEqual(set(res['buildsystem_files']), set(['meson_options.txt', 'meson.build']))
self.assertEqual(set(res['buildsystem_files']), {'meson_options.txt', 'meson.build'})
self.assertEqual(res['version'], 'undefined')
self.assertEqual(res['descriptive_name'], 'options')
self.assertEqual(res['subprojects'], [])
testfile = os.path.join(self.common_test_dir, '44 subproject options', 'meson.build')
res = self.introspect_directory(testfile, '--projectinfo')
self.assertEqual(set(res['buildsystem_files']), set(['meson_options.txt', 'meson.build']))
self.assertEqual(set(res['buildsystem_files']), {'meson_options.txt', 'meson.build'})
self.assertEqual(res['version'], 'undefined')
self.assertEqual(res['descriptive_name'], 'suboptions')
self.assertEqual(len(res['subprojects']), 1)
subproject_files = set(f.replace('\\', '/') for f in res['subprojects'][0]['buildsystem_files'])
self.assertEqual(subproject_files, set(['subprojects/subproject/meson_options.txt', 'subprojects/subproject/meson.build']))
subproject_files = {f.replace('\\', '/') for f in res['subprojects'][0]['buildsystem_files']}
self.assertEqual(subproject_files, {'subprojects/subproject/meson_options.txt', 'subprojects/subproject/meson.build'})
self.assertEqual(res['subprojects'][0]['name'], 'subproject')
self.assertEqual(res['subprojects'][0]['version'], 'undefined')
self.assertEqual(res['subprojects'][0]['descriptive_name'], 'subproject')
@ -4544,7 +4544,7 @@ class AllPlatformTests(BasePlatformTests):
infodir = os.path.join(self.builddir, 'meson-info')
self.assertPathExists(infodir)
with open(os.path.join(infodir, 'intro-targets.json'), 'r') as fp:
with open(os.path.join(infodir, 'intro-targets.json')) as fp:
targets = json.load(fp)
for i in targets:
@ -4653,7 +4653,7 @@ class AllPlatformTests(BasePlatformTests):
for i in root_keylist:
curr = os.path.join(infodir, 'intro-{}.json'.format(i[0]))
self.assertPathExists(curr)
with open(curr, 'r') as fp:
with open(curr) as fp:
res[i[0]] = json.load(fp)
assertKeyTypes(root_keylist, res)
@ -4761,7 +4761,7 @@ class AllPlatformTests(BasePlatformTests):
for i in root_keylist:
curr = os.path.join(infodir, 'intro-{}.json'.format(i))
self.assertPathExists(curr)
with open(curr, 'r') as fp:
with open(curr) as fp:
res_file[i] = json.load(fp)
self.assertEqual(res_all, res_file)
@ -4771,7 +4771,7 @@ class AllPlatformTests(BasePlatformTests):
introfile = os.path.join(self.builddir, 'meson-info', 'meson-info.json')
self.init(testdir)
self.assertPathExists(introfile)
with open(introfile, 'r') as fp:
with open(introfile) as fp:
res1 = json.load(fp)
for i in ['meson_version', 'directories', 'introspection', 'build_files_updated', 'error']:
@ -4785,7 +4785,7 @@ class AllPlatformTests(BasePlatformTests):
introfile = os.path.join(self.builddir, 'meson-info', 'intro-buildoptions.json')
self.init(testdir)
self.assertPathExists(introfile)
with open(introfile, 'r') as fp:
with open(introfile) as fp:
res1 = json.load(fp)
for i in res1:
@ -4803,7 +4803,7 @@ class AllPlatformTests(BasePlatformTests):
self.setconf('-Dcpp_std=c++14')
self.setconf('-Dbuildtype=release')
with open(introfile, 'r') as fp:
with open(introfile) as fp:
res2 = json.load(fp)
self.assertListEqual(res1, res2)
@ -4814,7 +4814,7 @@ class AllPlatformTests(BasePlatformTests):
introfile = os.path.join(self.builddir, 'meson-info', 'intro-targets.json')
self.init(testdir)
self.assertPathExists(introfile)
with open(introfile, 'r') as fp:
with open(introfile) as fp:
res_wb = json.load(fp)
res_nb = self.introspect_directory(testfile, ['--targets'] + self.meson_args)
@ -5190,7 +5190,7 @@ class AllPlatformTests(BasePlatformTests):
self.init(testdir)
build_ninja = os.path.join(self.builddir, 'build.ninja')
with open(build_ninja, 'r', encoding='utf-8') as f:
with open(build_ninja, encoding='utf-8') as f:
contents = f.read()
self.assertRegex(contents, r'build main(\.exe)?.*: c_LINKER')
@ -5222,10 +5222,10 @@ class AllPlatformTests(BasePlatformTests):
## Validate commands
md_commands = set(k for k,v in md_command_sections.items())
md_commands = {k for k,v in md_command_sections.items()}
help_output = self._run(self.meson_command + ['--help'])
help_commands = set(c.strip() for c in re.findall(r'usage:(?:.+)?{((?:[a-z]+,*)+?)}', help_output, re.MULTILINE|re.DOTALL)[0].split(','))
help_commands = {c.strip() for c in re.findall(r'usage:(?:.+)?{((?:[a-z]+,*)+?)}', help_output, re.MULTILINE|re.DOTALL)[0].split(',')}
self.assertEqual(md_commands | {'help'}, help_commands, 'Doc file: `{}`'.format(doc_path))
@ -6151,7 +6151,7 @@ class WindowsTests(BasePlatformTests):
self.init(testdir, extra_args=['-Db_vscrt=mdd'])
# Verify that we're linking to the debug versions of Qt DLLs
build_ninja = os.path.join(self.builddir, 'build.ninja')
with open(build_ninja, 'r', encoding='utf-8') as f:
with open(build_ninja, encoding='utf-8') as f:
contents = f.read()
m = re.search('build qt5core.exe: cpp_LINKER.*Qt5Cored.lib', contents)
self.assertIsNotNone(m, msg=contents)
@ -6245,7 +6245,7 @@ class DarwinTests(BasePlatformTests):
self.assertIn('-fembed-bitcode', compdb['command'])
build_ninja = os.path.join(self.builddir, 'build.ninja')
# Linker options were added
with open(build_ninja, 'r', encoding='utf-8') as f:
with open(build_ninja, encoding='utf-8') as f:
contents = f.read()
m = re.search('LINK_ARGS =.*-bitcode_bundle', contents)
self.assertIsNotNone(m, msg=contents)
@ -6256,7 +6256,7 @@ class DarwinTests(BasePlatformTests):
for compdb in self.get_compdb():
self.assertNotIn('-fembed-bitcode', compdb['command'])
build_ninja = os.path.join(self.builddir, 'build.ninja')
with open(build_ninja, 'r', encoding='utf-8') as f:
with open(build_ninja, encoding='utf-8') as f:
contents = f.read()
m = re.search('LINK_ARGS =.*-bitcode_bundle', contents)
self.assertIsNone(m, msg=contents)
@ -7601,7 +7601,7 @@ class LinuxlikeTests(BasePlatformTests):
build_ninja = os.path.join(self.builddir, 'build.ninja')
max_count = 0
search_term = '-Wl,--export-dynamic'
with open(build_ninja, 'r', encoding='utf-8') as f:
with open(build_ninja, encoding='utf-8') as f:
for line in f:
max_count = max(max_count, line.count(search_term))
self.assertEqual(max_count, 1, 'Export dynamic incorrectly deduplicated.')
@ -7610,7 +7610,7 @@ class LinuxlikeTests(BasePlatformTests):
testdir = os.path.join(self.unit_test_dir, '56 dedup compiler libs')
self.init(testdir)
build_ninja = os.path.join(self.builddir, 'build.ninja')
with open(build_ninja, 'r', encoding='utf-8') as f:
with open(build_ninja, encoding='utf-8') as f:
lines = f.readlines()
for lib in ('-ldl', '-lm', '-lc', '-lrt'):
for line in lines:
@ -7636,7 +7636,7 @@ class LinuxlikeTests(BasePlatformTests):
nativefile = tempfile.NamedTemporaryFile(mode='w')
nativefile.write(textwrap.dedent('''\
[binaries]
c = ['{0}']
c = ['{}']
'''.format(os.path.join(testdir, 'build_wrapper.py'))))
nativefile.flush()
self.meson_native_file = nativefile.name
@ -7644,7 +7644,7 @@ class LinuxlikeTests(BasePlatformTests):
crossfile = tempfile.NamedTemporaryFile(mode='w')
crossfile.write(textwrap.dedent('''\
[binaries]
c = ['{0}']
c = ['{}']
'''.format(os.path.join(testdir, 'host_wrapper.py'))))
crossfile.flush()
self.meson_cross_file = crossfile.name
@ -7660,7 +7660,7 @@ class LinuxlikeTests(BasePlatformTests):
crossfile = tempfile.NamedTemporaryFile(mode='w')
crossfile.write(textwrap.dedent('''\
[binaries]
c = ['{0}']
c = ['{}']
'''.format(os.path.join(testdir, 'host_wrapper.py'))))
crossfile.flush()
self.meson_cross_file = crossfile.name

@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
import argparse
import os

@ -8,7 +8,7 @@ inputs = sys.argv[1:-1]
with open(output, 'w') as ofile:
ofile.write('#pragma once\n')
for i in inputs:
with open(i, 'r') as ifile:
with open(i) as ifile:
content = ifile.read()
ofile.write(content)
ofile.write('\n')

@ -5,7 +5,7 @@ import sys
ifile = sys.argv[1]
ofile = sys.argv[2]
with open(ifile, 'r') as f:
with open(ifile) as f:
resname = f.readline().strip()
templ = 'const char %s[] = "%s";\n'

@ -5,7 +5,7 @@ import sys
ifile = sys.argv[1]
ofile = sys.argv[2]
with open(ifile, 'r') as f:
with open(ifile) as f:
resval = f.readline().strip()
templ = '#define RESULT (%s)\n'

@ -11,7 +11,7 @@ def main():
text = args.text[0]
with open(args.file[0], 'r', encoding='utf-8') as f:
with open(args.file[0], encoding='utf-8') as f:
for line in f:
if line.strip() == text:
return 0

@ -1,6 +1,5 @@
#!/usr/bin/env python3
from __future__ import print_function
import sys

@ -1,6 +1,5 @@
#!/usr/bin/env python3
from __future__ import print_function
import sys

@ -6,7 +6,7 @@ import time, sys
# is missing.
time.sleep(0.5)
with open(sys.argv[1], 'r') as f:
with open(sys.argv[1]) as f:
contents = f.read()
with open(sys.argv[2], 'w') as f:
f.write(contents)

@ -6,5 +6,5 @@ from glob import glob
files = glob(os.path.join(sys.argv[1], '*.tmp'))
assert(len(files) == 1)
with open(files[0], 'r') as ifile, open(sys.argv[2], 'w') as ofile:
with open(files[0]) as ifile, open(sys.argv[2], 'w') as ofile:
ofile.write(ifile.read())

@ -1,6 +1,5 @@
#!/usr/bin/env python3
from __future__ import print_function
# Generates a static library, object file, source
# file and a header file.

@ -1,5 +1,4 @@
#!/usr/bin/env python3
from __future__ import print_function
print('cross')

@ -1,5 +1,4 @@
#!/usr/bin/env python3
from __future__ import print_function
print('native')

@ -2,5 +2,5 @@
import sys
with open(sys.argv[1], 'r') as infile, open(sys.argv[2], 'w') as outfile:
with open(sys.argv[1]) as infile, open(sys.argv[2], 'w') as outfile:
outfile.write(infile.read().format(icon=sys.argv[3]))

@ -54,7 +54,7 @@ def get_entries() -> T.List[T.Tuple[int, str]]:
return entries
def replace_source(sourcefile: str, replacements: T.List[T.Tuple[str, str]]) -> None:
with open(sourcefile, 'r') as f:
with open(sourcefile) as f:
contents = f.read()
for old_name, new_name in replacements:
contents = contents.replace(old_name, new_name)

@ -94,7 +94,7 @@ def get_commands_data(root_dir: Path) -> T.Dict[str, T.Any]:
return out
output = _get_meson_output(root_dir, ['--help'])
commands = set(c.strip() for c in re.findall(r'usage:(?:.+)?{((?:[a-z]+,*)+?)}', output, re.MULTILINE|re.DOTALL)[0].split(','))
commands = {c.strip() for c in re.findall(r'usage:(?:.+)?{((?:[a-z]+,*)+?)}', output, re.MULTILINE|re.DOTALL)[0].split(',')}
commands.remove('help')
cmd_data = dict()

Loading…
Cancel
Save