count-lines-of-code 759 B

12345678910111213141516171819
  1. #!/usr/bin/env python
  2. import subprocess
  3. ls_files = subprocess.check_output([ 'git', 'ls-files']).decode('utf-8')
  4. all_files = set(ls_files.splitlines())
  5. all_files.discard('')
  6. for attr in ('linguist-generated', 'linguist-vendored'):
  7. cp = subprocess.run(['git', 'check-attr', attr, '--stdin'],
  8. check=True, stdout=subprocess.PIPE, input='\n'.join(all_files).encode('utf-8'))
  9. for line in cp.stdout.decode().splitlines():
  10. if line.endswith(' true'):
  11. fname = line.split(':', 1)[0]
  12. all_files.discard(fname)
  13. all_files -= {'gen/nerd-fonts-glyphs.txt', 'gen/rowcolumn-diacritics.txt'}
  14. cp = subprocess.run(['cloc', '--list-file', '-'], input='\n'.join(all_files).encode())
  15. raise SystemExit(cp.returncode)