aboutsummaryrefslogtreecommitdiff
path: root/scripts/check-includes.py
diff options
context:
space:
mode:
authorDaniel Hahler <git@thequod.de>2019-07-29 04:43:28 +0200
committerDaniel Hahler <git@thequod.de>2019-07-29 22:14:23 +0200
commit97ce776e7ba68d1966fddba475b11e85a6c53420 (patch)
tree4497a57464593e468d152eb7272717f6039f35a3 /scripts/check-includes.py
parentbae02eb3968be1c9677283d030fbbe6dd02cb180 (diff)
downloadrneovim-97ce776e7ba68d1966fddba475b11e85a6c53420.tar.gz
rneovim-97ce776e7ba68d1966fddba475b11e85a6c53420.tar.bz2
rneovim-97ce776e7ba68d1966fddba475b11e85a6c53420.zip
scripts: autopep8
Diffstat (limited to 'scripts/check-includes.py')
-rwxr-xr-xscripts/check-includes.py84
1 files changed, 42 insertions, 42 deletions
diff --git a/scripts/check-includes.py b/scripts/check-includes.py
index 21308a21aa..735fb393dd 100755
--- a/scripts/check-includes.py
+++ b/scripts/check-includes.py
@@ -9,58 +9,58 @@ from argparse import ArgumentParser
GENERATED_INCLUDE_RE = re.compile(
- r'^\s*#\s*include\s*"([/a-z_0-9.]+\.generated\.h)"(\s+//.*)?$')
+ r'^\s*#\s*include\s*"([/a-z_0-9.]+\.generated\.h)"(\s+//.*)?$')
def main(argv):
- argparser = ArgumentParser()
- argparser.add_argument('--generated-includes-dir', action='append',
- help='Directory where generated includes are located.')
- argparser.add_argument('--file', type=open, help='File to check.')
- argparser.add_argument('iwyu_args', nargs='*',
- help='IWYU arguments, must go after --.')
- args = argparser.parse_args(argv)
+ argparser = ArgumentParser()
+ argparser.add_argument('--generated-includes-dir', action='append',
+ help='Directory where generated includes are located.')
+ argparser.add_argument('--file', type=open, help='File to check.')
+ argparser.add_argument('iwyu_args', nargs='*',
+ help='IWYU arguments, must go after --.')
+ args = argparser.parse_args(argv)
- with args.file:
- include_dirs = []
+ with args.file:
+ include_dirs = []
- iwyu = Popen(['include-what-you-use', '-xc'] + args.iwyu_args + ['/dev/stdin'],
- stdin=PIPE, stdout=PIPE, stderr=PIPE)
+ iwyu = Popen(['include-what-you-use', '-xc'] + args.iwyu_args + ['/dev/stdin'],
+ stdin=PIPE, stdout=PIPE, stderr=PIPE)
- for line in args.file:
- match = GENERATED_INCLUDE_RE.match(line)
- if match:
- for d in args.generated_includes_dir:
- try:
- f = open(os.path.join(d, match.group(1)))
- except IOError:
- continue
- else:
- with f:
- for generated_line in f:
- iwyu.stdin.write(generated_line)
- break
- else:
- raise IOError('Failed to find {0}'.format(match.group(1)))
- else:
- iwyu.stdin.write(line)
+ for line in args.file:
+ match = GENERATED_INCLUDE_RE.match(line)
+ if match:
+ for d in args.generated_includes_dir:
+ try:
+ f = open(os.path.join(d, match.group(1)))
+ except IOError:
+ continue
+ else:
+ with f:
+ for generated_line in f:
+ iwyu.stdin.write(generated_line)
+ break
+ else:
+ raise IOError('Failed to find {0}'.format(match.group(1)))
+ else:
+ iwyu.stdin.write(line)
- iwyu.stdin.close()
+ iwyu.stdin.close()
- out = iwyu.stdout.read()
- err = iwyu.stderr.read()
+ out = iwyu.stdout.read()
+ err = iwyu.stderr.read()
- ret = iwyu.wait()
+ ret = iwyu.wait()
- if ret != 2:
- print('IWYU failed with exit code {0}:'.format(ret))
- print('{0} stdout {0}'.format('=' * ((80 - len(' stdout ')) // 2)))
- print(out)
- print('{0} stderr {0}'.format('=' * ((80 - len(' stderr ')) // 2)))
- print(err)
- return 1
- return 0
+ if ret != 2:
+ print('IWYU failed with exit code {0}:'.format(ret))
+ print('{0} stdout {0}'.format('=' * ((80 - len(' stdout ')) // 2)))
+ print(out)
+ print('{0} stderr {0}'.format('=' * ((80 - len(' stderr ')) // 2)))
+ print(err)
+ return 1
+ return 0
if __name__ == '__main__':
- raise SystemExit(main(sys.argv[1:]))
+ raise SystemExit(main(sys.argv[1:]))