tools/indentlevel.py

Sun, 03 Jul 2022 13:44:11 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Sun, 03 Jul 2022 13:44:11 +0300
changeset 319
9727e545b0bc
parent 317
852021f38b66
permissions
-rw-r--r--

Extract the triangulation and triangle merging code into a new source file and clean it up somewhat

#!/usr/bin/env python3
import sys
too_many = 6
for filename in sys.argv[1:]:
	with open(filename) as file:
		at_start_of_new_block = False
		old_n = 0
		for linenumber, line in enumerate(file, 1):
			import re
			n = len(re.match('^(\t*).*$', line).group(1))
			if at_start_of_new_block and n >= too_many and old_n < too_many:
				print(f'{filename}:{linenumber}: warning: block with {n} indent levels', file = sys.stderr)
			at_start_of_new_block = line.strip().endswith('{')
			old_n = n

mercurial