tools/linelength.py

Sun, 14 Feb 2016 03:19:28 +0200

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sun, 14 Feb 2016 03:19:28 +0200
changeset 1017
fc1c13db9618
child 1058
695edd4f0411
permissions
-rwxr-xr-x

Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Added transform.h that may or may not prove useful sometime
Added linelength.py that was missing from a prior commit
Converted the various boolean members of LDDocument to flags

#!/usr/bin/env python3
from sys import argv, stderr
from os.path import realpath

for filename in argv[1:]:
	with open(filename, 'r') as fp:
		try:
			exceeders = [(i + 1) for i, ln in enumerate(fp.read().splitlines()) if len(ln.replace('\t', '    ')) > 120]

			for linenumber in exceeders:
				stderr.write('%s:%d: warning: line length exceeds 120 characters\n' % (realpath(filename), linenumber))
		except Exception as e:
			stderr.write('%s: warning: %s: %s\n' % (realpath(filename), type(e).__name__, e))

mercurial