#!/usr/bin/env python import subprocess files_to_exclude = '''\ kitty/wcwidth-std.h kitty/charsets.c kitty/unicode-data.c kitty/key_encoding.py kitty/rgb.py kitty/gl.h kitty/gl-wrapper.h kitty/gl-wrapper.c kitty/glfw-wrapper.h kitty/glfw-wrapper.c kitty/emoji.h kittens/unicode_input/names.h kitty/parse-graphics-command.h kitty/options/types.py kitty/options/parse.py kitty/options/to-c-generated.h kittens/diff/options/types.py kittens/diff/options/parse.py tools/wcswidth/std.go ''' ignored = [] for line in subprocess.check_output(['git', 'status', '--ignored', '--porcelain']).decode().splitlines(): if line.startswith('!! '): ignored.append(line[3:]) files_to_exclude += '\n'.join(ignored) p = subprocess.Popen([ 'cloc', '--exclude-list-file', '/dev/stdin', 'kitty', 'kittens', 'tools', ], stdin=subprocess.PIPE) p.communicate(files_to_exclude.encode('utf-8')) raise SystemExit(p.wait())