tools/linelength.py

Sun, 16 Oct 2016 17:54:22 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 16 Oct 2016 17:54:22 +0300
changeset 1039
f68ebbae4efb
parent 1017
fc1c13db9618
child 1058
695edd4f0411
permissions
-rwxr-xr-x

Fixed compilation.

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:
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
8 exceeders = [(i + 1) for i, ln in enumerate(fp.read().splitlines()) if len(ln.replace('\t', ' ')) > 120]
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