tools/linelength.py

Thu, 23 Feb 2017 23:36:59 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Thu, 23 Feb 2017 23:36:59 +0200
changeset 1172
3defab8cfd93
parent 1058
695edd4f0411
permissions
-rwxr-xr-x

Changed QByteArray to QVector to avoid that ugly reinterpret_cast.

1017
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python3
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 from sys import argv, stderr
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 from os.path import realpath
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 for filename in argv[1:]:
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 with open(filename, 'r') as fp:
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 try:
1058
695edd4f0411 Cleaned up crash catcher, fixed missing <math.h> include
Teemu Piippo <teemu@hecknology.net>
parents: 1017
diff changeset
8 exceeders = [(i + 1) for i, ln in enumerate(fp.read().splitlines()) if len(ln.replace('\t', ' ')) > 140]
1017
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 for linenumber in exceeders:
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 stderr.write('%s:%d: warning: line length exceeds 120 characters\n' % (realpath(filename), linenumber))
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 except Exception as e:
fc1c13db9618 Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 stderr.write('%s: warning: %s: %s\n' % (realpath(filename), type(e).__name__, e))

mercurial