File: count-lines-of-code

package info (click to toggle)
kitty 0.42.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 28,564 kB
  • sloc: ansic: 82,787; python: 55,191; objc: 5,122; sh: 1,295; xml: 364; makefile: 143; javascript: 78
file content (18 lines) | stat: -rwxr-xr-x 759 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python

import subprocess

ls_files = subprocess.check_output([ 'git', 'ls-files']).decode('utf-8')
all_files = set(ls_files.splitlines())
all_files.discard('')
for attr in ('linguist-generated', 'linguist-vendored'):
    cp = subprocess.run(['git', 'check-attr', attr, '--stdin'],
                        check=True, stdout=subprocess.PIPE, input='\n'.join(all_files).encode('utf-8'))
    for line in cp.stdout.decode().splitlines():
        if line.endswith(' true'):
            fname = line.split(':', 1)[0]
            all_files.discard(fname)

all_files -= {'gen/nerd-fonts-glyphs.txt', 'gen/rowcolumn-diacritics.txt'}
cp = subprocess.run(['cloc', '--list-file', '-'], input='\n'.join(all_files).encode())
raise SystemExit(cp.returncode)