diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index dcabd0b73..e5682138c 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -796,7 +796,7 @@ int dummy; class_list.append(plain_class_path) class_dep_list = [os.path.join(self.get_target_private_dir(target), i) for i in class_list] jar_rule = 'java_LINKER' - commands = [c+m+e+f] + commands = [c + m + e + f] if e != '': commands.append(main_class) commands.append(self.get_target_filename(target)) diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index 5738dd7f0..e8b60c5af 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -320,7 +320,7 @@ class Vs2010Backend(backends.Backend): return '' directories = os.path.normpath(target.subdir).split(os.sep) - return os.sep.join(['..']*len(directories)) + return os.sep.join(['..'] * len(directories)) def special_quote(self, arr): return ['"%s"' % i for i in arr] @@ -380,7 +380,7 @@ class Vs2010Backend(backends.Backend): cmd += i.fullpath else: cmd.append(i) - cmd_templ = '''"%s" '''*len(cmd) + cmd_templ = '''"%s" ''' * len(cmd) ET.SubElement(customstep, 'Command').text = cmd_templ % tuple(cmd) ET.SubElement(customstep, 'Message').text = 'Running custom command.' ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.targets') @@ -395,7 +395,7 @@ class Vs2010Backend(backends.Backend): # from the target dir, not the build root. target.absolute_paths = True (srcs, ofilenames, cmd) = self.eval_custom_target_command(target, True) - cmd_templ = '''"%s" '''*len(cmd) + cmd_templ = '''"%s" ''' * len(cmd) ET.SubElement(customstep, 'Command').text = cmd_templ % tuple(cmd) ET.SubElement(customstep, 'Outputs').text = ';'.join(ofilenames) ET.SubElement(customstep, 'Inputs').text = ';'.join(srcs) diff --git a/mesonbuild/backend/xcodebackend.py b/mesonbuild/backend/xcodebackend.py index 77eb2ef7d..691a36057 100644 --- a/mesonbuild/backend/xcodebackend.py +++ b/mesonbuild/backend/xcodebackend.py @@ -60,7 +60,7 @@ class XCodeBackend(backends.Backend): return dirname def write_line(self, text): - self.ofile.write(self.indent*self.indent_level + text) + self.ofile.write(self.indent * self.indent_level + text) if not text.endswith('\n'): self.ofile.write('\n') diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index 801dffb5a..4e245e1d8 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -307,7 +307,7 @@ def build_unix_rpath_args(build_dir, rpath_paths, install_rpath): return [] paths = ':'.join([os.path.join(build_dir, p) for p in rpath_paths]) if len(paths) < len(install_rpath): - padding = 'X'*(len(install_rpath) - len(paths)) + padding = 'X' * (len(install_rpath) - len(paths)) if len(paths) == 0: paths = padding else: @@ -651,7 +651,7 @@ class CCompiler(Compiler): return os.path.split(header_name)[-1] + '.' + self.get_pch_suffix() def get_linker_search_args(self, dirname): - return ['-L'+dirname] + return ['-L' + dirname] def gen_import_library_args(self, implibname): """ @@ -1654,7 +1654,7 @@ class DCompiler(Compiler): return [] paths = ':'.join([os.path.join(build_dir, p) for p in rpath_paths]) if len(paths) < len(install_rpath): - padding = 'X'*(len(install_rpath) - len(paths)) + padding = 'X' * (len(install_rpath) - len(paths)) if len(paths) == 0: paths = padding else: @@ -1671,7 +1671,7 @@ class DCompiler(Compiler): if arg == '-pthread': continue if arg.startswith('-Wl,'): - linkargs = arg[arg.index(',')+1:].split(',') + linkargs = arg[arg.index(',') + 1:].split(',') for la in linkargs: dcargs.append('-L' + la.strip()) continue @@ -1716,7 +1716,7 @@ class GnuDCompiler(DCompiler): return ['-Werror'] def get_linker_search_args(self, dirname): - return ['-L'+dirname] + return ['-L' + dirname] def get_buildtype_args(self, buildtype): return d_gdc_buildtype_args[buildtype] @@ -1774,7 +1774,7 @@ class LLVMDCompiler(DCompiler): # -L is recognized as "add this to the search path" by the linker, # while the compiler recognizes it as "pass to linker". So, the first # -L is for the compiler, telling it to pass the second -L to the linker. - return ['-L-L'+dirname] + return ['-L-L' + dirname] def unix_link_flags_to_native(self, args): return self.translate_args_to_nongnu(args) @@ -1820,7 +1820,7 @@ class DmdDCompiler(DCompiler): # -L is recognized as "add this to the search path" by the linker, # while the compiler recognizes it as "pass to linker". So, the first # -L is for the compiler, telling it to pass the second -L to the linker. - return ['-L-L'+dirname] + return ['-L-L' + dirname] def get_buildtype_args(self, buildtype): return d_dmd_buildtype_args[buildtype] @@ -1997,7 +1997,7 @@ class VisualStudioCCompiler(CCompiler): def has_multi_arguments(self, args, env): warning_text = '9002' code = 'int i;\n' - (fd, srcname) = tempfile.mkstemp(suffix='.'+self.default_suffix) + (fd, srcname) = tempfile.mkstemp(suffix='.' + self.default_suffix) os.close(fd) with open(srcname, 'w') as ofile: ofile.write(code) @@ -2523,7 +2523,7 @@ class G95FortranCompiler(FortranCompiler): self.id = 'g95' def get_module_outdir_args(self, path): - return ['-fmod='+path] + return ['-fmod=' + path] def get_always_args(self): return ['-pipe'] @@ -2555,7 +2555,7 @@ class SunFortranCompiler(FortranCompiler): return [] def get_module_outdir_args(self, path): - return ['-moddir='+path] + return ['-moddir=' + path] class IntelFortranCompiler(FortranCompiler): std_warn_args = ['-warn', 'all'] diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py index 027dd5830..44a333128 100644 --- a/mesonbuild/mconf.py +++ b/mesonbuild/mconf.py @@ -67,8 +67,8 @@ class Conf: if longest_possible_value > 0: titles[3] = 'Possible Values' - print(' %s%s %s%s %s%s %s' % (titles[0], ' '*(longest_name - len(titles[0])), titles[1], ' '*(longest_descr - len(titles[1])), titles[2], ' '*(longest_value - len(titles[2])), titles[3])) - print(' %s%s %s%s %s%s %s' % ('-'*len(titles[0]), ' '*(longest_name - len(titles[0])), '-'*len(titles[1]), ' '*(longest_descr - len(titles[1])), '-'*len(titles[2]), ' '*(longest_value - len(titles[2])), '-'*len(titles[3]))) + print(' %s%s %s%s %s%s %s' % (titles[0], ' ' * (longest_name - len(titles[0])), titles[1], ' ' * (longest_descr - len(titles[1])), titles[2], ' ' * (longest_value - len(titles[2])), titles[3])) + print(' %s%s %s%s %s%s %s' % ('-' * len(titles[0]), ' ' * (longest_name - len(titles[0])), '-' * len(titles[1]), ' ' * (longest_descr - len(titles[1])), '-' * len(titles[2]), ' ' * (longest_value - len(titles[2])), '-' * len(titles[3]))) for i in arr: name = i[0] descr = i[1] @@ -80,9 +80,9 @@ class Conf: possible_values = '[%s]' % ', '.join(map(str, i[3])) elif i[3]: possible_values = i[3] if isinstance(i[3], str) else str(i[3]).lower() - namepad = ' '*(longest_name - len(name)) - descrpad = ' '*(longest_descr - len(descr)) - valuepad = ' '*(longest_value - len(str(value))) + namepad = ' ' * (longest_name - len(name)) + descrpad = ' ' * (longest_descr - len(descr)) + valuepad = ' ' * (longest_value - len(str(value))) f = ' %s%s %s%s %s%s %s' % (name, namepad, descr, descrpad, value, valuepad, possible_values) print(f) diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py index b7e5a8cc7..a919fe51e 100644 --- a/mesonbuild/modules/gnome.py +++ b/mesonbuild/modules/gnome.py @@ -362,7 +362,7 @@ can not be used with the current version of glib-compiled-resources, due to scan_command = giscanner.get_command() + ['@INPUT@'] scan_command += pkgargs - scan_command += ['--no-libtool', '--namespace='+ns, '--nsversion=' + nsversion, '--warn-all', + scan_command += ['--no-libtool', '--namespace=' + ns, '--nsversion=' + nsversion, '--warn-all', '--output', '@OUTPUT@'] extra_args = mesonlib.stringlistify(kwargs.pop('extra_args', [])) diff --git a/mesonbuild/mparser.py b/mesonbuild/mparser.py index 17ca3b8a6..2fc248718 100644 --- a/mesonbuild/mparser.py +++ b/mesonbuild/mparser.py @@ -87,7 +87,7 @@ class Lexer: mo = reg.match(code, loc) if mo: curline = lineno - col = mo.start()-line_start + col = mo.start() - line_start matched = True span_start = loc loc = mo.end() diff --git a/mesonbuild/scripts/depfixer.py b/mesonbuild/scripts/depfixer.py index baa401eca..1a19a8acf 100644 --- a/mesonbuild/scripts/depfixer.py +++ b/mesonbuild/scripts/depfixer.py @@ -29,25 +29,25 @@ class DataSizes(): p = '<' else: p = '>' - self.Half = p+'h' + self.Half = p + 'h' self.HalfSize = 2 - self.Word = p+'I' + self.Word = p + 'I' self.WordSize = 4 - self.Sword = p+'i' + self.Sword = p + 'i' self.SwordSize = 4 if ptrsize == 64: - self.Addr = p+'Q' + self.Addr = p + 'Q' self.AddrSize = 8 - self.Off = p+'Q' + self.Off = p + 'Q' self.OffSize = 8 - self.XWord = p+'Q' + self.XWord = p + 'Q' self.XWordSize = 8 - self.Sxword = p+'q' + self.Sxword = p + 'q' self.SxwordSize = 8 else: - self.Addr = p+'I' + self.Addr = p + 'I' self.AddrSize = 4 - self.Off = p+'I' + self.Off = p + 'I' self.OffSize = 4 class DynamicEntry(DataSizes): @@ -273,7 +273,7 @@ class Elf(DataSizes): name = self.read_str() if name.startswith(prefix): basename = name.split(b'/')[-1] - padding = b'\0'*(len(name) - len(basename)) + padding = b'\0' * (len(name) - len(basename)) newname = basename + padding assert(len(newname) == len(name)) self.bf.seek(offset) @@ -299,7 +299,7 @@ class Elf(DataSizes): sys.exit("New rpath must not be longer than the old one.") self.bf.seek(rp_off) self.bf.write(new_rpath) - self.bf.write(b'\0'*(len(old_rpath) - len(new_rpath) + 1)) + self.bf.write(b'\0' * (len(old_rpath) - len(new_rpath) + 1)) if len(new_rpath) == 0: self.remove_rpath_entry(entrynum) @@ -311,7 +311,7 @@ class Elf(DataSizes): if entry.d_tag == entrynum: rpentry = self.dynamic[i] rpentry.d_tag = 0 - self.dynamic = self.dynamic[:i] + self.dynamic[i+1:] + [rpentry] + self.dynamic = self.dynamic[:i] + self.dynamic[i + 1:] + [rpentry] break; # DT_MIPS_RLD_MAP_REL is relative to the offset of the tag. Adjust it consequently. for entry in self.dynamic[i:]: diff --git a/mesonbuild/scripts/meson_install.py b/mesonbuild/scripts/meson_install.py index f497f2cc2..881615ddd 100644 --- a/mesonbuild/scripts/meson_install.py +++ b/mesonbuild/scripts/meson_install.py @@ -51,7 +51,7 @@ def do_copydir(src_prefix, src_dir, dst_dir): for root, dirs, files in os.walk(src_prefix): for d in dirs: abs_src = os.path.join(src_dir, root, d) - filepart = abs_src[len(src_dir)+1:] + filepart = abs_src[len(src_dir) + 1:] abs_dst = os.path.join(dst_dir, filepart) if os.path.isdir(abs_dst): continue @@ -62,7 +62,7 @@ def do_copydir(src_prefix, src_dir, dst_dir): shutil.copystat(abs_src, abs_dst) for f in files: abs_src = os.path.join(src_dir, root, f) - filepart = abs_src[len(src_dir)+1:] + filepart = abs_src[len(src_dir) + 1:] abs_dst = os.path.join(dst_dir, filepart) if os.path.isdir(abs_dst): print('Tried to copy file %s but a directory of that name already exists.' % abs_dst) diff --git a/mesonbuild/scripts/symbolextractor.py b/mesonbuild/scripts/symbolextractor.py index bfd629f64..976d2f088 100644 --- a/mesonbuild/scripts/symbolextractor.py +++ b/mesonbuild/scripts/symbolextractor.py @@ -80,7 +80,7 @@ def osx_syms(libfilename, outfilename): if 'LC_ID_DYLIB' in val: match = i break - result = [arr[match+2], arr[match+5]] # Libreoffice stores all 5 lines but the others seem irrelevant. + result = [arr[match + 2], arr[match + 5]] # Libreoffice stores all 5 lines but the others seem irrelevant. pnm, output = Popen_safe(['nm', '-g', '-P', libfilename])[0:2] if pnm.returncode != 0: raise RuntimeError('nm does not work.') diff --git a/mesonbuild/scripts/yelphelper.py b/mesonbuild/scripts/yelphelper.py index e5b3b1126..85d89b8d8 100644 --- a/mesonbuild/scripts/yelphelper.py +++ b/mesonbuild/scripts/yelphelper.py @@ -33,7 +33,7 @@ def build_pot(srcdir, project_id, sources): # Must be relative paths sources = [os.path.join('C', source) for source in sources] outfile = os.path.join(srcdir, project_id + '.pot') - subprocess.call(['itstool', '-o', outfile]+sources) + subprocess.call(['itstool', '-o', outfile] + sources) def update_po(srcdir, project_id, langs): potfile = os.path.join(srcdir, project_id + '.pot') @@ -55,7 +55,7 @@ def merge_translations(blddir, sources, langs): subprocess.call([ 'itstool', '-m', os.path.join(blddir, lang, lang + '.gmo'), '-o', os.path.join(blddir, lang) - ]+sources) + ] + sources) def install_help(srcdir, blddir, sources, media, langs, install_dir, destdir, project_id, symlinks): c_install_dir = os.path.join(install_dir, 'C', project_id) diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index 3db3f9bfc..d25769a38 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -181,7 +181,7 @@ class Resolver: cwd=checkoutdir) def get_data(self, url): - blocksize = 10*1024 + blocksize = 10 * 1024 if url.startswith('https://wrapdb.mesonbuild.com'): resp = open_wrapdburl(url) else: @@ -206,7 +206,7 @@ class Resolver: break downloaded += len(block) blocks.append(block) - ratio = int(downloaded/dlsize * 10) + ratio = int(downloaded / dlsize * 10) while printed_dots < ratio: print('.', end='') sys.stdout.flush() diff --git a/mesontest.py b/mesontest.py index dd76e30fc..240b4f70e 100755 --- a/mesontest.py +++ b/mesontest.py @@ -274,10 +274,10 @@ class TestHarness: return result def print_stats(self, numlen, tests, name, result, i, logfile, jsonlogfile): - startpad = ' '*(numlen - len('%d' % (i+1))) - num = '%s%d/%d' % (startpad, i+1, len(tests)) - padding1 = ' '*(38-len(name)) - padding2 = ' '*(8-len(result.res)) + startpad = ' ' * (numlen - len('%d' % (i + 1))) + num = '%s%d/%d' % (startpad, i + 1, len(tests)) + padding1 = ' ' * (38 - len(name)) + padding2 = ' ' * (8 - len(result.res)) result_str = '%s %s %s%s%s%5.2f s' % \ (num, name, padding1, result.res, padding2, result.duration) print(result_str) @@ -425,7 +425,7 @@ class TestHarness: for t in tests: if t.name in self.options.args: for i in range(self.options.repeat): - print('Running: %s %d/%d' % (t.name, i+1, self.options.repeat)) + print('Running: %s %d/%d' % (t.name, i + 1, self.options.repeat)) if self.options.gdb: wrap = ['gdb', '--quiet'] if len(t.cmd_args) > 0: diff --git a/run_project_tests.py b/run_project_tests.py index 6e2cb4565..a11847bde 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -59,7 +59,7 @@ class AutoDeletedDir(): shutil.rmtree(self.dir) return except OSError: - if i == retries-1: + if i == retries - 1: raise time.sleep(0.1 * (2**i)) @@ -472,7 +472,7 @@ def check_format(): def pbcompile(compiler, source, objectfile): if compiler == 'cl': - cmd = [compiler, '/nologo', '/Fo'+objectfile, '/c', source] + cmd = [compiler, '/nologo', '/Fo' + objectfile, '/c', source] else: cmd = [compiler, '-c', source, '-o', objectfile] subprocess.check_call(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) diff --git a/test cases/common/129 object only target/obj_generator.py b/test cases/common/129 object only target/obj_generator.py index a1f7421eb..f0239b44e 100755 --- a/test cases/common/129 object only target/obj_generator.py +++ b/test cases/common/129 object only target/obj_generator.py @@ -12,7 +12,7 @@ if __name__ == '__main__': ifile = sys.argv[2] ofile = sys.argv[3] if compiler.endswith('cl'): - cmd = [compiler, '/nologo', '/MDd', '/Fo'+ofile, '/c', ifile] + cmd = [compiler, '/nologo', '/MDd', '/Fo' + ofile, '/c', ifile] else: cmd = [compiler, '-c', ifile, '-o', ofile] sys.exit(subprocess.call(cmd)) diff --git a/test cases/common/59 object generator/obj_generator.py b/test cases/common/59 object generator/obj_generator.py index d028156ac..a33872aac 100755 --- a/test cases/common/59 object generator/obj_generator.py +++ b/test cases/common/59 object generator/obj_generator.py @@ -12,7 +12,7 @@ if __name__ == '__main__': ifile = sys.argv[2] ofile = sys.argv[3] if compiler.endswith('cl'): - cmd = [compiler, '/nologo', '/MDd', '/Fo'+ofile, '/c', ifile] + cmd = [compiler, '/nologo', '/MDd', '/Fo' + ofile, '/c', ifile] else: cmd = [compiler, '-c', ifile, '-o', ofile] sys.exit(subprocess.call(cmd)) diff --git a/tools/cmake2meson.py b/tools/cmake2meson.py index 7b28597cc..28222a58c 100755 --- a/tools/cmake2meson.py +++ b/tools/cmake2meson.py @@ -53,7 +53,7 @@ class Lexer: for (tid, reg) in self.token_specification: mo = reg.match(code, loc) if mo: - col = mo.start()-line_start + col = mo.start() - line_start matched = True loc = mo.end() match_text = mo.group() @@ -240,7 +240,7 @@ class Converter: else: line = '''# %s(%s)''' % (t.name, self.convert_args(t.args)) self.indent_level += preincrement - indent = self.indent_level*self.indent_unit + indent = self.indent_level * self.indent_unit outfile.write(indent) outfile.write(line) if not(line.endswith('\n')):