tree-wide: use proper 'not in' notation

Let's be more pythonic and 'not is' seems really weird.

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
pull/1233/head
Igor Gnatenko 8 years ago
parent 9ffc0d2f89
commit 139e020ede
  1. 6
      mesonbuild/backend/ninjabackend.py
  2. 6
      mesonbuild/build.py
  3. 2
      mesonbuild/dependencies.py
  4. 4
      mesonbuild/environment.py
  5. 18
      mesonbuild/interpreter.py
  6. 4
      mesonbuild/mconf.py
  7. 4
      mesonbuild/modules/gnome.py
  8. 2
      mesonbuild/modules/i18n.py
  9. 2
      mesonbuild/optinterpreter.py

@ -268,7 +268,7 @@ int dummy;
return False return False
suffix = os.path.splitext(source)[1][1:] suffix = os.path.splitext(source)[1][1:]
for lang in self.langs_cant_unity: for lang in self.langs_cant_unity:
if not lang in target.compilers: if lang not in target.compilers:
continue continue
if suffix in target.compilers[lang].file_suffixes: if suffix in target.compilers[lang].file_suffixes:
return False return False
@ -433,7 +433,7 @@ int dummy;
def process_target_dependencies(self, target, outfile): def process_target_dependencies(self, target, outfile):
for t in target.get_dependencies(): for t in target.get_dependencies():
tname = t.get_basename() + t.type_suffix() tname = t.get_basename() + t.type_suffix()
if not tname in self.processed_targets: if tname not in self.processed_targets:
self.generate_target(t, outfile) self.generate_target(t, outfile)
def custom_target_generator_inputs(self, target, outfile): def custom_target_generator_inputs(self, target, outfile):
@ -2076,7 +2076,7 @@ rule FORTRAN_DEP_HACK
result = [] result = []
for ld in link_deps: for ld in link_deps:
prospective = self.get_target_dir(ld) prospective = self.get_target_dir(ld)
if not prospective in result: if prospective not in result:
result.append(prospective) result.append(prospective)
return result return result

@ -315,7 +315,7 @@ class BuildTarget():
def check_unknown_kwargs_int(self, kwargs, known_kwargs): def check_unknown_kwargs_int(self, kwargs, known_kwargs):
unknowns = [] unknowns = []
for k in kwargs: for k in kwargs:
if not k in known_kwargs: if k not in known_kwargs:
unknowns.append(k) unknowns.append(k)
if len(unknowns) > 0: if len(unknowns) > 0:
mlog.warning('Unknown keyword argument(s) in target %s: %s.' % mlog.warning('Unknown keyword argument(s) in target %s: %s.' %
@ -347,7 +347,7 @@ class BuildTarget():
if hasattr(s, 'held_object'): if hasattr(s, 'held_object'):
s = s.held_object s = s.held_object
if isinstance(s, File): if isinstance(s, File):
if not s in added_sources: if s not in added_sources:
self.sources.append(s) self.sources.append(s)
added_sources[s] = True added_sources[s] = True
elif isinstance(s, (GeneratedList, CustomTarget)): elif isinstance(s, (GeneratedList, CustomTarget)):
@ -874,7 +874,7 @@ class Generator():
for rule in outputs: for rule in outputs:
if not isinstance(rule, str): if not isinstance(rule, str):
raise InvalidArguments('"output" may only contain strings.') raise InvalidArguments('"output" may only contain strings.')
if not '@BASENAME@' in rule and not '@PLAINNAME@' in rule: if '@BASENAME@' not in rule and '@PLAINNAME@' not in rule:
raise InvalidArguments('Every element of "output" must contain @BASENAME@ or @PLAINNAME@.') raise InvalidArguments('Every element of "output" must contain @BASENAME@ or @PLAINNAME@.')
if '/' in rule or '\\' in rule: if '/' in rule or '\\' in rule:
raise InvalidArguments('"outputs" must not contain a directory separator.') raise InvalidArguments('"outputs" must not contain a directory separator.')

@ -345,7 +345,7 @@ class WxDependency(Dependency):
def get_requested(self, kwargs): def get_requested(self, kwargs):
modules = 'modules' modules = 'modules'
if not modules in kwargs: if modules not in kwargs:
return [] return []
candidates = kwargs[modules] candidates = kwargs[modules]
if isinstance(candidates, str): if isinstance(candidates, str):

@ -830,9 +830,9 @@ class CrossBuildInfo():
self.parse_datafile(filename) self.parse_datafile(filename)
if 'target_machine' in self.config: if 'target_machine' in self.config:
return return
if not 'host_machine' in self.config: if 'host_machine' not in self.config:
raise mesonlib.MesonException('Cross info file must have either host or a target machine.') raise mesonlib.MesonException('Cross info file must have either host or a target machine.')
if not 'binaries' in self.config: if 'binaries' not in self.config:
raise mesonlib.MesonException('Cross file is missing "binaries".') raise mesonlib.MesonException('Cross file is missing "binaries".')
def ok_type(self, i): def ok_type(self, i):

@ -1278,7 +1278,7 @@ class Interpreter(InterpreterBase):
if len(args) != 1: if len(args) != 1:
raise InvalidCode('Import takes one argument.') raise InvalidCode('Import takes one argument.')
modname = args[0] modname = args[0]
if not modname in self.environment.coredata.modules: if modname not in self.environment.coredata.modules:
module = importlib.import_module('mesonbuild.modules.' + modname).initialize() module = importlib.import_module('mesonbuild.modules.' + modname).initialize()
self.environment.coredata.modules[modname] = module self.environment.coredata.modules[modname] = module
return ModuleHolder(modname, self.environment.coredata.modules[modname], self) return ModuleHolder(modname, self.environment.coredata.modules[modname], self)
@ -1509,7 +1509,7 @@ class Interpreter(InterpreterBase):
self.add_languages(args[1:], True) self.add_languages(args[1:], True)
langs = self.coredata.compilers.keys() langs = self.coredata.compilers.keys()
if 'vala' in langs: if 'vala' in langs:
if not 'c' in langs: if 'c' not in langs:
raise InterpreterException('Compiling Vala requires C. Add C to your project languages and rerun Meson.') raise InterpreterException('Compiling Vala requires C. Add C to your project languages and rerun Meson.')
if not self.is_subproject(): if not self.is_subproject():
self.check_cross_stdlibs() self.check_cross_stdlibs()
@ -1876,7 +1876,7 @@ requirements use the version keyword argument instead.''')
all_args = args[1:] all_args = args[1:]
deps = [] deps = []
elif len(args) == 1: elif len(args) == 1:
if not 'command' in kwargs: if 'command' not in kwargs:
raise InterpreterException('Missing "command" keyword argument') raise InterpreterException('Missing "command" keyword argument')
all_args = kwargs['command'] all_args = kwargs['command']
if not isinstance(all_args, list): if not isinstance(all_args, list):
@ -2054,7 +2054,7 @@ requirements use the version keyword argument instead.''')
def func_install_subdir(self, node, args, kwargs): def func_install_subdir(self, node, args, kwargs):
if len(args) != 1: if len(args) != 1:
raise InvalidArguments('Install_subdir requires exactly one argument.') raise InvalidArguments('Install_subdir requires exactly one argument.')
if not 'install_dir' in kwargs: if 'install_dir' not in kwargs:
raise InvalidArguments('Missing keyword argument install_dir') raise InvalidArguments('Missing keyword argument install_dir')
install_dir = kwargs['install_dir'] install_dir = kwargs['install_dir']
if not isinstance(install_dir, str): if not isinstance(install_dir, str):
@ -2066,7 +2066,7 @@ requirements use the version keyword argument instead.''')
def func_configure_file(self, node, args, kwargs): def func_configure_file(self, node, args, kwargs):
if len(args) > 0: if len(args) > 0:
raise InterpreterException("configure_file takes only keyword arguments.") raise InterpreterException("configure_file takes only keyword arguments.")
if not 'output' in kwargs: if 'output' not in kwargs:
raise InterpreterException('Required keyword argument "output" not defined.') raise InterpreterException('Required keyword argument "output" not defined.')
inputfile = kwargs.get('input', None) inputfile = kwargs.get('input', None)
output = kwargs['output'] output = kwargs['output']
@ -2137,7 +2137,7 @@ requirements use the version keyword argument instead.''')
'been declared.\nThis is not permitted. Please declare all ' \ 'been declared.\nThis is not permitted. Please declare all ' \
'global arguments before your targets.' 'global arguments before your targets.'
raise InvalidCode(msg) raise InvalidCode(msg)
if not 'language' in kwargs: if 'language' not in kwargs:
raise InvalidCode('Missing language definition in add_global_arguments') raise InvalidCode('Missing language definition in add_global_arguments')
lang = kwargs['language'].lower() lang = kwargs['language'].lower()
if lang in self.build.global_args: if lang in self.build.global_args:
@ -2160,7 +2160,7 @@ requirements use the version keyword argument instead.''')
'been declared.\nThis is not permitted. Please declare all ' \ 'been declared.\nThis is not permitted. Please declare all ' \
'global arguments before your targets.' 'global arguments before your targets.'
raise InvalidCode(msg) raise InvalidCode(msg)
if not 'language' in kwargs: if 'language' not in kwargs:
raise InvalidCode('Missing language definition in add_global_link_arguments') raise InvalidCode('Missing language definition in add_global_link_arguments')
lang = kwargs['language'].lower() lang = kwargs['language'].lower()
if lang in self.build.global_link_args: if lang in self.build.global_link_args:
@ -2175,7 +2175,7 @@ requirements use the version keyword argument instead.''')
'been declared.\nThis is not permitted. Please declare all ' \ 'been declared.\nThis is not permitted. Please declare all ' \
'project link arguments before your targets.' 'project link arguments before your targets.'
raise InvalidCode(msg) raise InvalidCode(msg)
if not 'language' in kwargs: if 'language' not in kwargs:
raise InvalidCode('Missing language definition in add_project_link_arguments') raise InvalidCode('Missing language definition in add_project_link_arguments')
lang = kwargs['language'].lower() lang = kwargs['language'].lower()
if self.subproject not in self.build.projects_link_args: if self.subproject not in self.build.projects_link_args:
@ -2192,7 +2192,7 @@ requirements use the version keyword argument instead.''')
'project arguments before your targets.' 'project arguments before your targets.'
raise InvalidCode(msg) raise InvalidCode(msg)
if not 'language' in kwargs: if 'language' not in kwargs:
raise InvalidCode('Missing language definition in add_project_arguments') raise InvalidCode('Missing language definition in add_project_arguments')
if self.subproject not in self.build.projects_args: if self.subproject not in self.build.projects_args:

@ -104,7 +104,7 @@ class Conf:
tgt.set_value(v) tgt.set_value(v)
elif k.endswith('_link_args'): elif k.endswith('_link_args'):
lang = k[:-10] lang = k[:-10]
if not lang in self.coredata.external_link_args: if lang not in self.coredata.external_link_args:
raise ConfException('Unknown language %s in linkargs.' % lang) raise ConfException('Unknown language %s in linkargs.' % lang)
# TODO, currently split on spaces, make it so that user # TODO, currently split on spaces, make it so that user
# can pass in an array string. # can pass in an array string.
@ -112,7 +112,7 @@ class Conf:
self.coredata.external_link_args[lang] = newvalue self.coredata.external_link_args[lang] = newvalue
elif k.endswith('_args'): elif k.endswith('_args'):
lang = k[:-5] lang = k[:-5]
if not lang in self.coredata.external_args: if lang not in self.coredata.external_args:
raise ConfException('Unknown language %s in compile args' % lang) raise ConfException('Unknown language %s in compile args' % lang)
# TODO same fix as above # TODO same fix as above
newvalue = v.split() newvalue = v.split()

@ -639,7 +639,7 @@ can not be used with the current version of glib-compiled-resources, due to
modulename = args[0] modulename = args[0]
if not isinstance(modulename, str): if not isinstance(modulename, str):
raise MesonException('Gtkdoc arg must be string.') raise MesonException('Gtkdoc arg must be string.')
if not 'src_dir' in kwargs: if 'src_dir' not in kwargs:
raise MesonException('Keyword argument src_dir missing.') raise MesonException('Keyword argument src_dir missing.')
main_file = kwargs.get('main_sgml', '') main_file = kwargs.get('main_sgml', '')
if not isinstance(main_file, str): if not isinstance(main_file, str):
@ -657,7 +657,7 @@ can not be used with the current version of glib-compiled-resources, due to
namespace = kwargs.get('namespace', '') namespace = kwargs.get('namespace', '')
mode = kwargs.get('mode', 'auto') mode = kwargs.get('mode', 'auto')
VALID_MODES = ('xml', 'sgml', 'none', 'auto') VALID_MODES = ('xml', 'sgml', 'none', 'auto')
if not mode in VALID_MODES: if mode not in VALID_MODES:
raise MesonException('gtkdoc: Mode {} is not a valid mode: {}'.format(mode, VALID_MODES)) raise MesonException('gtkdoc: Mode {} is not a valid mode: {}'.format(mode, VALID_MODES))
src_dirs = kwargs['src_dir'] src_dirs = kwargs['src_dir']

@ -53,7 +53,7 @@ class I18nModule:
file_type = kwargs.pop('type', 'xml') file_type = kwargs.pop('type', 'xml')
VALID_TYPES = ('xml', 'desktop') VALID_TYPES = ('xml', 'desktop')
if not file_type in VALID_TYPES: if file_type not in VALID_TYPES:
raise MesonException('i18n: "{}" is not a valid type {}'.format(file_type, VALID_TYPES)) raise MesonException('i18n: "{}" is not a valid type {}'.format(file_type, VALID_TYPES))
kwargs['command'] = ['msgfmt', '--' + file_type, kwargs['command'] = ['msgfmt', '--' + file_type,

@ -130,7 +130,7 @@ class OptionInterpreter:
if 'type' not in kwargs: if 'type' not in kwargs:
raise OptionException('Option call missing mandatory "type" keyword argument') raise OptionException('Option call missing mandatory "type" keyword argument')
opt_type = kwargs['type'] opt_type = kwargs['type']
if not opt_type in option_types: if opt_type not in option_types:
raise OptionException('Unknown type %s.' % opt_type) raise OptionException('Unknown type %s.' % opt_type)
if len(posargs) != 1: if len(posargs) != 1:
raise OptionException('Option() must have one (and only one) positional argument') raise OptionException('Option() must have one (and only one) positional argument')

Loading…
Cancel
Save